Kurd
A high-performance Model Context Protocol (MCP) gateway for Python, powered by Rust.
Kurd combines a Python-first developer API with a Rust data plane for MCP routing, upstream aggregation, concurrency control, security, caching, and observability.
Status
Kurd is in beta and is being hardened for production use.
Current release line: 0.3.x
The gateway targets the MCP 2026-07-28 protocol revision while preserving compatibility paths used by existing Kurd applications.
Highlights
- Python-first
RouterAPI - Rust core using Tokio, Axum, Serde, and Reqwest
- MCP
server/discover,tools/list, andtools/call - Local Python tools and mounted upstream MCP servers
- Sync and async Python callbacks
- Concurrent upstream discovery
- Shared HTTP connection pool
- Retry with exponential backoff and jitter
- Circuit breaker
- Tool-list caching with TTL and cache scope
- Graceful HTTP lifecycle: start, stop, status, restart
- Optional bearer authentication
- Request-size and content-type validation
- Upstream URL validation and private-network policy
- Configurable upstream timeout
- Global, per-upstream, and Python callback backpressure
- Request IDs and structured request logging
- Runtime, cache, and upstream metrics
- Cross-platform CI and automated PyPI release workflow
Installation
pip install kurd
Python 3.10 or newer is required.
Quick Start
from kurd import Router
router = Router()
@router.tool()
async def add(a: int, b: int) -> int:
return a + b
Start the HTTP gateway:
from kurd._kurd import start_http_gateway
start_http_gateway("127.0.0.1:9200")
The MCP endpoint is:
http://127.0.0.1:9200/mcp
Health and operational status are exposed at:
GET /health
GET /status
GET /metrics
The /metrics endpoint exports Prometheus-format metrics for integration with monitoring systems (Datadog, Prometheus, New Relic, etc.).
Mount an Upstream MCP Server
from kurd import Router
router = Router()
router.mount("github", "http://127.0.0.1:9300")
An upstream tool named create_issue is exposed through Kurd as:
github.create_issue
Unmount or refresh the aggregated tool cache:
router.unmount("github")
router.refresh_tools()
Runtime Hardening
Kurd provides explicit concurrency controls:
router.configure_runtime(
global_concurrency=512,
upstream_concurrency=64,
python_concurrency=64,
request_logging=False,
)
Inspect runtime state:
print(router.runtime_status())
The HTTP /status endpoint also reports runtime, cache, security, upstream latency, retry, and circuit-breaker metrics.
Security
Kurd currently provides a production security baseline:
- maximum MCP request body size
- JSON content-type validation
- optional bearer-token authentication
- upstream URL validation
- configurable private/loopback upstream policy
- configurable upstream request timeout
- sanitized upstream transport errors
- overload rejection through explicit backpressure
For deployments exposed beyond localhost, use TLS at the reverse proxy or ingress layer and apply your normal network-level authentication and authorization controls.
Observability & Monitoring
Prometheus Metrics Export
Kurd exports metrics in Prometheus format at the /metrics endpoint:
curl http://127.0.0.1:9200/metrics
Available metrics:
kurd_requests_total- Total HTTP requests (total, completed, rejected)kurd_requests_active- Currently active requestskurd_requests_peak_active- Peak concurrent requestskurd_request_latency_ms- Average request latencykurd_python_active_calls- Active Python tool callskurd_python_rejections_total- Python tool call rejectionskurd_upstream_requests_total- Requests to upstream servers (per upstream)kurd_upstream_successes_total- Successful upstream callskurd_upstream_failures_total- Failed upstream callskurd_upstream_retries_total- Upstream call retrieskurd_upstream_latency_ms- Average upstream latencykurd_upstream_circuit_breaker_state- Circuit breaker state (0=closed, 1=open)kurd_cache_hits_total- Tool discovery cache hitskurd_cache_misses_total- Tool discovery cache misseskurd_cache_invalidations_total- Cache invalidationskurd_concurrency_limit- Configured concurrency limits
Integration example (Prometheus):
# prometheus.yml
scrape_configs:
- job_name: 'kurd'
static_configs:
- targets: ['127.0.0.1:9200']
metrics_path: '/metrics'
Integration example (Datadog):
# datadog.yaml
openmetrics_endpoint: http://127.0.0.1:9200/metrics
MCP 2026-07-28
Kurd implements the stateless 2026 MCP model used for routable gateway traffic:
- per-request protocol metadata
MCP-Protocol-VersionMcp-MethodMcp-Namefor tool callsserver/discover- deterministic
tools/list resultTypettlMscacheScope- server identity metadata
Kurd rejects mismatched modern MCP headers and unsupported protocol versions.
Performance
The repository includes end-to-end HTTP load tests in tests/test_load.py.
Example measurements from a Windows development machine:
| Scenario | Concurrency | Throughput | p50 | p95 | p99 | Errors |
|---|---|---|---|---|---|---|
| Local Python tool | 10 | 594.5 req/s | 14.94 ms | 23.88 ms | 28.66 ms | 0% |
| Local Python tool | 50 | 587.9 req/s | 33.29 ms | 87.83 ms | 119.09 ms | 0% |
| Local Python tool | 100 | 556.0 req/s | 18.27 ms | 29.52 ms | 32.43 ms | 0% |
| Upstream tool | 10 | 412.2 req/s | 21.77 ms | 36.35 ms | 42.74 ms | 0% |
| Upstream tool | 50 | 229.8 req/s | 20.61 ms | 534.61 ms | 549.25 ms | 0% |
| Upstream tool | 100 | 293.6 req/s | 30.12 ms | 531.40 ms | 535.34 ms | 0% |
| Local sustained burst | 100 | 573.3 req/s | 73.51 ms | 179.13 ms | 218.49 ms | 0% |
These are local measurements, not universal performance guarantees. Hardware, operating system, Python version, payload shape, upstream implementation, and network conditions affect results.
Run the benchmark suite with:
python -m pytest tests/test_load.py -q -s
Development
Create and activate a virtual environment, then install the development tools:
python -m pip install --upgrade pip
python -m pip install maturin pytest
Build the native extension:
maturin develop --release
Run the full test suite:
python -m pytest -q
Build release artifacts:
maturin build --release
Architecture
Python application
|
v
Kurd Router
|
v
PyO3 boundary
|
v
Rust MCP gateway
| |
| +--> Local Python tools
|
+-------------> Upstream MCP servers
Rust owns the HTTP server, MCP validation, routing, caching, retries, circuit breaking, backpressure, and operational metrics. Python provides the developer-facing registration and configuration API.
Testing
The current suite covers:
- JSON-RPC parsing and dispatch
- local sync and async tools
- upstream discovery and calls
- concurrent upstream discovery
- cache behavior and invalidation
- mount and unmount
- MCP 2026 request headers and protocol-version checks
- HTTP lifecycle and graceful shutdown
- request-size and content-type security
- bearer authentication
- upstream URL policy
- timeout configuration
- error sanitization
- global and Python callback backpressure
- request ID propagation
- runtime observability
- load and burst behavior
Compatibility
CI targets Windows, Linux, and macOS. Release wheels are built through Maturin.
The project is primarily developed with Python 3.12 and stable Rust; package metadata supports Python 3.10+.
Release Policy
Kurd uses semantic versioning while the public API stabilizes.
- patch releases: bug fixes and packaging corrections
- minor releases: new gateway or MCP capabilities
1.0.0: stable public API commitment
Project Structure
kurd/
├── kurd/
│ ├── __init__.py
│ └── router.py
├── src/
│ └── lib.rs
├── tests/
│ ├── test_upstream.py
│ ├── test_load.py
│ └── upstream_server.py
├── Cargo.toml
├── pyproject.toml
├── README.md
└── LICENSE
Contributing
Issues and technical discussions are welcome through the GitHub issue tracker.
Before submitting a change:
cargo check
maturin develop --release
python -m pytest -q
License
MIT.
Name
The name Kurd honors Kurdish identity and heritage.
Bezhi Kurd u Kurdistan.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
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 kurd-0.4.0.tar.gz.
File metadata
- Download URL: kurd-0.4.0.tar.gz
- Upload date:
- Size: 102.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4007657a1f3287f917ce537cc55a18b613661e0eb06aa4020f5d2b85758b4634
|
|
| MD5 |
4edd90826bf80ef69a712c586d4f3e85
|
|
| BLAKE2b-256 |
081e5a036e678cde640b0ea2ed73c1433f1f91a8218963418892f931e4a1a5dc
|
Provenance
The following attestation bundles were made for kurd-0.4.0.tar.gz:
Publisher:
release.yml on sn391/kurd
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
kurd-0.4.0.tar.gz -
Subject digest:
4007657a1f3287f917ce537cc55a18b613661e0eb06aa4020f5d2b85758b4634 - Sigstore transparency entry: 2556151697
- Sigstore integration time:
-
Permalink:
sn391/kurd@a0fa50c53ed5f192ce3c50b6ff1e271e8e4e6a91 -
Branch / Tag:
refs/tags/v0.4.0 - Owner: https://github.com/sn391
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@a0fa50c53ed5f192ce3c50b6ff1e271e8e4e6a91 -
Trigger Event:
push
-
Statement type:
File details
Details for the file kurd-0.4.0-cp312-cp312-win_amd64.whl.
File metadata
- Download URL: kurd-0.4.0-cp312-cp312-win_amd64.whl
- Upload date:
- Size: 2.1 MB
- Tags: CPython 3.12, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7033e41f801ec27f819362b0234b079fbe21b00ec807ffe6695a4f3e631b2572
|
|
| MD5 |
36be2b8c40b011b2eb948aa985472b33
|
|
| BLAKE2b-256 |
6b6ec0aaa16e954ac3886fb6ea76e10846cf76e1a668a3d8868d5d5afc56282b
|
Provenance
The following attestation bundles were made for kurd-0.4.0-cp312-cp312-win_amd64.whl:
Publisher:
release.yml on sn391/kurd
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
kurd-0.4.0-cp312-cp312-win_amd64.whl -
Subject digest:
7033e41f801ec27f819362b0234b079fbe21b00ec807ffe6695a4f3e631b2572 - Sigstore transparency entry: 2556151756
- Sigstore integration time:
-
Permalink:
sn391/kurd@a0fa50c53ed5f192ce3c50b6ff1e271e8e4e6a91 -
Branch / Tag:
refs/tags/v0.4.0 - Owner: https://github.com/sn391
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@a0fa50c53ed5f192ce3c50b6ff1e271e8e4e6a91 -
Trigger Event:
push
-
Statement type:
File details
Details for the file kurd-0.4.0-cp312-cp312-manylinux_2_28_x86_64.whl.
File metadata
- Download URL: kurd-0.4.0-cp312-cp312-manylinux_2_28_x86_64.whl
- Upload date:
- Size: 2.5 MB
- Tags: CPython 3.12, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
09d7269988927af359843d3f38d7042a26292c01e1f33eedf326f16082c62648
|
|
| MD5 |
721a2ca0d0ad1eeaca66d44492a641c7
|
|
| BLAKE2b-256 |
26e1ded3f5491c3c4bb72493aa31794a030e1fd6f3f21b9114f6b70d373b09a1
|
Provenance
The following attestation bundles were made for kurd-0.4.0-cp312-cp312-manylinux_2_28_x86_64.whl:
Publisher:
release.yml on sn391/kurd
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
kurd-0.4.0-cp312-cp312-manylinux_2_28_x86_64.whl -
Subject digest:
09d7269988927af359843d3f38d7042a26292c01e1f33eedf326f16082c62648 - Sigstore transparency entry: 2556151865
- Sigstore integration time:
-
Permalink:
sn391/kurd@a0fa50c53ed5f192ce3c50b6ff1e271e8e4e6a91 -
Branch / Tag:
refs/tags/v0.4.0 - Owner: https://github.com/sn391
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@a0fa50c53ed5f192ce3c50b6ff1e271e8e4e6a91 -
Trigger Event:
push
-
Statement type:
File details
Details for the file kurd-0.4.0-cp312-cp312-macosx_11_0_arm64.whl.
File metadata
- Download URL: kurd-0.4.0-cp312-cp312-macosx_11_0_arm64.whl
- Upload date:
- Size: 2.2 MB
- Tags: CPython 3.12, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
81656279441c5ffa9eafcf79e5682007d58c1c415680186c7a32950f5d019f66
|
|
| MD5 |
b9bd977ed782127e7a655574a0bbf69f
|
|
| BLAKE2b-256 |
9a0c81c2246efb1a0aeb733ce30d25310645334a5aa729224378ce77efef5605
|
Provenance
The following attestation bundles were made for kurd-0.4.0-cp312-cp312-macosx_11_0_arm64.whl:
Publisher:
release.yml on sn391/kurd
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
kurd-0.4.0-cp312-cp312-macosx_11_0_arm64.whl -
Subject digest:
81656279441c5ffa9eafcf79e5682007d58c1c415680186c7a32950f5d019f66 - Sigstore transparency entry: 2556151802
- Sigstore integration time:
-
Permalink:
sn391/kurd@a0fa50c53ed5f192ce3c50b6ff1e271e8e4e6a91 -
Branch / Tag:
refs/tags/v0.4.0 - Owner: https://github.com/sn391
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@a0fa50c53ed5f192ce3c50b6ff1e271e8e4e6a91 -
Trigger Event:
push
-
Statement type: