MCPServerDemo MCP Server

1

Add it to Claude Code

Run this in a terminal.

Run in terminal
claude mcp add mcp-server-demo -- uv run fastmcp install claude-desktop TestMPCserver.py
README.md

A demonstration server that implements JSON-RPC 2.0 methods for arithmetic.

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

Streaming HTTP Demo

This project includes a streaming HTTP endpoint demonstration using FastAPI's StreamingResponse.

Start the Stream Server

uv run uvicorn Streamable:app --reload

The server will run at http://127.0.0.1:8000/stream and sends 10 chunks with 1-second intervals.

Run the Stream Client

python StreamableClient.py

The client demonstrates both async and synchronous methods to consume the streaming response.

Test with curl

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

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

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.

Tools (2)

addAdds two numbers together.
multiplyMultiplies two numbers together.

Configuration

claude_desktop_config.json
{"mcpServers": {"MCPServerDemo": {"command": "uv", "args": ["run", "fastmcp", "run", "TestMPCserver.py"]}}}

Try it

Add 25 and 47 using the MCPServerDemo tool.
Multiply 12 by 8 using the available arithmetic tools.
Can you calculate the sum of 100 and 250?
Use the multiply tool to find the product of 15 and 4.

Frequently Asked Questions

What are the key features of MCPServerDemo?

Implements JSON-RPC 2.0 methods for basic arithmetic. Provides integration examples for the Model Context Protocol. Includes a streaming HTTP endpoint demonstration using FastAPI. Supports auto-reloading development server via Uvicorn.

What can I use MCPServerDemo for?

Learning how to implement JSON-RPC 2.0 with FastAPI. Testing Model Context Protocol (MCP) connectivity with Claude Desktop. Demonstrating streaming HTTP responses in a Python environment. Debugging MCP server interactions using the FastMCP inspector.

How do I install MCPServerDemo?

Install MCPServerDemo by running: uv pip install fastapi uvicorn jsonrpcserver fastmcp

What MCP clients work with MCPServerDemo?

MCPServerDemo works with any MCP-compatible client including Claude Desktop, Claude Code, Cursor, and other editors with MCP support.

Turn this server into reusable context

Keep MCPServerDemo docs, env vars, and workflow notes in Conare so your agent carries them across sessions.

Need the old visual installer? Open Conare IDE.
Open Conare