Context Router Python SDK
Python client for the Context Router MCP server.
Requirements
- Python 3.10+
- Node.js 20+ with a resolvable
@context-router/mcp-serverpackage, 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:
CONTEXT_ROUTER_MCP_ENTRYenvironment variable- Installed npm package
@context-router/mcp-server/entry - 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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ctxrouter-0.4.0.tar.gz.
File metadata
- Download URL: ctxrouter-0.4.0.tar.gz
- Upload date:
- Size: 8.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
663b95f8d4f02fa92dfaef1cc1f7c5995c1f36b93ed7f4a1b1dd84bf1e2f8efc
|
|
| MD5 |
cdf4e101cb2f151b4dfd6f6429d2b841
|
|
| BLAKE2b-256 |
68c017ee0ee3f68c97c5f546801be1351dba4c8e4fc76d4be49a4912507b6e10
|
Provenance
The following attestation bundles were made for ctxrouter-0.4.0.tar.gz:
Publisher:
release-python.yml on mindlever-strategy/context-router
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ctxrouter-0.4.0.tar.gz -
Subject digest:
663b95f8d4f02fa92dfaef1cc1f7c5995c1f36b93ed7f4a1b1dd84bf1e2f8efc - Sigstore transparency entry: 2212506140
- Sigstore integration time:
-
Permalink:
mindlever-strategy/context-router@2d923fcc04cbb7c0e42b5aa766617a80709e45cc -
Branch / Tag:
refs/heads/main - Owner: https://github.com/mindlever-strategy
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-python.yml@2d923fcc04cbb7c0e42b5aa766617a80709e45cc -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file ctxrouter-0.4.0-py3-none-any.whl.
File metadata
- Download URL: ctxrouter-0.4.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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1f81b807c53cd8c0bd97c75ce548117ded2f009751807eee9ab38f6bbbfc2063
|
|
| MD5 |
4c57011237597eb410ef6e70bf2f2862
|
|
| BLAKE2b-256 |
2afadd6e37327e9ac9647d93eb48cb700b4f578a34e05bfca4370a4c383ae554
|
Provenance
The following attestation bundles were made for ctxrouter-0.4.0-py3-none-any.whl:
Publisher:
release-python.yml on mindlever-strategy/context-router
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ctxrouter-0.4.0-py3-none-any.whl -
Subject digest:
1f81b807c53cd8c0bd97c75ce548117ded2f009751807eee9ab38f6bbbfc2063 - Sigstore transparency entry: 2212506162
- Sigstore integration time:
-
Permalink:
mindlever-strategy/context-router@2d923fcc04cbb7c0e42b5aa766617a80709e45cc -
Branch / Tag:
refs/heads/main - Owner: https://github.com/mindlever-strategy
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-python.yml@2d923fcc04cbb7c0e42b5aa766617a80709e45cc -
Trigger Event:
workflow_dispatch
-
Statement type: