Skip to main content
Glama

Math Lab: MCP + OpenAI Agents SDK

このプロジェクトは、同じ数学ロジックを2つのアダプターから使用します。

  • Codex、MCP Inspector、または互換性のある任意のクライアント向けのMCPサーバー。

  • OpenAI Agents SDKで構築されたエージェントで、自然言語で会話します。

pip install -e .でインストール可能なPythonパッケージとしてパッケージ化され、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キー、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

メニューでは以下のことができます。

  1. OpenAIエージェントと会話する(.envOPENAI_API_KEYを使用)。

  2. 加算、減算、乗算、除算をAPIコストなしでローカルにテストする。

  3. 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

数学ツールの追加方法

  1. src/math_assistant/domain/operations.pyに純粋関数とそのdocstringを作成します。

  2. src/math_assistant/application/tool_catalog.pyMATH_OPERATIONSに追加します。

  3. テストを実行します。

2つのアダプターが自動的に公開します。FastMCPはMCPツールに変換し、Agents SDKはfunction toolに変換します。

F
license - not found
Not graded
quality - not tested
C
maintenance

Maintenance

Maintainers
Response time
Release cycle
Releases (12mo)
Commit activity

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

  • F
    license
    Not graded
    quality
    D
    maintenance
    A 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.
  • F
    license
    Not graded
    quality
    D
    maintenance
    A 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.
  • F
    license
    A
    quality
    D
    maintenance
    A 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

View all related MCP servers

Related MCP Connectors

View all MCP Connectors

Latest Blog Posts

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