Skip to main content

Context Router Python SDK

Python client for the Context Router MCP server.

Full Cursor + Python usage guide: USING.md.

Requirements

  • Python 3.10+
  • Node.js 20+ with a resolvable @context-router/mcp-server package, or a built server in this monorepo

Install

From the monorepo:

cd packages/sdk-python
pip install -e ".[dev]"

Ensure the MCP server is built:

cd ../..
npm run build

Quickstart

import asyncio
from context_router import ContextRouter


async def main():
    async with await ContextRouter.local() as router:
        flow = await router.start("Research")
        await flow.set("findings", {"answer": 42})
        handoff = await flow.handoff(keys=["findings"])
        print(handoff.summary)
        await flow.complete()


asyncio.run(main())

Use an isolated SQLite directory in tests:

async with await ContextRouter.local(data_dir="/tmp/my-router-data") as router:
    ...

API surface

The Python SDK mirrors the TypeScript SDK:

  • High-level: ContextRouter.local(), router.start(), router.status(), router.discover_tools()
  • WorkflowSession: set, get, get_many, checkpoint, handoff, complete, fail
  • Explicit namespaces: router.workspace, router.schema, router.workflow, router.state, router.checkpoint, router.handoff, router.step, router.agent_role

Examples

Tests

pytest

Integration tests skip automatically when Node.js or the MCP server entry is unavailable.

Server resolution

ContextRouter.local() resolves the server in this order:

  1. CONTEXT_ROUTER_MCP_ENTRY environment variable
  2. Installed npm package @context-router/mcp-server/entry
  3. Monorepo fallback at packages/server/dist/index.js

License

Apache-2.0

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ctxrouter-0.5.0.tar.gz (8.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ctxrouter-0.5.0-py3-none-any.whl (9.9 kB view details)

Uploaded Python 3

File details

Details for the file ctxrouter-0.5.0.tar.gz.

File metadata

  • Download URL: ctxrouter-0.5.0.tar.gz
  • Upload date:
  • Size: 8.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for ctxrouter-0.5.0.tar.gz
Algorithm Hash digest
SHA256 12b50f0dc1d84ccd0d1e7d70caa986231483bf24a94e47964004dcc45d2e4bbe
MD5 48998e7c06db95876cdc84714df0421c
BLAKE2b-256 af5d6c29bfffadcadaa34774e4bebc1fdaa66f4bb98c45b9991b2cd2fd6cbf67

See more details on using hashes here.

Provenance

The following attestation bundles were made for ctxrouter-0.5.0.tar.gz:

Publisher: release-python.yml on mindlever-strategy/context-router

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ctxrouter-0.5.0-py3-none-any.whl.

File metadata

  • Download URL: ctxrouter-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 9.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for ctxrouter-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 fc66ff8f7150528b8d29d90ef6a8a398ce8f62db2a8d9753f786df53f629f0d4
MD5 b81223cc6a08c04c3a453e6f36c8e3ed
BLAKE2b-256 cc2e63cccd460a86c0b539bfe7748cd8e09c66ff4ba1c6e4be5844a097615cd3

See more details on using hashes here.

Provenance

The following attestation bundles were made for ctxrouter-0.5.0-py3-none-any.whl:

Publisher: release-python.yml on mindlever-strategy/context-router

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

0.6.0

2 files

This release

0.5.0 This release

2 files

0.4.0

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page