Agentic MCP Microservices

Agentic MCP Microservices

MCP server that exposes customer profile, order listing, and order cancellation tools, integrating with underlying REST services to enable AI agents to manage customer and order workflows.

Category
访问服务器

README

Enterprise BAU Services with MCP and Gemini

An executable proof of concept showing how an AI agent can work with existing Business-as-Usual (BAU) REST microservices through the Model Context Protocol (MCP).

The demonstration uses Google Gemini to discover MCP tools, retrieve customer and order information, and perform a controlled order-cancellation action. The BAU services remain independent REST APIs; MCP provides the integration boundary between those APIs and the agent.

Demonstration

The included scenario asks the agent to:

  1. Retrieve the profile for CUST-1001.
  2. List the customer's orders.
  3. Identify the order in Processing status.
  4. Cancel ORD-9002 with a supplied reason.
  5. Summarize the completed work.

The expected tool sequence is:

Gemini agent
    -> MCP tool discovery over stdio
    -> MCP server
    -> Customer and Order REST APIs
    -> Tool results returned to Gemini
    -> Final user-facing summary

Architecture

+------------------+       stdio        +------------------+       HTTP       +----------------------+
| Gemini agent     | <----------------> | MCP server       | <--------------> | Customer service     |
| agent_runner.py  |                    | server.py        |                  | localhost:8001       |
+------------------+                    +--------+---------+                  +----------------------+
                                                   |
                                                   | HTTP
                                                   v
                                         +----------------------+
                                         | Order service        |
                                         | localhost:8002       |
                                         +----------------------+

MCP tools

Tool Purpose
get_customer_profile Retrieves customer profile, tier, status, and credit limit.
get_customer_orders Lists orders associated with a customer.
cancel_order_by_id Cancels an order when its status allows cancellation.

Project structure

.
├── 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

Prerequisites

  • Python 3.11 or newer
  • A Gemini API key from Google AI Studio
  • Windows PowerShell, macOS/Linux shell, or an equivalent terminal
  • Network access to the Gemini API when running the agent

This project does not require an Anthropic or OpenAI API key.

Quick start on Windows

Open PowerShell in the project directory:

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

Open .env and replace your_gemini_api_key_here with your key:

GOOGLE_API_KEY=your_gemini_api_key_here
GEMINI_MODEL=gemini-3.6-flash

Never commit .env or place an API key in source code. The selected model must be available to your Gemini account.

Run the demonstration

Use three terminals. Activate .venv in each terminal.

Terminal 1: customer service

python services/customer_service.py

Runs at http://localhost:8001.

Terminal 2: order service

python services/order_service.py

Runs at http://localhost:8002.

Terminal 3: Gemini agent

python agent/agent_runner.py

The agent starts the MCP server as a child process, discovers its tools, and executes the sample workflow.

Verify the local services

Run these commands while the two services are active:

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

Run the tests

With the virtual environment active:

python -m pytest -q

The tests cover case-insensitive customer lookup, missing customers, cancellation of a processing order, and protection against cancelling a shipped order.

Configuration

Variable Description Default
GOOGLE_API_KEY Gemini authentication key. Required
GEMINI_MODEL Gemini model used by the agent. gemini-3.6-flash
CUSTOMER_SERVICE_URL Customer service base URL. http://localhost:8001
ORDER_SERVICE_URL Order service base URL. http://localhost:8002

Scope and limitations

This is a local, intentionally small POC intended to make the integration pattern easy to inspect and run.

  • Customer and order records are stored in memory and reset when services restart.
  • The services do not implement authentication or authorization.
  • The cancellation operation should be protected by approval and business policy controls in a real system.
  • MCP uses stdio for local process integration. A deployed architecture should use an authenticated network transport.
  • Downstream errors are returned as tool text for visibility; production systems should use structured errors, retries, tracing, and metrics.
  • The sample agent makes a real Gemini API request and requires a valid key.

Troubleshooting

GOOGLE_API_KEY is not set

Confirm that .env exists in the project directory and contains a valid key. Run the agent from the project directory.

404 NOT_FOUND for a Gemini model

Set GEMINI_MODEL in .env to a model enabled for your account. The default in this POC is gemini-3.6-flash.

MCP startup or tool discovery fails

Confirm that dependencies were installed into the active virtual environment:

python -m pip install -r requirements.txt

The project pins MCP to the 1.x API range because the server implementation uses FastMCP.

Connection errors from MCP tools

Confirm both REST services are running on ports 8001 and 8002. If a port is already in use, update the service port and the matching URL in .env.

Further reading

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选
mcp-server-qdrant

mcp-server-qdrant

这个仓库展示了如何为向量搜索引擎 Qdrant 创建一个 MCP (Managed Control Plane) 服务器的示例。

官方
精选
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选