Existing OpenAPI to an MCP Server Using FastMCP
In this brief tutorial, we’ll use FastMCP to transform an existing TODO application (which exposes an OpenAPI spec) into a MCP server and link it to CoPilot for organic task interactions. Step 1: The TODO App Your TODO app should already be running at: http://localhost:8000 And exposing its OpenAPI spec at: http://localhost:8000/openapi.json Step 2: Create the MCP Server Create a file todo_mcp_server.py: import httpx from fastmcp import FastMCP client = httpx.AsyncClient(base_url="http://localhost:8000") spec = httpx.get("http://localhost:8000/openapi.json").json() mcp = FastMCP.from_openapi(openapi_spec=spec, client=client) if __name__ == "__main__": mcp.run( transport="http", host="localhost", port=4200, path="/todo-mcp/http", log_level="debug", ) Run it: ...