The MCP service exposes the OpenTelemetry Astronomy Shop demo's tools over the
Model Context Protocol. It runs a
FastMCP server that lets the agent
service (or any other MCP-compatible client) discover and invoke shop
operations such as listing products, managing carts, checking out.... etc
- Runtime: Python 3.14
- MCP framework: FastMCP (built on top of
mcp) - Transport: HTTP streamable transport at
/mcp - Observability: Traceloop SDK and OpenTelemetry OTLP export, with
httpxauto-instrumentation - Default port:
8011
The service starts from run.py, initializes Traceloop instrumentation,
instruments the httpx client, and launches the MCP FastMCP
server in a worker thread.
The MCP server registers the Astronomy Shop tools defined in
src/shared/tools.py (copied into the image at build time).
Each tool calls the frontend HTTP API through APPLICATION_ENDPOINT.
| Tool | Description |
|---|---|
list_products |
Lists available products. |
get_product(product_id) |
Gets details for a specific product. |
get_ads(category) |
Fetches promotional ads for a category. |
get_recommendations(product_id) |
Returns product recommendations. |
add_to_cart(user_id, product_id, quantity) |
Adds an item to a user's cart. |
get_cart(user_id) |
Retrieves a user's cart. |
empty_cart(user_id) |
Empties a user's cart. |
checkout(checkout_person) |
Performs checkout for a user's cart. |
get_supported_currencies() |
Lists supported currencies. |
get_shipping_quote(items, currency_code, address) |
Returns a shipping quote. |
MCP clients connect to the streamable HTTP endpoint:
http://${MCP_ENDPOINT}:${MCP_PORT}/mcp
The service is configured with environment variables. Values can be supplied
through Docker Compose, .env, .env.override, or the local shell environment.
| Variable | Default | Description |
|---|---|---|
MCP_PORT |
8011 |
Port used by the FastMCP HTTP server. |
MCP_ENDPOINT |
mcp in Compose |
Service hostname used by other demo services (e.g. agent). |
APPLICATION_ENDPOINT |
frontend:8080 in Compose |
Frontend/API endpoint used by the shop tools. |
OTEL_EXPORTER_OTLP_ENDPOINT |
localhost:4317 |
OTLP endpoint used by Traceloop/OpenTelemetry. In Compose this points to the OpenTelemetry Collector. |
OTEL_EXPORTER_OTLP_INSECURE |
unset | Set to true in Compose for insecure local OTLP export. |
OTEL_RESOURCE_ATTRIBUTES |
inherited | Additional OpenTelemetry resource attributes (Compose adds service.criticality=low). |
OTEL_SERVICE_NAME |
AstronomyShopAgentMCP |
Service name used in telemetry. |
In compose.agent.yml, the service is named mcp and is built from src/mcp/Dockerfile.
Important Compose settings:
- Image:
${IMAGE_NAME}:${DEMO_VERSION}-mcp - Container name:
mcp - Dockerfile:
${MCP_DOCKERFILE} - Memory limit:
500M - Restart policy:
unless-stopped - Exposed port:
${MCP_PORT} - Depends on:
agent
The agent service enables MCP usage via:
MCP_ENABLED=True
MCP_ENDPOINT=mcp
MCP_PORT=8011
When MCP_ENABLED=True on the agent side, the agent loads its tools from this
MCP service instead of using its own built-in tools.
run.py initializes Traceloop with:
- Application name:
mcp - API endpoint:
OTEL_EXPORTER_OTLP_ENDPOINT, defaulting tolocalhost:4317
The HTTPXClientInstrumentor is enabled so that outbound calls to the frontend
(made by the shop tools) are traced. In Docker Compose, telemetry is sent to
the local OpenTelemetry Collector and the service name is set to mcp.
From the repository root, create or activate a Python environment, then install dependencies:
pip install -r src/mcp/requirements.txtBecause the service imports the shop tools from the agent source tree
(the Dockerfile copies src/agent/src/agents/tools.py into src/mcp_server/),
make the same file available locally before running:
cp src/shared/tools.py src/mcp/src/mcp_server/tools.pyRun the service locally:
cd src/mcp
MCP_PORT=8011 \
APPLICATION_ENDPOINT=localhost:8080 \
OTEL_EXPORTER_OTLP_ENDPOINT=localhost:4317 \
python run.pyThe MCP endpoint will be available at http://localhost:8011/mcp.
From the repository root, build the service image:
make buildOr build only this service through Compose:
docker compose build mcp
docker compose up mcpYou can verify the MCP server is reachable with any MCP client. A quick smoke
test using curl against the streamable HTTP transport:
curl -i http://localhost:8011/mcpA 4xx response with MCP-specific headers indicates the server is up; full
interaction requires a proper MCP client (such as the agent service
with MCP_ENABLED=True, or langchain_mcp_adapters).
src/mcp/
|-- Dockerfile
|-- README.md
|-- requirements.txt
|-- requirements.in
|-- run.py # Entry point: Traceloop init + FastMCP server
`-- src/
`-- mcp_server/
|-- astronomy_shop_mcp_server.py # FastMCP server and tool registration