About MCP example & Demo
MCP example & Demo is a sample server for developers learning or testing MCP. Its README walks through STDIN execution, JSON-RPC requests, tool calls, and use of the MCP inspector.
Key features
- 01STDIN server example
- 02Initialize and ping requests
- 03List and call the Add tool
- 04Example tool-call error
- 05MCP inspector dev mode
Use cases
- 01Review MCP initialization and notification formats
- 02Test tool listing and invocation requests
- 03Debug the server with the inspector
MCP support
This example MCP server demonstrates protocol interactions including initialization, ping, listing tools, and calling a tool.
Configuration
Local server config is the same for every client. Copy it into your client’s MCP config file.
We haven’t collected a package or remote endpoint for this server. Follow the instructions in the project README.
Tools
Local servers expose tools only once running on your machine, and the maintainer has not provided a tool list.
Details
From the project READMEMCP example & Demo
Example: Run on STDIN
Run server
mcp run server.py
1. Initialize request
{
"jsonrpc": "2.0",
"id": 1,
"method": "initialize",
"params": {
"protocolVersion": "2025-03-26",
"capabilities": {
"roots": {
"listChanged": true
},
"sampling": {}
},
"clientInfo": {
"name": "ExampleClient",
"version": "1.0.0"
}
}
}
Note: It MUST be in one line!
{"jsonrpc": "2.0", "id": 1, "method": "initialize", "params": {"protocolVersion": "2025-03-26", "capabilities": {"roots": {"listChanged": true}, "sampling": {}}, "clientInfo": {"name": "ExampleClient", "version": "1.0.0"}}}
2. Initialized OK
{"jsonrpc": "2.0", "method": "notifications/initialized" }
3. Ping
{"jsonrpc": "2.0", "id":"123", "method":"ping"}
4. List tools
{"jsonrpc" :"2.0", "id" :1, "method" :"tools/list"}
5. Call tool: Add
{
"jsonrpc": "2.0",
"id": 2,
"method": "tools/call",
"params": {
"name": "add",
"arguments": {
"a": 40,
"b": 2
}
}
}
{"jsonrpc": "2.0", "id": 2, "method": "tools/call", "params": {"name": "add", "arguments": {"a": 40 ,"b": 2}}}
6. Call tool: Add, with an error
{
"jsonrpc": "2.0",
"id": 2,
"method": "tools/call",
"params": {
"name": "add",
"arguments": {
"a": 40,
"z": "2"
}
}
}
{"jsonrpc": "2.0", "id": 2, "method": "tools/call", "params": {"name": "add", "arguments": {"a": 40 ,"z": "2"}}}
Example 2: Use MCP inspector
Run in 'dev' mode:
mcp dev server.py
Comments
New to MCP?
From what the protocol is to installing your first server, these answers cover most first questions.
An open protocol that defines how AI applications connect to external tools and data in a uniform way. Clients talk to the model; MCP servers provide tools, resources and prompt templates. They exchange standard messages, so one server can be reused by many clients.