计算器MCP服务

一个简单的MCP服务器演示,用于执行基本算术运算,适用于需要快速部署计算服务的场景。

  • by amugoodbad229
  • Python
  • 本地部署
  • 更新于
在 GitHub 查看 amugoodbad229/calculator_mcp_demo

使用说明

计算器MCP演示

一个简单而现代的MCP服务器演示,旨在执行基本的算术运算。此存储库主要是为在FastMCP Cloud上部署而创建的。

🚀 概述

该项目提供了一个构建和部署MCP(模型控制程序)服务器的简单示例。它公开了一组可由客户端应用程序调用的计算器工具。

✨ 特性

  • 补充: 将两个数字相加。
  • 减法: 从一个数字中减去另一个数字。
  • 乘法: 将两个数字相乘。
  • 部门: 将一个数字除以另一个数字,并对除以零的错误进行处理。

► 查看资源板

🛠️ 技术栈

  • python
  • FastMCP
  • httpx

🚀 如何使用它

从下面的选项中选择您喜欢的客户端或工具,并使用提供的代码段进行连接。

🐍 FastMCP Client (Python)
import asyncio
from fastmcp import Client, FastMCP

client = Client("https://calculator-mcp-demo.fastmcp.app/mcp")

async def main():
    async with client:
        # Ensure client can connect
        await client.ping()

        # List available operations
        tools = await client.list_tools()
        resources = await client.list_resources()
        prompts = await client.list_prompts()

        # Ex. execute a tool call
        result = await client.call_tool("your_example_tool", {"param": "value"})
        print(result)

asyncio.run(main())
🧠 OpenAI SDK (Python)
from openai import OpenAI

client = OpenAI()

resp = client.responses.create(
    model="gpt-4.1",
    tools=[
        {
            "type": "mcp",
            "server_label": "calculator-mcp-demo",
            "server_url": "https://calculator-mcp-demo.fastmcp.app/mcp",
            "require_approval": "never",
        },
    ],
    input="Hello from FastMCP Cloud!",
)
🤖 Claude Desktop

要连接、下载并安装 .dxt 配置文件来自 客户 FastMCP Cloud仪表板上的选项卡。

🖱️ Connect to Cursor

通过在浏览器上粘贴链接立即安装:

cursor://anysphere.cursor-deeplink/mcp/install?name=calculator-mcp演示和配置=eyJ1cmwiOiJodHRwczovL2NhbGN1bGF0b3ItbWNwLWRlbW8uZmFzdG1jcC5hcHAvbWNwIn0%3D

⚡ Command Line Integrations (CLI)

Gemini CLI

gemini mcp add calculator-mcp-demo https://calculator-mcp-demo.fastmcp.app/mcp --transport http

克劳德代码

claude mcp add --scope local --transport http calculator-mcp-demo https://calculator-mcp-demo.fastmcp.app/mcp

Codex CLI

运行此命令以添加服务器:

codex mcp add -- calculator-mcp-demo npx -y mcp-remote@latest https://calculator-mcp-demo.fastmcp.app/mcp

或者,将此添加到您的Codex配置文件中:

[mcp_servers.calculator-mcp-demo]
command = "npx"
args = ["-y", "mcp-remote@latest", "https://calculator-mcp-demo.fastmcp.app/mcp"]

☁️ 部署

此MCP服务器旨在部署在 FastMCP云The pyproject.toml 包含文件是为了方便此过程。

📄 许可证

此项目根据MIT许可证获得许可-请参阅 许可证 文件以获取详细信息。