Skip to main content
Glama

MCP FastAPI Server

by finianoneill

MCP FastAPI Server

A production-ready Model Context Protocol (MCP) server built with FastAPI.

Directory Structure

. ├── main.py # Entry point ├── requirements.txt # Dependencies ├── README.md # Documentation └── src/ ├── __init__.py ├── app.py # FastAPI application └── mcp_app/ ├── __init__.py ├── models.py # Pydantic models ├── server.py # MCP server logic └── tools.py # Tool registry & implementations

Installation

pip install -r requirements.txt

Usage

python main.py

Server runs on http://localhost:8000

Endpoints

  • GET / - Server information

  • GET /health - Health check

  • GET /tools - List available tools

  • WS /mcp - MCP WebSocket endpoint

  • POST /mcp/http - MCP HTTP endpoint

Built-in Tools

  1. calculate - Mathematical calculations

  2. get_time - Current time in timezone

  3. echo - Echo messages

API Documentation

Visit http://localhost:8000/docs for interactive API documentation.

-
security - not tested
A
license - permissive license
-
quality - not tested

local-only server

The server can only run on the client's local machine because it depends on local resources.

A production-ready Model Context Protocol server that provides mathematical calculations, time zone information, and message echoing capabilities through both WebSocket and HTTP endpoints. Built with FastAPI for robust API functionality and interactive documentation.

  1. Directory Structure
    1. Installation
      1. Usage
        1. Endpoints
          1. Built-in Tools
            1. API Documentation

              MCP directory API

              We provide all the information about MCP servers via our MCP API.

              curl -X GET 'https://glama.ai/api/mcp/v1/servers/finianoneill/mcp_fastapi_server_example'

              If you have feedback or need assistance with the MCP directory API, please join our Discord server