math-mcp-lab

math-mcp-lab

MCP server exposing pure mathematical operations (sum, subtraction, multiplication, division) as tools, with a clean layered architecture and optional OpenAI Agents SDK integration.

Category
Visit Server

README

Math Lab: MCP + OpenAI Agents SDK

Este proyecto usa una misma lógica matemática desde dos adaptadores:

  • Un servidor MCP para Codex, el MCP Inspector, o cualquier cliente compatible.
  • Un agente construido con el OpenAI Agents SDK para conversar en lenguaje natural.

Empaquetado como paquete Python instalable (pip install -e .), con layout src/ y arquitectura limpia por capas.

Estructura

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

La dependencia siempre apunta hacia adentro:

CLI / MCP / OpenAI SDK  →  application  →  domain

El dominio no conoce FastMCP, OpenAI, una API key, ni print. Por eso puede probarse rápido y sin red.

Instalación

python -m venv .venv
.\.venv\Scripts\python.exe -m pip install -e ".[dev]"

Copia tu OPENAI_API_KEY en un archivo .env en la raíz (nunca se sube a git).

Ejecutar la interfaz amigable

.\.venv\Scripts\python.exe .\run_cli.py

El menú permite:

  1. Hablar con el agente de OpenAI (usa OPENAI_API_KEY de .env).
  2. Probar suma, resta, multiplicación y división localmente, sin costo de API.
  3. Ver las herramientas que el servidor MCP publica.

Ejecutar el servidor MCP

.\.venv\Scripts\python.exe .\run_mcp.py

Para inspeccionarlo con 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"

Usa rutas absolutas: el Inspector no siempre respeta el directorio de trabajo actual.

No agregues print() dentro de run_mcp.py ni del adaptador MCP: el canal estándar de salida (stdout) se reserva para los mensajes JSON-RPC del protocolo. La interfaz amigable vive en run_cli.py por esa razón.

Integración con Codex

.codex/config.toml (no versionado, es config local de máquina) apunta Codex al servidor MCP. Si usas Codex CLI, crea el tuyo:

[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"

Pruebas

.\.venv\Scripts\python.exe -m unittest discover -s tests -v

Cómo añadir una herramienta matemática

  1. Crea la función pura y su docstring en src/math_assistant/domain/operations.py.
  2. Agrégala a MATH_OPERATIONS en src/math_assistant/application/tool_catalog.py.
  3. Ejecuta las pruebas.

Los dos adaptadores la expondrán automáticamente: FastMCP la convierte en una herramienta MCP y el Agents SDK en una function tool.

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured