Related MCP Server Resources

Explore more AI models, providers, and integration options:

  • Explore AI Models
  • Explore AI Providers
  • Explore MCP Servers
  • LangDB Pricing
  • Documentation
  • AI Industry Blog
  • Bybit MCP Server
  • IR Toolshed MCP Server
  • Vertex AI MCP Server
  • Amazon VPC Lattice MCP Server
  • GHAS MCP server GitHub Advanced Security
Back to MCP Servers
Calculator MCP Server

Calculator MCP Server

Public
mzdz/calc-mcp

Provides basic and advanced arithmetic operations including addition, subtraction, multiplication, division, power, square root, and expression evaluation with calculation history and resource API access, built on the Model Context Protocol (MCP).

python
0 tools
May 30, 2025
Updated Jun 4, 2025

Supercharge Your AI with Calculator MCP Server

MCP Server

Unlock the full potential of Calculator MCP Server through LangDB's AI Gateway. Get enterprise-grade security, analytics, and seamless integration with zero configuration.

Unified API Access
Complete Tracing
Instant Setup
Get Started Now

Free tier available • No credit card required

Instant Setup
99.9% Uptime
10,000+Monthly Requests

计算器 MCP 服务器

这是一个使用 Model Context Protocol (MCP) 开发的计算器服务器,提供基本的算术运算功能。

功能特点

基本计算器功能

  • 加法、减法、乘法、除法的基本运算
  • 自动记录计算历史
  • 通过资源 API 访问帮助信息和历史记录

高级计算器功能

  • 幂运算和平方根计算
  • 表达式计算(使用安全的表达式求值)
  • 资源更新通知(当历史记录更新时)

安装要求

  1. Python 3.7 或更高版本
  2. MCP Python SDK

安装步骤

  1. 克隆或下载此仓库
  2. 安装依赖项:
pip install -r requirements.txt

使用方法

运行基本计算器服务器

python calculator_server.py

或者使用 MCP 命令:

mcp run calculator_server.py

运行高级计算器服务器

python advanced_calculator_server.py

运行客户端示例

python calculator_client.py

可用工具

基本工具:

  • add(a, b): 计算 a + b
  • subtract(a, b): 计算 a - b
  • multiply(a, b): 计算 a * b
  • divide(a, b): 计算 a / b

高级工具(仅在高级计算器中可用):

  • power(base, exponent): 计算 base 的 exponent 次幂
  • sqrt(value): 计算平方根
  • evaluate_expression(expression): 计算数学表达式字符串

可用资源

  • calculator://help: 获取帮助信息
  • calculator://history: 获取计算历史记录

示例代码

使用 Python 客户端调用计算器服务器

from mcp import ClientSession, StdioServerParameters from mcp.client.stdio import stdio_client import asyncio async def main(): server_params = StdioServerParameters( command="python", args=["advanced_calculator_server.py"], ) async with stdio_client(server_params) as (read, write): async with ClientSession(read, write) as session: await session.initialize() # 调用加法工具 result = await session.call_tool("add", {"a": 5, "b": 3}) print(f"5 + 3 = {result}") # 读取计算历史 history, _ = await session.read_resource("calculator://history") print(history) if __name__ == "__main__": asyncio.run(main())

项目结构

  • calculator_server.py: 基本计算器 MCP 服务器
  • advanced_calculator_server.py: 高级计算器 MCP 服务器,带有更多功能
  • calculator_client.py: 计算器客户端示例
  • requirements.txt: 项目依赖
  • README.md: 项目文档

进一步开发

你可以通过以下方式扩展这个计算器服务器:

  1. 添加更多数学函数(如三角函数、对数等)
  2. 实现更复杂的表达式解析器
  3. 添加图形界面
  4. 实现持久化存储计算历史
  5. 添加用户自定义变量和函数

许可证

MIT 许可证

Publicly Shared Threads0

Discover shared experiences

Shared threads will appear here, showcasing real-world applications and insights from the community. Check back soon for updates!

Share your threads to help others
Related MCPs5
  • Bybit MCP Server
    Bybit MCP Server

    Provides read-only access to Bybit's cryptocurrency exchange API via Model Context Protocol, offerin...

    9 tools
    Added May 30, 2025
  • IR Toolshed MCP Server
    IR Toolshed MCP Server

    Provides a Model Context Protocol (MCP) service offering advanced network incident response tools in...

    Added May 30, 2025
  • Vertex AI MCP Server
    Vertex AI MCP Server

    Provides a Model Context Protocol server enabling advanced interaction with Google Cloud's Vertex AI...

    20 tools
    Added May 30, 2025
  • Amazon VPC Lattice MCP Server
    Amazon VPC Lattice MCP Server

    Model Context Protocol server offering tools to access, manage, and automate AWS VPC Lattice resourc...

    2 tools
    Added May 30, 2025
  • GHAS MCP server GitHub Advanced Security
    GHAS MCP server GitHub Advanced Security

    Provides Model Context Protocol (MCP) integration for GitHub Advanced Security by enabling read-only...

    Added May 30, 2025