MCPServerDemo

MCPServerDemo

A demonstration server that implements JSON-RPC 2.0 methods for basic arithmetic using FastAPI. It provides integration examples for the Model Context Protocol (MCP) using FastMCP to connect with Claude Desktop.

Category
Visit Server

README

JSON RPC Server with FastAPI and Python

This project implements a simple JSON-RPC server using FastAPI, Uvicorn, and jsonrpcserver in Python. It exposes add and multiply methods.

Setup

  1. Clone the repository:

    git clone <your-repo-url>
    cd json-rpc-server
    
  2. Create a virtual environment and install dependencies using uv:

    uv venv
    .\.venv\Scripts\activate # On Windows
    # source .venv/bin/activate # On Linux/macOS
    uv pip install fastapi uvicorn jsonrpcserver
    

Running the Server

To start the development server with auto-reloading:

.\.venv\Scripts\activate # On Windows
# source .venv/bin/activate # On Linux/macOS
uv run python -m uvicorn main:app --reload

The server will run at http://127.0.0.1:8000/.

API Endpoints

GET /

A simple test endpoint to confirm the server is running.

Request:

# Using curl (Linux/macOS/Git Bash)
curl http://127.0.0.1:8000/

# Using Invoke-RestMethod (PowerShell)
Invoke-RestMethod -Uri "http://127.0.0.1:8000/" -Method Get

Response:

{
  "message": "FastAPI is running!"
}

POST / (JSON-RPC 2.0)

This is the main JSON-RPC endpoint for add and multiply methods.

Add Method

Request:

# Using curl
curl -X POST -H "Content-Type: application/json" -d '{"jsonrpc": "2.0", "method": "add", "params": [2, 3], "id": 1}' http://127.0.0.1:8000/

# Using Invoke-RestMethod (PowerShell)
Invoke-RestMethod -Uri "http://127.0.0.1:8000/"   -Method Post -Headers @{ "Content-Type" = "application/json" }   -Body '{"jsonrpc":"2.0","method":"add","params":[2,3],"id":1}'

Response (Example):

{"jsonrpc": "2.0", "result": 5, "id": 1}

Multiply Method

Request:

# Using curl
curl -X POST -H "Content-Type: application/json" -d '{"jsonrpc": "2.0", "method": "multiply", "params": [4, 5], "id": 1}' http://127.0.0.1:8000/

# Using Invoke-RestMethod (PowerShell)
Invoke-RestMethod -Uri "http://127.0.0.1:8000/"  -Method Post -Headers @{ "Content-Type" = "application/json" }  -Body '{"jsonrpc":"2.0","method":"multiply","params":[4,5],"id":1}'

Response (Example):

{"jsonrpc": "2.0", "result": 20, "id": 1}

Multipl Methods in a sigal call

curl -X POST -H "Content-Type: application/json" -d '[{"jsonrpc": "2.0", "method": "add", "params": [2, 3], "id": 1},{"jsonrpc": "2.0", "method": "multiply", "params": [2, 30], "id": 2}]' http://127.0.0.1:8000/


Invoke-RestMethod -Uri "http://127.0.0.1:8000/" -Method Post -Headers @{ "Content-Type" = "application/json" }  -Body '[{"jsonrpc":"2.0","method":"add","params":[2,3],"id":1},{"jsonrpc":"2.0","method":"multiply","params":[2,30],"id":2}]'

Install fastmcp

uv add fastmcp

Run MCP inspector

uv run fastmcp dev inspector TestMPCserver.py 

Run MCP server

uv run fastmcp run TestMPCserver.py

Connect to cluade-desktop

uv run fastmcp install claude-desktop TestMPCserver.py

Run MCP server

uv run fastmcp run DataprovidersMCPServer.py

Connect to cluade-desktop

uv run fastmcp install claude-desktop DataprovidersMCPServer.py
uv add langchain langchain-openai langchain-mcp-adapters python-dotenv streamlit logging pandas fastmcp python-dotenv jsonrpcserver uvicorn streamlit langchain-ollama fastapi
 uvicorn serversendevent:app
 uvicorn Streamable:app

VS Code Debugging

A launch.json file is provided in the .vscode directory to enable debugging with VS Code. You can set breakpoints in main.py and run the "Python: FastAPI" configuration.

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