python sdk to mcp converter
converts any python sdk into an mcp server. discovers methods automatically, generates json schemas, exposes via mcp protocol.
tested on: kubernetes, github, azure, aws (boto3), stripe, requests, and standard python libraries.
quick start
pip install -r requirements.txt
cd demo_agent
cp .env.example .env
nano .env # add OPENAI_API_KEY
python app.pysee SETUP.md for detailed instructions and credential configuration.
how it works
discovery: uses python inspect to find methods from any module. handles simple modules (os, json), client sdks (github, kubernetes), and azure operation groups.
schemas: converts function signatures to json schemas. extracts types from annotations and descriptions from docstrings.
protocol: implements json-rpc 2.0 over stdio. supports tools/list (discovery) and tools/call (execution).
execution: validates inputs, injects auth, executes with retries and timeout, caches results, redacts secrets.
llm usage: optional openai api calls during startup to enhance schema descriptions. disabled by default. core functionality works without it.
run the server directly
export SDKS="os,requests,kubernetes"
python server.pyreads json-rpc from stdin, writes responses to stdout.
configuration
environment variables for server behavior:
SDKS="os,boto3" # which sdks to load
ALLOW_DANGEROUS=false # filter delete/remove operations
ENABLE_CACHE=true # cache results
MAX_RETRIES=3 # retry failed callssdk credentials in demo_agent/.env:
OPENAI_API_KEY=sk-... # required for demo ui
GITHUB_TOKEN=ghp_... # optional
AZURE_TENANT_ID=... # optional
AWS_ACCESS_KEY_ID=... # optionaltesting
cd core_sdk_to_mcp_tool
python test_core_functionality.pyfiles
server.py- mcp server main loopreflection.py- method discoveryschema_gen.py- json schema generationexecutor.py- execution with retry/cachemcp_protocol.py- json-rpc handlersauth.py- credential injectiondemo_agent/app.py- terminal ui demo
supported sdks
works with any python module. special handling for:
- client sdks: instantiates with credentials (github, kubernetes)
- azure: discovers operation groups (resource_groups, virtual_machines)
- factory patterns: boto3, stripe
limitations
- openai limits to 128 tools per agent
- requires type hints for accurate schemas
- authentication must be pre-configured
