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.15.0.dev202610182305

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.15.0.dev202610182305
File Size Uploaded Provenance
barndoor-2.15.0.dev202610182305.tar.gz 241.0 kB With provenance Details

Built distribution (wheel)

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

Total release size: 826.8 kB

Release files / barndoor-2.15.0.dev202610182305.tar.gz

Download URL barndoor-2.15.0.dev202610182305.tar.gz
Size 241.0 kB
Tags Source
SHA-256 checksum
How to use checksums
134323d84f2c3f5715c34ef8f401ac94bc542c3a3d929dd05b3d6a514c7fbf5a
BLAKE2b-256 checksum
How to use checksums
1e14d6a8d057bf1b53fabc872b0968cb51f70a5f5b2f0782f74cfcf37ce49080
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 18, 2026.

Transparency log

Release files / barndoor-2.15.0.dev202610182305-py3-none-any.whl

Download URL barndoor-2.15.0.dev202610182305-py3-none-any.whl
Size 585.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
63971dba4aed1720a3de2f1c322f1f8dd17fb62370a01085dc353290a482a051
BLAKE2b-256 checksum
How to use checksums
a2fb16e66af27ebf0068da6a47ebf2d33029a0b225bc7abe978f504880145585
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 18, 2026.

Transparency log

Security for barndoor 2.15.0.dev202610182305

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.15.0.dev202610182305.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 18, 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