MCP FastAPI Server logo

MCP FastAPI Server

by karthikv2k

A FastAPI-based async API server that communicates with Model Context Protocol (MCP) servers. It provides endpoints to list available MCP servers and tools, and to invoke tools on these servers.

View on GitHub

Last updated: N/A

What is MCP FastAPI Server?

This is a FastAPI server that acts as an intermediary to interact with Model Context Protocol (MCP) servers. It provides a RESTful API to discover and invoke tools available on MCP servers.

How to use MCP FastAPI Server?

  1. Clone the repository. 2. Create and activate a virtual environment. 3. Install dependencies using pip install -r requirements.txt. 4. Configure the .env file with your MCP server URL. 5. Start the server using uvicorn app.main:app --reload. Then, use the API endpoints documented in Swagger UI or ReDoc to manage and invoke tools.

Key features of MCP FastAPI Server

  • List available MCP servers

  • List tools available from MCP servers

  • Invoke tools on MCP servers

Use cases of MCP FastAPI Server

  • Orchestrating interaction with multiple MCP servers

  • Building user interfaces to manage and invoke tools

  • Automating tool execution workflows

  • Integrating MCP tools into larger systems

FAQ from MCP FastAPI Server

What is an MCP server?

An MCP server is a Model Context Protocol server, which likely provides a set of tools or models that can be accessed remotely.

Where can I find documentation for API endpoints?

Once the server is running, you can access interactive API documentation at http://localhost:8000/docs (Swagger UI) or http://localhost:8000/redoc (ReDoc).

What is the purpose of the .env file?

The .env file is used to configure the server, specifically the URL of your MCP server and other settings.

How do I specify parameters when invoking a tool?

When invoking a tool via the /api/invoke-tool endpoint, you should provide a JSON payload that includes the 'server_url', 'tool_name', and a 'params' object containing the necessary parameters for the tool.

What if I encounter an error while interacting with the server?

Check the server logs for detailed error messages. Verify that your MCP server is accessible and that your request parameters are correct.