FastAPI MCP-Style Server

FastAPI MCP-Style Server

A minimal FastAPI implementation that mimics Model Context Protocol functionality with JSON-RPC 2.0 support. Provides basic tools like echo and text transformation through both REST and RPC endpoints for testing MCP-style interactions.

Category
Visit Server

README

FastAPI MCP-Style Server

Minimal FastAPI implementation that mimics a subset of Model Context Protocol (MCP) functionality.

Features

  • Echo-style POST /mcp endpoint returning structured response (id, status, outputs)
  • JSON-RPC 2.0 endpoint /mcp/rpc supporting:
    • mcp.list_tools
    • mcp.call_tool (tools: echo, uppercase, query_manse, calc_daewoon)
  • GET usage helper /mcp
  • Pydantic models for request/response
  • Basic logging
  • Tests (pytest) for REST + RPC

Quick Start

python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
uvicorn main:app --reload

REST Usage

curl -X POST http://127.0.0.1:8000/mcp \
  -H 'Content-Type: application/json' \
  -d '{"inputs": {"text": "hello"}}'

JSON-RPC Examples

List tools:

curl -X POST http://127.0.0.1:8000/mcp/rpc \
  -H 'Content-Type: application/json' \
  -d '{"jsonrpc":"2.0","id":1,"method":"mcp.list_tools"}'

Call echo:

curl -X POST http://127.0.0.1:8000/mcp/rpc \
  -H 'Content-Type: application/json' \
  -d '{"jsonrpc":"2.0","id":"abc","method":"mcp.call_tool","params":{"name":"echo","arguments":{"text":"hello"}}}'

Call query_manse (first 5 rows):

curl -X POST http://127.0.0.1:8000/mcp/rpc \
  -H 'Content-Type: application/json' \
  -d '{"jsonrpc":"2.0","id":2,"method":"mcp.call_tool","params":{"name":"query_manse","arguments":{"limit":5}}}'

Call calc_daewoon (example date):

curl -X POST http://127.0.0.1:8000/mcp/rpc \
  -H 'Content-Type: application/json' \
  -d '{"jsonrpc":"2.0","id":3,"method":"mcp.call_tool","params":{"name":"calc_daewoon","arguments":{"yyyymmdd":"20250115"}}}'

Response example:

{
  "jsonrpc": "2.0",
  "id": 3,
  "result": {
    "outputs": [
      {"type": "json", "content": {"asc_diff_days": 3, "desc_diff_days": 2}}
    ]
  }
}

Meaning:

  • asc_diff_days: 기준일 이후 다음 절기까지 (일수 / 3 반올림)
  • desc_diff_days: 기준일 이전 직전 절기까지 (일수 / 3 반올림)
  • 없으면 null

Environment Variables (DB)

Variable Default Description
MCP_DB_HOST 192.168.31.136 MariaDB host
MCP_DB_PORT 3306 MariaDB port
MCP_DB_USER DB user
MCP_DB_PASSWORD DB password
MCP_DB_NAME manse Database name

Example run with overrides:

MCP_DB_HOST=127.0.0.1 MCP_DB_USER=app MCP_DB_PASSWORD=secret uvicorn main:app --reload

Run Tests

pytest -q

Next Ideas

  • Streaming (SSE) outputs
  • Prompts/resources primitives
  • Auth layer (OAuth / API key)
  • Tool change events

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured