TMF MCP Builder
Workflow (decision tree)
- •
Choose the product shape
- •Wrap a real TMF API: Implement only the MCP server + HTTP client; no mock server.
- •Generate a full dev sandbox: Mock server (FastAPI) + HTTP client + MCP server that proxies to the mock.
- •
Choose the MCP framework (Python)
- •Use the official
mcpPython SDK +FastMCP(recommended): implement tools directly with@mcp.tooland choose the transport (stdio or HTTP) based on your deployment needs.
- •Use the official
- •
Choose the implementation approach
- •Hand-build: Use this skill as a checklist and build the server normally.
- •LLM-assisted generation (this repo): Use
tmf_llm_agent.pyto generate a starter implementation from an OpenAPI YAML, then tighten tool schemas and edge cases.
Conventions (TMF-specific)
Naming
- •Files (recommended for generated outputs)
- •
tmf###_mock_server.py - •
tmf###_client.py - •
tmf###_mcp_server.py - •
run_mock_server.py,run_mcp_server.py
- •
- •Tools
- •Use snake_case with TMF prefix:
tmf{tmf_number}_{action}_{resource} - •Standard actions:
list,get,create,patch(orupdate),delete, plushealth_check
- •Use snake_case with TMF prefix:
Input ergonomics: create/update tools
For TMF create operations, prefer field-level parameters (LLM-friendly) and rebuild the TMF JSON internally.
- •Read
references/resource-creation-guidelines.mdbefore implementingcreate_*tools. - •Avoid a single blob parameter like
customer: dictunless you also provide ergonomic field inputs.
OpenAPI-driven behavior
When generating mock behavior from TMF OpenAPI:
- •Treat
$refresolution as mandatory for realistic sample payloads. - •Treat
allOfas mandatory (TMF uses it heavily). Merge allOf schemas (including cases wheretype: objectandallOfboth exist). - •Identify main resources from the path set (e.g.,
/customer,/product,/service) and implement full CRUD for those first.
/hub and event endpoints
- •Implement
/hubendpoints only if required by the spec or your use case. - •If you implement them, keep them consistent: create/get/delete subscription, and store subscriptions in-memory for mocks.
Practical build steps (Python)
- •
Inventory the spec
- •Find the correct TMF OpenAPI YAML in https://github.com/tmforum-apis (users must pick the TMFxxx spec/version that matches their API).
- •Determine base paths, main resources, and required operations.
- •Extract required fields for create/patch input models.
- •
Ensure tmf_commons is available
- •Copy
assets/tmf_commonsinto your project root (or otherwise ensure it is importable). You can usescripts/copy_tmf_commons.py --dest <project-root>.
- •Copy
- •
Implement the HTTP client
- •Use
httpx.AsyncClient. - •Provide consistent error handling and timeouts.
- •Use
- •
Implement the mock server (optional)
- •Use in-memory storage keyed by resource.
- •Pre-populate sample objects.
- •Support: list (filter/paginate), get by id, create, patch, delete.
- •
Implement the MCP server
- •Expose tools for the main resources.
- •Make list tools pageable (
limit,offsetor cursor). - •Return predictable structured JSON (and optionally a markdown view if your framework supports it).
- •
Validate tool usability
- •Tool names are discoverable.
- •Create/update inputs are not "blob-only".
- •Errors are actionable.
- •
Add an evaluation set (recommended)
- •Create 10 read-only questions that require multiple tool calls.
- •If you need a template, follow the approach in the general mcp-builder evaluation guidance.
- •
Generate README-TMFxxxx (required)
- •Create a
README-TMF####.mdfile as the final step (after servers and tools are implemented). - •Use the TMF number from the OpenAPI spec (for TMF620, generate
README-TMF620.md). - •Include: overview, endpoints/tools list, run instructions (mock server + MCP server), and environment variables.
- •Create a
- •
Add requirements.txt (required)
- •Create a
requirements.txtin the output folder that lists runtime dependencies. - •Include at least:
fastapi,uvicorn,httpx,mcp,pyyaml.
- •Create a
Bundled assets
- •tmf_commons: copy ssets/tmf_commons into your project root when you want the shared mock server utilities (or run scripts/copy_tmf_commons.py --dest <project-root>).
References (load as needed)
- •
Bundled assets: ssets/tmf_commons (copy into your project root if you need the shared mock server utilities).
- •
All-in-one generator prompt:
references/TMF_MCP_SERVER_CREATION_PROMPT_all-in-one.md - •
Libraries-based generator prompt:
references/TMF_MCP_SERVER_CREATION_PROMPT_libraries.md - •
Create/update input rule (important):
references/resource-creation-guidelines.md