elbow_helper.mcp_server module
MCP server — the agent-tool door (optional [mcp] extra), via fastapi-mcp.
The fourth of elbow-helper’s surfaces lets an AI agent call the pipeline as
Model-Context-Protocol tools by mounting fastapi-mcp on a copy of
elbow_helper.api’s FastAPI app: the four REST operations already
tagged with an explicit operation_id there (knee/elbow/
diagnostics/locator) become the four MCP tools here, automatically,
with the same request/response schema. Rename or extend a route in
api.py and this door follows without a second edit — MCP must never be
a standalone, hand-written tool server that could drift from the REST API.
MCP is served over Streamable HTTP (mounted at /mcp on a running
app), not stdio — an HTTP-based MCP client pointed at the running server’s
/mcp endpoint is what fastapi-mcp offers. The same four tools are
also just REST endpoints an agent (or a human with curl) can hit directly.
Run it with:
pip install 'elbow-helper[mcp]'
uvicorn elbow_helper.mcp_server:app --port 8021 # or: python -m elbow_helper.mcp_server
MCP endpoint: http://127.0.0.1:8021/mcp. Runs on a different port from
elbow_helper.api’s 8020 by default so both doors can run side by side.
Consumes: fastapi-mcp (optional, pulls in fastapi/mcp),
elbow_helper.api.
Produces: app (the ASGI application), build_server().
- elbow_helper.mcp_server.build_server(app)[source]
Mount the MCP server (knee/elbow/diagnostics/locator tools) onto
app.- Parameters:
app (fastapi.FastAPI) – The app to mount onto — typically a fresh
elbow_helper.api.create_app()instance, so this module’sappstays independent ofelbow_helper.api’s own module-level one.- Returns:
The mounted server descriptor (
.namedefaults toapp.title).- Return type:
fastapi_mcp.FastApiMCP
Examples
>>> from elbow_helper.api import create_app >>> mcp = build_server(create_app()) >>> mcp.name 'elbow-helper'