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.

Release files for barndoor 2.2.0.dev202609252104

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.2.0.dev202609252104
File Size Uploaded
barndoor-2.2.0.dev202609252104.tar.gz 222.7 kB Details

Built distribution (wheel)

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

Total release size: 767.2 kB

Release files / barndoor-2.2.0.dev202609252104.tar.gz

Download URL barndoor-2.2.0.dev202609252104.tar.gz
Size 222.7 kB
Tags Source
SHA-256 checksum
How to use checksums
7907eb295ba77748593d49340e9d2a45b6aebb8e66775c2a9b05bea2e2c264bf
BLAKE2b-256 checksum
How to use checksums
b12f5ae4fa2b17abf763763cf7b38a19b12678f82c6e4ce57eb18929c3364243
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 Sep 25, 2026.

Transparency log

Release files / barndoor-2.2.0.dev202609252104-py3-none-any.whl

Download URL barndoor-2.2.0.dev202609252104-py3-none-any.whl
Size 544.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4eb1eb81be1bbc4ac973250f99f35495ec002531a5aa895d076d15bcfa5d3a5a
BLAKE2b-256 checksum
How to use checksums
4e0ca17828a9c8ca6b3a195f3445b129f018a1b00a0056c62ce14ab2ec254b03
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 Sep 25, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

1.3.0

2 release files

1.2.0

2 release files

1.1.0

2 release files

1.0.3

2 release files

1.0.1

2 release files

1.0.0

2 release files

0.4.3

2 release files

0.4.2

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.0

2 release files

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