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().

Author

Warith Harchaoui, <warith.harchaoui@deraison.ai>

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’s app stays independent of elbow_helper.api’s own module-level one.

Returns:

The mounted server descriptor (.name defaults to app.title).

Return type:

fastapi_mcp.FastApiMCP

Examples

>>> from elbow_helper.api import create_app
>>> mcp = build_server(create_app())
>>> mcp.name
'elbow-helper'
elbow_helper.mcp_server.main()[source]

Run the MCP-mounted app over HTTP (the python -m elbow_helper.mcp_server path).

Return type:

None