curl / Postman / OpenAI function-callingからMCPサーバーを呼び出す方法
使うタイミング: 優れたMCPサーバーを選んだが、本番スタックがPythonサービス / OpenAI Assistants API / HTTP+JSONを必要とするものの場合。
前提条件
- 通常起動するMCPコマンド — 例:
uvx mcp-server-timeまたはnpx -y @modelcontextprotocol/server-fetch
フロー
-
ラップするRun
uvx mcpo --port 8000 -- uvx mcp-server-timeand confirm /docs is up.✓ コピーしました→ Swagger UIがツールをエンドポイントとして表示 -
curlから呼び出すShow me a working curl that calls the time tool with timezone=America/Los_Angeles.✓ コピーしました→ 現在時刻 + タイムゾーン情報が返される
-
OpenAIに接続するGenerate a function-calling spec from /openapi.json that I can paste into the OpenAI API.✓ コピーしました→ スペックが出力;簡単なテスト呼び出しが成功
結果: 非MCPバックエンドがHTTP経由で操作できるMCPサーバー。
注意点
- 長時間実行ツールがデフォルトのuvicorn設定でタイムアウトする — mcpoに
--timeout-keep-alive 600を渡すか、同じタイムアウトでnginxをフロントに置いてください