math-mcp-lab
Math Lab: MCP + OpenAI Agents SDK
本项目通过两个适配器使用同一套数学逻辑:
一个用于 Codex、MCP Inspector 或任何兼容客户端的 MCP 服务器。
一个使用 OpenAI Agents SDK 构建的代理,用于自然语言对话。
打包为可安装的 Python 包(pip install -e .),采用 src/ 布局和清晰的分层架构。
结构
pyproject.toml # Metadata, dependencias y entry points del paquete
src/
└── math_assistant/
├── domain/ # Reglas matemáticas puras (sin dependencias externas)
├── application/ # Catálogo de capacidades públicas
├── infrastructure/ # Adaptadores para MCP (FastMCP) y OpenAI Agents SDK
└── presentation/ # Interfaz de terminal
tests/
├── unit/ # Prueban dominio y catálogo
└── integration/ # Comprueban que los adaptadores se construyen
run_cli.py # Entry point: interfaz amigable para aprender y probar
run_mcp.py # Entry point: STDIO exclusivo para el cliente MCP依赖始终指向内部:
CLI / MCP / OpenAI SDK → application → domain领域层不依赖 FastMCP、OpenAI、API key 或 print。因此可以快速测试,无需网络。
Related MCP server: Explore MCP
安装
python -m venv .venv
.\.venv\Scripts\python.exe -m pip install -e ".[dev]"将你的 OPENAI_API_KEY 复制到根目录下的 .env 文件中(永远不会提交到 git)。
运行友好界面
.\.venv\Scripts\python.exe .\run_cli.py菜单允许:
与 OpenAI 代理对话(使用
.env中的OPENAI_API_KEY)。在本地测试加法、减法、乘法和除法,无需 API 费用。
查看 MCP 服务器发布的工具。
运行 MCP 服务器
.\.venv\Scripts\python.exe .\run_mcp.py要使用 MCP Inspector 检查它:
npx @modelcontextprotocol/inspector "C:\ruta\completa\a\math-mcp-lab\.venv\Scripts\python.exe" "C:\ruta\completa\a\math-mcp-lab\run_mcp.py"使用绝对路径:Inspector 并不总是遵循当前工作目录。
不要在 run_mcp.py 或 MCP 适配器中添加 print():标准输出通道(stdout)保留给协议的 JSON-RPC 消息。友好界面因此位于 run_cli.py 中。
与 Codex 集成
.codex/config.toml(不纳入版本控制,是机器本地配置)将 Codex 指向 MCP 服务器。如果你使用 Codex CLI,请创建你自己的:
[mcp_servers.math]
command = "C:\\ruta\\completa\\a\\math-mcp-lab\\.venv\\Scripts\\python.exe"
args = ["C:\\ruta\\completa\\a\\math-mcp-lab\\run_mcp.py"]
cwd = "C:\\ruta\\completa\\a\\math-mcp-lab"测试
.\.venv\Scripts\python.exe -m unittest discover -s tests -v如何添加数学工具
在
src/math_assistant/domain/operations.py中创建纯函数及其 docstring。将其添加到
src/math_assistant/application/tool_catalog.py中的MATH_OPERATIONS。运行测试。
两个适配器会自动暴露它:FastMCP 将其转换为 MCP 工具,Agents SDK 将其转换为 function tool。
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- AlicenseBqualityDmaintenanceA learning-focused MCP server that demonstrates how to build arithmetic tools for AI assistants, currently featuring addition functionality with structured input/output.117MIT
- FlicenseNot gradedqualityDmaintenanceA demonstration MCP server that exposes basic arithmetic tools (add, subtract, ping) through FastAPI and shows how to integrate them with OpenAI's tool-calling API for LLM orchestration.
- FlicenseNot gradedqualityDmaintenanceA simple demonstration MCP server built with FastMCP that exposes basic calculator operations (add, subtract, multiply, divide) as tools for MCP clients like GitHub Copilot Agent mode.
- FlicenseAqualityDmaintenanceA basic MCP server built with the FastMCP framework that provides fundamental mathematical operations like addition, subtraction, multiplication, and division. It serves as a demonstration for integrating math-based tools into MCP-compatible environments like Cursor IDE.4
Related MCP Connectors
MCP server exposing the Backtest360 engine API as tools for AI agents.
This MCP server enables users to perform scientific computations regarding linear algebra and vect…
Hosted MCP server to manage a restaurant menu from AI agents - 39 tools over the DuckHub API.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/matiasn2008/math-mcp-lab'
If you have feedback or need assistance with the MCP directory API, please join our Discord server