Skip to main content
Glama
xieyongliang

Monitoring MCP Demo

by xieyongliang

Monitoring MCP Demo

This is a minimal runnable example for a Managed Agent monitoring POC.

For the full walkthrough and verified AWS E2E result, see docs/managed-agent-monitoring-poc.md.

For external AWS MCP deployment, HTTPS authentication, and MA Cloud integration, see Accessing an External AWS Monitoring MCP Server from MA (English) or the Chinese version.

The demo has two layers:

  • tools.py: provider-specific monitoring functions. It can run without MCP.

  • server.py: exposes the same functions as MCP tools through streamable-http.

Run the local tool test

python3 -m venv .venv
.venv/bin/python -m pip install -r requirements.txt
.venv/bin/python test_tools.py

Expected behavior:

  • returns mock alarms, metrics, and logs

  • produces a deterministic incident triage summary

Related MCP server: CloudWatch MCP Agent

Start the MCP server

Install the MCP package first:

.venv/bin/python -m pip install -r requirements.txt

Then start the server:

.venv/bin/python server.py

In another terminal, call the MCP tools:

.venv/bin/python client_test.py --provider mock

For Managed Agent integration, deploy this server as a public HTTPS service that MA can reach. Localhost is useful for development, but MA cloud sessions cannot access a developer laptop localhost directly.

Replace mock data with AWS

The tool supports AWS through boto3, with an AWS CLI fallback.

Then run:

AWS_ACCESS_KEY_ID="..." \
AWS_SECRET_ACCESS_KEY="..." \
AWS_DEFAULT_REGION="ap-southeast-1" \
MOCK_MODE=0 .venv/bin/python server.py

In another terminal:

.venv/bin/python client_test.py \
  --provider aws \
  --region ap-southeast-1 \
  --log-group-name "/aws/ecs/your-service"

The first AWS version uses:

  • STS GetCallerIdentity

  • CloudWatch DescribeAlarms

  • CloudWatch Logs FilterLogEvents

After the target resource type is clear, add service-specific aws cloudwatch get-metric-data queries.

Full AWS E2E test

This creates temporary AWS resources, calls the MCP tools, then cleans up:

  • CloudWatch Logs log group and stream

  • one synthetic ERROR log event

  • one custom CloudWatch metric datapoint

  • one CloudWatch alarm forced into ALARM state for deterministic testing

AWS_ACCESS_KEY_ID="..." \
AWS_SECRET_ACCESS_KEY="..." \
AWS_DEFAULT_REGION="ap-southeast-1" \
.venv/bin/python aws_e2e_test.py

The alarm and log group are deleted at the end. CloudWatch custom metrics cannot be manually deleted; they expire automatically after retention.

BytePlus Cloud Monitor

The server also exposes get_byteplus_metric_data and get_byteplus_alert_groups, implemented in byteplus_tools.py using the official BytePlus SDK. Install the optional dependencies with:

.venv/bin/python -m pip install -r requirements-byteplus.txt

Configure BYTEPLUS_ACCESS_KEY, BYTEPLUS_SECRET_KEY, and, for temporary credentials, BYTEPLUS_SESSION_TOKEN in the MCP server environment. These are BytePlus cloud credentials, not a ModelArk API key. Do not include credentials in prompts or commit them to the repository.

See BytePlus monitoring setup and validation. These dedicated tools do not use the AWS/mock provider switch. BytePlus TLS log search is not implemented.

Related MCP Connectors

Related MCP Servers