How to build an MCP server - Calculator Example
@simonberner
关于 How to build an MCP server - Calculator Example
Example project showing how to build a simple MCP Server (and having it on Smithery!)
基本信息
配置
使用下面的配置,将此服务器添加到你的 MCP 客户端。
{
"mcpServers": {
"mcp-server-calculator-simonberner": {
"command": "npx",
"args": [
"-y",
"@smithery/cli",
"install",
"@simonberner/mcp-server-calculator",
"--client",
"claude"
]
}
}
}工具
未检测到工具
工具是从 README 中自动提取的。维护者可以在 ## Tools 标题下列出工具,即可填充这部分内容。
概览
What is How to build an MCP server - Calculator Example?
This is a simple example MCP server that provides basic math operations (addition, subtraction, multiplication, division) to an MCP client. It demonstrates how to build an MCP server from scratch using Python and the MCP SDK, intended for developers learning the Model Context Protocol.
How to use How to build an MCP server - Calculator Example?
Install automatically via Smithery (npx -y @smithery/cli install @simonberner/mcp-server-calculator --client claude), or set up the development environment using Nix/direnv or manually with uv. Run locally with mcp dev src/mcp_server_calculator/calculator.py and test using MCP Inspector. Integrate with an MCP host by adding the server configuration to the host's mcp config file (e.g., for Claude Desktop).
Key features of How to build an MCP server - Calculator Example
- Provides basic math operations: add, subtract, multiply, divide.
- Built with Python 3 and the MCP SDK.
- Supports installation via Smithery, Nix, or uv.
- Testable via MCP Inspector web interface.
- Includes unit tests with pytest.
Use cases of How to build an MCP server - Calculator Example
- Learning how to build an MCP server from scratch.
- Prototyping a simple math tool for AI agents.
- Testing MCP client-server interactions locally.
FAQ from How to build an MCP server - Calculator Example
What is MCP?
Model Context Protocol (MCP) is a protocol that enables LLMs to access custom tools and services. An MCP client can make requests to MCP servers to access tools they provide.
How do I install this server?
You can install it via Smithery, use the Nix development environment with direnv, or set it up manually with uv. For hosts like Claude Desktop, add the server configuration to your mcp config.
What dependencies are required?
Python 3, the MCP SDK, the MCP CLI, and pytest. Optionally Nix (or Lix) for a reproducible environment.
How do I test the server locally without an LLM?
Run mcp dev src/mcp_server_calculator/calculator.py and open MCP Inspector at http://localhost:5173 to test the server via a GUI.
Where does server data live?
The server is stateless; all math operations are computed in memory and no data is persisted.
What transport does it use?
The server runs as a Python script over stdio, configured locally in the MCP host’s configuration file. It is not a remote server.
开发工具 分类下的更多 MCP 服务器
MCP-Scan: An MCP Security Scanner
invariantlabs-aiSecurity scanner for AI agents, MCP servers and agent skills.
MCP Containers
metorialConnect any AI model to 1200+ integrations (MCP, CLI, API)
DevDocs by CyberAGI 🚀
cyberagiincCompletely free, private, UI based Tech Documentation MCP server. Designed for coders and software developers in mind. Easily integrate into Cursor, Windsurf, Cline, Roo Code, Claude Desktop App
MCP-Bridge
SecretiveShellA middleware to provide an openAI compatible endpoint that can call MCP tools
Smithery CLI
smithery-aiInstall, manage and develop MCP servers and skills for agents
评论