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-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
Metadata
Release files for ctxrouter 0.6.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| ctxrouter-0.6.0.tar.gz | 8.6 kB | With provenance | Details for ctxrouter-0.6.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| ctxrouter-0.6.0-py3-none-any.whl | Python 3 | none | any | Details for ctxrouter-0.6.0-py3-none-any.whl |
Total release size: 18.5 kB
Release files / ctxrouter-0.6.0.tar.gz
| Download URL | ctxrouter-0.6.0.tar.gz |
|---|---|
| Size | 8.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
09ffd297662b6fabfa2a22251516729ef7580fe5cab2d2a39c5e70021b13d988
|
|
BLAKE2b-256 checksum How to use checksums |
c0a144376fd6e0dc4a94970692e3db590f227e8daa06da733b32e45c260efd1d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.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 Jul 27, 2026.
Transparency logRelease files / ctxrouter-0.6.0-py3-none-any.whl
| Download URL | ctxrouter-0.6.0-py3-none-any.whl |
|---|---|
| Size | 9.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3978795da938a1cd43abc830a076f409a3cff9b2fd73e55fb63a19e338be2e07
|
|
BLAKE2b-256 checksum How to use checksums |
559cc069aed89e5665138b4bcb2a61bc88e6bee290823c731cac37f992d4dd27
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.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 Jul 27, 2026.
Transparency logSecurity for ctxrouter 0.6.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.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for ctxrouter-0.6.0.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 Jul 27, 2026.
Transparency logA 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.