Skip to main content

dendrux

Python SDK for Dendrux — the framework for building agents with tools, persistence, and observability.

Version: 0.6.0

Install

pip install "dendrux[all]"              # Everything
pip install "dendrux[anthropic]"        # Anthropic + core runtime
pip install "dendrux[openai]"           # OpenAI + core runtime
pip install "dendrux[mcp]"              # Managed MCP client runtime

Provider extras require anthropic>=0.77.0,<1.0 and openai>=1.97.2,<3.0. The openrouter extra uses the OpenAI requirement; all includes both.

Quick Example

import asyncio
from dendrux import Agent, tool
from dendrux.llm.anthropic import AnthropicProvider

@tool()
async def add(a: int, b: int) -> int:
    """Add two numbers."""
    return a + b

async def main():
    async with Agent(
        provider=AnthropicProvider(model="claude-sonnet-4-6"),
        prompt="You are a calculator.",
        tools=[add],
        strict_tenancy=False,  # single-tenant example; see Multi-tenancy
    ) as agent:
        result = await agent.run("What is 15 + 27?")
        print(result.answer)

asyncio.run(main())

Managed MCP client

MCPRuntime is the application-scoped owner of process-local MCP connections. Bind cheaply for each request, hand an explicit tool view to an ephemeral Agent, and close the runtime once during application shutdown:

from dendrux import Agent
from dendrux.mcp import MCPRuntime, MCPSource

runtime = MCPRuntime(max_connections=100, max_in_flight_calls=100)

connection = runtime.bind(
    tenant_key=current_user.id,
    connection_key=github_connection.id,
    source=MCPSource.http("github", github_connection.server_url),
    credentials=credential_provider,
)

agent = Agent(
    provider=provider,
    prompt="Help with this repository.",
    tool_sources=[connection.tools(allowed_tools=["search_code", "create_issue"])],
)

try:
    result = await agent.run(user_message)
finally:
    await agent.close()  # Releases this Agent's lease.

# Once, during application shutdown:
await runtime.close()

Dendrux is the MCP client. The vendor, your platform, or a subprocess you configure hosts the MCP server. See the MCP architecture guide and multi-user example. To test a real hosted server, run the read-only GitHub example.

For OAuth-protected MCP servers, bind with oauth=MCPOAuth(...) instead of credentials=: Dendrux runs discovery, registration, PKCE sign-in, refresh coordinated across workers, scope step-up, and revocation, while your application keeps the encrypted token store, user identity, and the redirect. See the MCP OAuth web-app recipe and the end-to-end example.

Providers

Provider Import Use case
Anthropic from dendrux.llm.anthropic import AnthropicProvider Claude models
OpenAI from dendrux.llm.openai import OpenAIProvider GPT models + vLLM, SGLang, Groq, Ollama
OpenAI Responses from dendrux.llm.openai_responses import OpenAIResponsesProvider GPT + built-in tools (web search)
Mock from dendrux.llm.mock import MockLLM Deterministic testing

API Quick Reference

from dendrux.notifiers.console import ConsoleNotifier

async with Agent(
    provider=provider,                  # Required: LLM provider
    prompt="...",                        # Required: system prompt
    tools=[add],                         # Optional: tool functions
    database_url="sqlite+aiosqlite:///./dendrux.db",
) as agent:
    result = await agent.run(
        "What is 15 + 27?",
        notifier=ConsoleNotifier(),      # Optional: terminal output
        tenant_id="org-123",             # Optional: multi-tenant isolation
        metadata={"thread": "t1"},       # Optional: your linking data
    )

RunResult

result.answer          # str | None — the agent's final answer
result.status          # RunStatus — SUCCESS, ERROR, MAX_ITERATIONS, WAITING_CLIENT_TOOL, CANCELLED
result.steps           # list[AgentStep] — full reasoning chain
result.iteration_count # int — how many loop iterations ran
result.usage           # UsageStats — input_tokens, output_tokens, total_tokens
result.run_id          # str — unique run identifier (ULID)
result.error           # str | None — safe error message if status is ERROR
result.error_info      # ErrorInfo | None — category, retryable, safe_message of a provider or database failure
result.stop_reason     # StopReason | None — why the answer call stopped; result.truncated is True at max_tokens
result.pause_id        # str | None — id of the current pause; pass it as expected_pause_id= (required to approve)
result.pending         # PendingPause | None — what a paused run is waiting on
result.to_dict()       # versioned, allowlisted browser envelope (never meta, traces or PII mappings)

Tool Options

@tool()                                  # Basic server tool
@tool(target="client")                   # Client-side — agent pauses
@tool(max_calls_per_run=3)               # Limit calls per run
@tool(timeout_seconds=120)               # Custom timeout (default 120s)
@tool(parallel=False)                    # Run alone, not concurrently

Upgrading

See Upgrading to 0.6.0 for the migration order, storage-format activation and every changed default. See Upgrading to 0.5.0 for every change from 0.4.1 with an action for each, and a map from the removed read router to RunStore.

Full Documentation

See the full documentation on GitHub for provider setup, configuration, database guide, CLI, inspection tools you build, the notifier system, and examples.

Metadata

Release files for dendrux 0.7.0

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

Source distribution (sdist)

Source distribution for dendrux 0.7.0
File Size Uploaded Provenance Actions
dendrux-0.7.0.tar.gz 1.1 MB Without provenance Details for dendrux-0.7.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for dendrux 0.7.0
File Interpreter ABI Platform Actions
dendrux-0.7.0-py3-none-any.whl Python 3 none any Details for dendrux-0.7.0-py3-none-any.whl

Total release size: 2.3 MB

Release files / dendrux-0.7.0.tar.gz

Download URL dendrux-0.7.0.tar.gz
Size 1.1 MB
Tags Source
SHA-256 checksum
How to use checksums
e61eb30f5adaa6a09b664b63f9c667608bba76af1e7f8263f5bd5f7fe5fd4bea
BLAKE2b-256 checksum
How to use checksums
62b38b13f456982b8acb86e4583497496cf6e547adfd8fa4492709d08793d44d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.12

Release files / dendrux-0.7.0-py3-none-any.whl

Download URL dendrux-0.7.0-py3-none-any.whl
Size 1.2 MB
Tags Python 3
SHA-256 checksum
How to use checksums
19822cd02f246f3a46ee90f6c1e19ddea0f5ca04b945042c52d4c374c0a308bd
BLAKE2b-256 checksum
How to use checksums
ee1cc51a027518dbd59d12e1d913d05e944b7ba8d045351f8bfe61e65b187d88
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.12

Security for dendrux 0.7.0

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.7.0 This release

2 release files No provenance

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