karthikv2k_chat_mcp

karthikv2k_chat_mcp

by karthikv2k
A FastAPI-based async API server for interacting with Model Context Protocol (MCP) servers.

FastAPI MCP Server Integration

A FastAPI-based async API server designed to communicate with Model Context Protocol (MCP) servers. This project provides a seamless way to interact with MCP servers, list available tools, and invoke them programmatically.

Features

  • List Available MCP Servers: Retrieve a list of all accessible MCP servers.
  • List Tools: Discover tools available from a specific MCP server.
  • Invoke Tools: Execute tools on an MCP server with custom parameters.

API Endpoints

  • POST /api/list-mcp-servers: List all available MCP servers.
  • POST /api/list-tools: List tools available from a specified MCP server.
  • POST /api/invoke-tool: Invoke a tool on an MCP server with provided parameters.

Prerequisites

  • Python 3.8 or higher.
  • An accessible MCP server (local or remote).

Installation

  1. Clone the repository:
    shell git clone <repository-url> cd mcp-fastapi-server
  2. Create a virtual environment:
    shell python -m venv venv source venv/bin/activate # For Windows: venv\Scripts\activate
  3. Install dependencies:
    shell pip install -r requirements.txt
  4. Configure the .env file:
    shell cp .env.example .env
    Edit the .env file to set your MCP server URL and other configurations.

Running the Server

Start the server using:

uvicorn app.main:app --reload

The server will run on http://localhost:8000.

API Usage Examples

List MCP Servers

curl -X POST http://localhost:8000/api/list-mcp-servers -H "Content-Type: application/json" -d '{}'

List Tools from an MCP Server

curl -X POST http://localhost:8000/api/list-tools -H "Content-Type: application/json" -d '{"server_url": "http://localhost:5000"}'

Invoke a Tool

curl -X POST http://localhost:8000/api/invoke-tool -H "Content-Type: application/json" -d '{
  "server_url": "http://localhost:5000",
  "tool_name": "example_tool",
  "params": {
    "parameter1": "value1",
    "parameter2": "value2"
  }
}'

Documentation

Once the server is running, access the interactive API documentation:

  • Swagger UI: http://localhost:8000/docs
  • ReDoc: http://localhost:8000/redoc

License

This project is licensed under the MIT License.

Features & Capabilities

Categories
mcp_server model_context_protocol python fastapi docker api_integration async

Implementation Details

Stats

0 Views
4 GitHub Stars

Repository Info

karthikv2k Organization

Similar MCP Servers

continuedev_continue by continuedev
25049
21423
9300