MCP Builder
The MCP builder is the final synthesis step. It takes parsed imports, helpers, tool functions, and conflict metadata and writes a unified MCP server.
Output
mcp_unified_server.py
Responsibilities
- write the MCP header and runtime footer
- include safe imports
- include utility functions, classes, and globals
- include extracted
@toolfunctions - emit comment blocks for env requirements, skipped repos, and build conflicts
Generated runtime shape
The builder creates a FastMCP server using streamable-http transport. The --host and --port values passed at build time are baked into the output file:
if __name__ == "__main__":
mcp.run(transport='streamable-http', host='0.0.0.0', port=8000)
To use a different port, pass --port at build time:
toolstorepy build --queries queries.json --index core-tools --port 9090
This generates:
if __name__ == "__main__":
mcp.run(transport='streamable-http', host='0.0.0.0', port=9090)
Conflict handling
The builder surfaces parser decisions such as:
- duplicate tool renames
- helper collisions
- dropped relative imports
- repos that contributed no tools
- tools that may fail because required helper symbols were removed
This makes the generated server auditable instead of silently rewriting code behind the scenes.