MCP.so
ログイン

How to build an MCP server - Calculator Example

@simonberner

基本情報

カテゴリ

開発者ツール

ライセンス

MIT license

トランスポート

stdio

作者

simonberner

How to build an MCP server - Calculator Example について

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

How to build an MCP server - Calculator Example の設定

以下の設定を使って、このサーバーを MCP 対応クライアントに追加してください。

{
  "mcpServers": {
    "mcp-server-calculator-simonberner": {
      "command": "npx",
      "args": [
        "-y",
        "@smithery/cli",
        "install",
        "@simonberner/mcp-server-calculator",
        "--client",
        "claude"
      ]
    }
  }
}

How to build an MCP server - Calculator Example のツール

ツール一覧はまだありません

この掲載には表示できるツール一覧がまだありません。サーバーにツールがないという意味ではありません。対応機能はプロジェクトのドキュメントをご確認ください。

上のボタンで一時的なサンドボックスでこのサーバーを実行し、ツール一覧を取得できます。

概要

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.

よくある質問

1

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.

2

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.

3

What dependencies are required?

Python 3, the MCP SDK, the MCP CLI, and pytest. Optionally Nix (or Lix) for a reproducible environment.

4

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.

5

Where does server data live?

The server is stateless; all math operations are computed in memory and no data is persisted.

6

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.

コメント

「開発者ツール」の他のコンテンツ