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.3.0.dev202609281504

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.3.0.dev202609281504
File Size Uploaded Provenance
barndoor-2.3.0.dev202609281504.tar.gz 225.4 kB With provenance Details

Built distribution (wheel)

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

Total release size: 774.3 kB

Release files / barndoor-2.3.0.dev202609281504.tar.gz

Download URL barndoor-2.3.0.dev202609281504.tar.gz
Size 225.4 kB
Tags Source
SHA-256 checksum
How to use checksums
194be2e587753c085605d0fc4c1ec1376d90df138ab8564c5f03c465cefeec97
BLAKE2b-256 checksum
How to use checksums
d242ca6857eb569eeb48f541350b6d5d0855d0d09b6efefb14bfebd298980a59
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 28, 2026.

Transparency log

Release files / barndoor-2.3.0.dev202609281504-py3-none-any.whl

Download URL barndoor-2.3.0.dev202609281504-py3-none-any.whl
Size 548.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
de829954ddd04f6fddde4bc5d92cbaddce9f5caed0ed7bb8be3bc5979e8687dc
BLAKE2b-256 checksum
How to use checksums
35bf922c504ac899555d02fb34cabd748956607de087b89454c5a768c679874b
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 28, 2026.

Transparency log

Security for barndoor 2.3.0.dev202609281504

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.3.0.dev202609281504.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 Sep 28, 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