Skip to main content

mcp-worker-sdk

Worker Protocol Python runtime reference implementation — a universal MCP tool runtime SDK.

Write plain Python functions with the @worker.tool decorator and automatically get standard endpoints, schema generation, parameter validation, standardized errors, lifecycle hooks, and built-in database drivers.

mcp-worker-sdk is the Python runtime binding of the language-agnostic Worker Protocol. It is Hub-agnostic: omit hub_url to run it standalone as a standard HTTP tool service that any aggregator (Hub / MCP gateway) can consume.


Install

pip install mcp-worker-sdk

With all built-in database drivers:

pip install "mcp-worker-sdk[db]"

Quick start

from mcp_worker_sdk import Worker
from mcp_worker_sdk.adapters import DBAdapter

worker = Worker(
    name="notes",
    adapter=DBAdapter("sqlite", ":memory:"),
    # hub_url="https://hub.example.com",   # optional; omit to run standalone
)


@worker.tool(
    id="notes_greet",
    title="Greet",
    description="Return a greeting for a name",
)
def greet(name: str = "World"):
    """Return a greeting.

    :param name: who to greet
    """
    return {"message": f"Hello, {name}!"}


if __name__ == "__main__":
    worker.run(port=9100)

Then:

curl http://localhost:9100/health
curl http://localhost:9100/tools
curl -X POST http://localhost:9100/execute \
  -H "Content-Type: application/json" \
  -d '{"tool_id":"notes_greet","params":{"name":"Mavis"}}'

Adapters

Adapter Purpose
ShellAdapter Command-line / sandbox / code execution
DBAdapter Relational / vector / graph / KV / document databases (7 built-in drivers)
MacAdapter macOS GUI / AppleScript / screenshots / mouse & keyboard
HTTPAdapter Cloud API forwarding (auth, signing hooks, pagination, JSONPath)
MCPClientAdapter Wrap a third-party MCP server
CustomAdapter Fully custom execution

DBAdapter built-in drivers

postgresql (psycopg), mysql (pymysql), sqlite (sqlite3), qdrant (qdrant-client), neo4j (neo4j), redis (redis), mongodb (pymongo).


Runtime observability

GET /health returns a rich three-tier payload — live status, queue backpressure, and performance profiling — instead of a bare alive flag:

{
  "status": "busy",
  "degraded_reason": "none",
  "active_tasks": 2,
  "queue_length": 5,
  "max_concurrency": 10,
  "max_queue_length": 20,
  "avg_task_duration_ms": 150,
  "p95_duration_ms": 420,
  "estimated_wait_ms": 250,
  "success_rate": 0.998,
  "cpu_percent": 40.0,
  "memory_percent": 61.2,
  "uptime_seconds": 3600,
  "version": "1.1.0",
  "custom": {}
}
  • Real bounded concurrency (max_concurrency) and queue backpressure (max_queue_length): when the queue is full, /execute replies 429 RATE_LIMITED + Retry-After.
  • worker.health_metrics() returns a protocol mcp_worker_protocol.HealthMetrics object (5 base + 6 rich fields) for zero-transformation heartbeat aggregation.

CLI scaffold

mcp-worker create my-worker              # default HTTPAdapter
mcp-worker create my-worker --adapter db

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

mcp_worker_sdk-1.1.0.tar.gz (7.9 MB view details)

Uploaded Source

Built Distribution

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

mcp_worker_sdk-1.1.0-py3-none-any.whl (26.4 kB view details)

Uploaded Python 3

File details

Details for the file mcp_worker_sdk-1.1.0.tar.gz.

File metadata

  • Download URL: mcp_worker_sdk-1.1.0.tar.gz
  • Upload date:
  • Size: 7.9 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.14.6

File hashes

Hashes for mcp_worker_sdk-1.1.0.tar.gz
Algorithm Hash digest
SHA256 1c5875807027f74fe61ec73e597b1858c44ecdf44f7715822f3269ba9c5e05b7
MD5 e4b35bf55c17b9dc4a2e8313fe11e2c8
BLAKE2b-256 c0f8a5a7560e26b44ac1341bfdc67d9ec3e075be2b7c68790830abe6bf6c7d1c

See more details on using hashes here.

File details

Details for the file mcp_worker_sdk-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: mcp_worker_sdk-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 26.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.14.6

File hashes

Hashes for mcp_worker_sdk-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 bc85cf5085a30771e9e72ed31396858a96f029b9ed14982bb6d6ccab1721be67
MD5 b7e4d714ee639d54aa46c1e5b9290676
BLAKE2b-256 bb46e4461594bae220f466e6610a12b22adb1ef8b1f547be4af78c661fc046c5

See more details on using hashes here.

Release history Release notifications | RSS feed

1.2.0

2 files

This release

1.1.0 This release

2 files

1.0.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