Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

barndoor

Official Python SDK for the Barndoor AI platform API.

pip install barndoor

Python 3.11 or later. Async, fully typed.

Quick start

import asyncio
from barndoor import create_client

async def main():
    client = create_client(auth="bdai_…")
    page = await client.registry.list_mcp_servers(limit=10)
    for server in page.data:
        print(server.name, server.slug)
    await client.aclose()

asyncio.run(main())

create_client is synchronous and touches no network, so building a client cannot fail because an identity provider is briefly unreachable. Use it as an async context manager to close the connection pool for you:

async with create_client(auth="bdai_…") as client:
    ...

Authentication

auth takes one of three things.

An API key, or any token you already hold:

create_client(auth="bdai_…")

Machine-to-machine credentials, exchanged and refreshed for you:

from barndoor import ClientCredentialsOptions

create_client(auth=ClientCredentialsOptions(
    client_id=os.environ["BARNDOOR_CLIENT_ID"],
    client_secret=os.environ["BARNDOOR_CLIENT_SECRET"],
))

Your own provider, an async callable asked on every request — for a token you source from a secrets manager or an inbound request:

create_client(auth=lambda: fetch_token_from_vault())

For a user-facing login there is start_authorization_code / complete_authorization_code (PKCE), and barndoor-login runs the browser flow from a terminal.

API surface

Namespace Covers
client.registry MCP servers, agents, connections, the directory
client.policy Policies, rules, impact analysis
client.identity Organizations, users, groups, identity providers
client.notification Channels, alerts, subscriptions
client.dlp Detection rules, findings, redaction
client.llm_gateway Models, budgets, API keys, usage
client.system_management Operational endpoints

The full surface is the OpenAPI specification the client is generated from, published here as openapi.yaml. Types ship with the package, so your editor is usually the fastest reference.

Connecting to MCP

The platform serves MCP as well as REST, authenticated with the same credentials:

from barndoor import create_client, mcp_client

async with create_client(auth="bdai_…") as client:
    async with mcp_client(client, "acme") as session:
        tools = await session.list_tools()

A context manager because the transport owns a connection — an async with cannot be forgotten on an early return. If you would rather hand connection details to another framework, mcp_connection_params returns the URL and headers without opening anything.

Reliability

Requests are retried with jittered exponential backoff. Only idempotent methods are retried: a 502 does not say whether a write landed, so repeating a POST risks a duplicate.

from barndoor import RetryOptions

create_client(auth=key, retry=RetryOptions(retries=5, timeout=60.0))
create_client(auth=key, retry=RetryOptions(retries=0))   # off

Retry-After is honoured, in both its seconds and HTTP-date forms.

Non-production environments

Production is the default and needs no configuration.

from barndoor import create_client, DEV, environment_from_env

create_client(auth=key, env=DEV)
create_client(auth=key, env=environment_from_env())   # reads BARNDOOR_ENV

Credentials inherit the environment's issuer, so pointing at dev cannot leave you calling dev with a production token. The SDK never reads the environment unless you ask it to.

Examples

Runnable examples are in examples/.

Versioning

The version is the version of the API contract, so which SDK speaks to which API needs no lookup table. It is independent of the Barndoor platform's own release version.

Part Changes when
MAJOR the API breaks — an operation removed, a field made required
MINOR the API gains something — a new operation or optional field
PATCH the SDK changes on its own — a fix, a dependency bump

Versions carrying a .devN suffix are prereleases built from unreleased platform work. pip install barndoor gives you the latest formal release.

This repository is generated

The client, this README and the examples are generated or maintained in Barndoor's platform monorepo and pushed here, which is where the package is published from. Pull requests against generated files here will be overwritten. Open an issue instead, or contact your Barndoor representative.

License

MIT — see LICENSE.

Metadata

Release files for barndoor 2.17.0.dev202610192128

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for barndoor 2.17.0.dev202610192128
File Size Uploaded Provenance
barndoor-2.17.0.dev202610192128.tar.gz 241.9 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for barndoor 2.17.0.dev202610192128
File Interpreter ABI Platform
barndoor-2.17.0.dev202610192128-py3-none-any.whl Python 3 none any Details

Total release size: 830.0 kB

Release files / barndoor-2.17.0.dev202610192128.tar.gz

Download URL barndoor-2.17.0.dev202610192128.tar.gz
Size 241.9 kB
Tags Source
SHA-256 checksum
How to use checksums
0ee37ec819a864e61876afe39c265523cf574ea3c7a012ef9c1e93075aab3b20
BLAKE2b-256 checksum
How to use checksums
50e1bda475becb3b719bec818754efd8fe5f0a73dda556f1c44ecd70375e3d02
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 19, 2026.

Transparency log

Release files / barndoor-2.17.0.dev202610192128-py3-none-any.whl

Download URL barndoor-2.17.0.dev202610192128-py3-none-any.whl
Size 588.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5dfe5023fd025d7a11e479c32da3f0ca950ab7e9840ce3acbf1fd6bfbc9f1537
BLAKE2b-256 checksum
How to use checksums
fd9271353e7926c85bfd4238ff5e010784d827f568f81cea2cecf7883aa1ab63
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 19, 2026.

Transparency log

Security for barndoor 2.17.0.dev202610192128

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for barndoor-2.17.0.dev202610192128.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 19, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Release history Release notifications | RSS feed

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page