Agentic MCP Microservices
MCP と Gemini によるエンタープライズ BAU サービス
既存の Business-as-Usual (BAU) REST マイクロサービスと、Model Context Protocol (MCP) を通じて AI エージェントが連携する方法を示す、実行可能な概念実証です。
このデモンストレーションでは、Google Gemini を使用して MCP ツールを発見し、顧客情報と注文情報を取得し、制御された注文キャンセル操作を実行します。BAU サービスは独立した REST API のままであり、MCP がそれらの API とエージェントの間の統合境界を提供します。
デモンストレーション
含まれるシナリオでは、エージェントに次のことを要求します。
CUST-1001のプロファイルを取得する。顧客の注文を一覧表示する。
Processingステータスの注文を特定する。指定された理由で
ORD-9002をキャンセルする。完了した作業を要約する。
期待されるツールシーケンスは次のとおりです。
Gemini agent
-> MCP tool discovery over stdio
-> MCP server
-> Customer and Order REST APIs
-> Tool results returned to Gemini
-> Final user-facing summaryRelated MCP server: MCP API Tool Demo
アーキテクチャ
+------------------+ stdio +------------------+ HTTP +----------------------+
| Gemini agent | <----------------> | MCP server | <--------------> | Customer service |
| agent_runner.py | | server.py | | localhost:8001 |
+------------------+ +--------+---------+ +----------------------+
|
| HTTP
v
+----------------------+
| Order service |
| localhost:8002 |
+----------------------+MCP ツール
Tool | 目的 |
| 顧客プロファイル、ティア、ステータス、与信限度額を取得します。 |
| 顧客に関連付けられた注文を一覧表示します。 |
| ステータスがキャンセルを許可している場合に注文をキャンセルします。 |
プロジェクト構造
.
├── agent/
│ └── agent_runner.py # Gemini agent and MCP client
├── mcp_server/
│ └── server.py # MCP tools and REST integration
├── services/
│ ├── customer_service.py # Mock customer REST API
│ └── order_service.py # Mock order REST API
├── tests/
│ └── test_services.py # Service behavior tests
├── .env.example # Environment variable template
├── requirements.txt # Python dependencies
└── mcp_microservices_poc_blueprint.md
# Detailed design and implementation reference前提条件
Python 3.11 以降
Google AI Studio の Gemini API キー
Windows PowerShell、macOS/Linux シェル、または同等のターミナル
エージェント実行時に Gemini API へのネットワークアクセス
このプロジェクトには Anthropic または OpenAI の API キーは必要ありません。
Windows でのクイックスタート
プロジェクトディレクトリで PowerShell を開きます。
python -m venv .venv
.\.venv\Scripts\Activate.ps1
python -m pip install --upgrade pip
python -m pip install -r requirements.txt
Copy-Item .env.example .env.env を開き、your_gemini_api_key_here を自分のキーに置き換えます。
GOOGLE_API_KEY=your_gemini_api_key_here
GEMINI_MODEL=gemini-3.6-flash.env をコミットしたり、API キーをソースコードに配置したりしないでください。選択したモデルがお使いの Gemini アカウントで利用可能である必要があります。
デモンストレーションの実行
3 つのターミナルを使用します。各ターミナルで .venv をアクティベートします。
ターミナル 1: 顧客サービス
python services/customer_service.pyhttp://localhost:8001 で実行されます。
ターミナル 2: 注文サービス
python services/order_service.pyhttp://localhost:8002 で実行されます。
ターミナル 3: Gemini エージェント
python agent/agent_runner.pyエージェントは MCP サーバーを子プロセスとして起動し、そのツールを発見して、サンプルワークフローを実行します。
ローカルサービスの検証
2 つのサービスがアクティブな状態で、次のコマンドを実行します。
Invoke-RestMethod http://localhost:8001/health
Invoke-RestMethod http://localhost:8002/health
Invoke-RestMethod http://localhost:8001/api/v1/customers/CUST-1001
Invoke-RestMethod http://localhost:8002/api/v1/orders/customer/CUST-1001テストの実行
仮想環境をアクティブにした状態で:
python -m pytest -qテストでは、大文字と小文字を区別しない顧客検索、存在しない顧客、処理中の注文のキャンセル、および出荷済みの注文のキャンセル防止をカバーしています。
設定
Variable | 説明 | デフォルト |
| Gemini 認証キー。 | 必須 |
| エージェントが使用する Gemini モデル。 |
|
| 顧客サービスのベース URL。 |
|
| 注文サービスのベース URL。 |
|
範囲と制限事項
これはローカル向けの、意図的に小規模な POC であり、統合パターンを簡単に確認して実行できるようにすることを目的としています。
顧客および注文レコードはメモリ内に保存され、サービスが再起動するとリセットされます。
サービスは認証または認可を実装していません。
キャンセル操作は、実際のシステムでは承認およびビジネスポリシー制御によって保護されるべきです。
MCP はローカルプロセス統合に stdio を使用します。デプロイされたアーキテクチャでは、認証されたネットワークトランスポートを使用する必要があります。
下流のエラーは可視化のためにツールテキストとして返されます。本番システムでは、構造化エラー、リトライ、トレーシング、およびメトリクスを使用する必要があります。
サンプルエージェントは実際の Gemini API リクエストを行うため、有効なキーが必要です。
トラブルシューティング
GOOGLE_API_KEY is not set
.env がプロジェクトディレクトリに存在し、有効なキーが含まれていることを確認してください。プロジェクトディレクトリからエージェントを実行してください。
Gemini モデルでの 404 NOT_FOUND
.env の GEMINI_MODEL を、アカウントで有効なモデルに設定してください。この POC のデフォルトは gemini-3.6-flash です。
MCP の起動またはツール発見の失敗
依存関係がアクティブな仮想環境にインストールされていることを確認してください。
python -m pip install -r requirements.txtこのプロジェクトは、サーバー実装が FastMCP を使用しているため、MCP を 1.x API 範囲に固定しています。
MCP ツールからの接続エラー
両方の REST サービスがポート 8001 と 8002 で実行されていることを確認してください。ポートがすでに使用されている場合は、サービスポートと .env 内の対応する URL を更新してください。
参考資料
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
- AlicenseNot gradedqualityCmaintenanceAn MCP server that enables AI agents to interact with the commercetools Composable Commerce platform. It provides tools for managing products, categories, orders, carts, and customer data through secure read and write operations.13MIT
- FlicenseNot gradedqualityBmaintenanceDemo MCP server that exposes order and customer data as read-only tools for AI assistants, simulating a business API or internal data source.
- AlicenseNot gradedqualityCmaintenanceMCP server that bridges AI agents with external tools, APIs, databases, and services, enabling standardized tool execution and resource access.MIT
- FlicenseNot gradedqualityBmaintenanceMCP server that enables AI platforms to search products, customers, and warehouses, and prepare and submit sales orders to a fixed ERP endpoint with per-session bearer authentication.
Related MCP Connectors
MCP server for AI agents to plan, verify, and deploy Cloudflare-native apps.
MCP server exposing the Backtest360 engine API as tools for AI agents.
MCP server for secureFlows: token-free URL builders and integration-linting tools for AI agents.
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/sganapa/agentic-mcp-microservices'
If you have feedback or need assistance with the MCP directory API, please join our Discord server