Skip to main content
Glama
FisherSkyi

MCP Calculator Demo

by FisherSkyi

MCP Demo

This is a demo of the MCP (Model Context Protocol) for testing and demonstration purposes. It includes a simple implementation of the MCP protocol and a sample calculator MCP server that can be used to test the protocol.

Running the Demo

npm install @modelcontextprotocol/sdk zod
node demo-client.mjs

And output should be:

โœ… Calculator MCP server running on stdio
๐Ÿ”ข Calculator MCP Demo
โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€

๐Ÿ“‹ Available tools: multiply, add, subtract, divide

  7 ร— 6 = 42
  123 ร— 456 = 56088
  42 + 58 = 100
  100 โˆ’ 37 = 63
  144 รท 12 = 12
  Error: Division by zero is undefined.

โœ… Demo complete!

How It Works

There are two files:

server.mjs โ€” the MCP Server

  • Registers 4 tools: multiply, add, subtract, divide

  • Each tool has a name, description, and typed inputs (using Zod)

  • Listens for calls over stdio (stdin/stdout)

demo-client.mjs โ€” the MCP Client

  • Spawns server.mjs as a subprocess

  • Calls listTools() to discover what the server offers

  • Calls each tool with arguments, gets results back

The communication between them looks like this:

demo-client.mjs  โ”€โ”€โ”€โ”€ JSON-RPC over stdio โ”€โ”€โ”€โ”€โ–ถ  server.mjs
   (Client)             { tool: "multiply",         (Server)
                          args: { a:7, b:6 } }
                โ—€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
                         { result: "7 ร— 6 = 42" }

Connect to Claude Desktop

This lets Claude itself call your calculator tools in conversation.

Find your Claude Desktop config file:

Mac: ~/Library/Application Support/Claude/claude_desktop_config.json Windows: %APPDATA%\Claude\claude_desktop_config.json

See https://modelcontextprotocol.io/docs/develop/connect-local-servers for details.

Add this (replace the path with your actual folder path):

{
  "mcpServers": {
    "calculator": {
      "command": "node",
      "args": ["/Users/yourname/calculator-mcp/server.mjs"]
    }
  }
}

Restart Claude Desktop. Then try asking Claude: "What is 123 multiplied by 456?" โ€” it will use your multiply tool to answer.

example ui of claude desktop alt text

-
security - not tested
F
license - not found
-
quality - not tested

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Latest Blog Posts

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/FisherSkyi/mcp-demo'

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