drio
Open app

How to build an MCP server - Calculator Example

Source

Example project showing how to build a simple MCP Server (and having it on Smithery!)

Catalog onlyCatalog onlySTDIO

Overview

MCP Server Calculator is a project aimed at providing a step-by-step guide to building an MCP server, specifically focusing on a calculator example.

To use the MCP Server Calculator, follow the setup instructions to create and activate a virtual environment, and then install the necessary libraries using pip.

  • Step-by-step instructions for setting up an MCP server - Example project focused on a calculator application - Guidance on creating a virtual environment and installing libraries
  1. Learning how to build an MCP server from scratch
  2. Understanding the setup process for Python projects
  3. Using the calculator example as a foundation for more complex applications

Add to your AI client

Use these steps to connect How to build an MCP server - Calculator Example in Cursor, Claude, VS Code, and other MCP-compatible apps. The same JSON appears in the Use with menu above for one-click copy.

Cursor

Add this to your .cursor/mcp.json file in your project root, then restart Cursor.

.cursor/mcp.json

{
  "mcpServers": {
    "mcp-server-calculator-simonberner": {
      "command": "npx",
      "args": [
        "-y",
        "@modelcontextprotocol/server-mcp-server-calculator-simonberner"
      ]
    }
  }
}

Claude Desktop

Add this server entry to the mcpServers object in your Claude Desktop config, then restart the app.

~/Library/Application Support/Claude/claude_desktop_config.json (macOS) or %APPDATA%\Claude\claude_desktop_config.json (Windows)

{
  "mcpServers": {
    "mcp-server-calculator-simonberner": {
      "command": "npx",
      "args": [
        "-y",
        "@modelcontextprotocol/server-mcp-server-calculator-simonberner"
      ]
    }
  }
}

Claude Code

Add this to your project's .mcp.json file. Claude Code will detect it automatically.

.mcp.json (project root)

{
  "mcpServers": {
    "mcp-server-calculator-simonberner": {
      "command": "npx",
      "args": [
        "-y",
        "@modelcontextprotocol/server-mcp-server-calculator-simonberner"
      ]
    }
  }
}

VS Code (Copilot)

Add this to your .vscode/mcp.json file. Requires the GitHub Copilot extension with MCP support enabled.

.vscode/mcp.json

{
  "servers": {
    "mcp-server-calculator-simonberner": {
      "type": "stdio",
      "command": "npx",
      "args": [
        "-y",
        "@modelcontextprotocol/server-mcp-server-calculator-simonberner"
      ]
    }
  }
}

Windsurf

Add this to your Windsurf MCP config file, then restart Windsurf.

~/.codeium/windsurf/mcp_config.json

{
  "mcpServers": {
    "mcp-server-calculator-simonberner": {
      "command": "npx",
      "args": [
        "-y",
        "@modelcontextprotocol/server-mcp-server-calculator-simonberner"
      ]
    }
  }
}

Cline

Open Cline settings, navigate to MCP Servers, and add this server configuration.

Cline MCP Settings (via UI)

{
  "mcpServers": {
    "mcp-server-calculator-simonberner": {
      "command": "npx",
      "args": [
        "-y",
        "@modelcontextprotocol/server-mcp-server-calculator-simonberner"
      ]
    }
  }
}

FAQ

Is the MCP Server Calculator complete?

No, it is currently a work in progress.

What libraries are required to run the MCP Server Calculator?

You need to install the 'mcp' library and its CLI version using pip.

Can I use this project for other applications?

Yes, the calculator example can be adapted for various other applications.