mcp-streaming-msk-bedrock

mcp-streaming-msk-bedrock

Streams real-time log context from Amazon MSK to a Bedrock AI agent for anomaly detection and root cause analysis. Enables AI-powered monitoring with WebSocket push and IAM authorization.

Category
Visit Server

README

MCP Streaming Demo — Amazon MSK + Bedrock Agents

A working demo of Streaming MCP (Model Context Protocol) on AWS — pushing real-time context to a Bedrock-powered AI agent using Amazon MSK, WebSockets, and IAM authorization.

Based on mcp-streaming-demo, adapted to use managed AWS services.

Architecture

log_simulator.py → Amazon MSK (app-logs) → streaming_mcp_server.py → bedrock_agent.py
                                                   ↕ WebSocket              ↕
                                          subscribe / get_anomalies    Bedrock Claude
                                                                      (invoke_model)

Lambda (Action Group) ← Bedrock Agent (managed) → MSK

Components

File Description
src/streaming_mcp_server.py Core server — MSK consumer (IAM auth) + WebSocket push
src/bedrock_agent.py AI agent — subscribes to stream, invokes Bedrock for analysis
src/log_simulator.py Produces realistic log events to MSK
src/mock_kafka.py Patches for local dev without IAM auth
lambda/handler.py Bedrock Agent Action Group Lambda
lambda/api_schema.json OpenAPI schema for action group
infra/template.yaml CloudFormation — MSK Serverless + Bedrock Agent + Lambda
docker-compose.yml Local Kafka for development

Prerequisites

  • Python 3.9+
  • AWS account with Bedrock model access (Claude 3 Sonnet)
  • AWS CLI configured with appropriate credentials
  • Docker (for local development)

Quick Start (Local Dev)

# 1. Start local Kafka
docker compose up -d

# 2. Install dependencies
pip install -r requirements.txt

# 3. Start server (local mode)
MSK_BOOTSTRAP=localhost:9092 python src/streaming_mcp_server.py

# 4. Start log simulator (separate terminal)
MSK_BOOTSTRAP=localhost:9092 python src/log_simulator.py

# 5. Start Bedrock agent (separate terminal)
python src/bedrock_agent.py

Deploy to AWS

# 1. Deploy infrastructure
aws cloudformation deploy \
  --template-file infra/template.yaml \
  --stack-name mcp-streaming-demo \
  --parameter-overrides VpcId=vpc-xxx SubnetIds=subnet-aaa,subnet-bbb \
  --capabilities CAPABILITY_NAMED_IAM

# 2. Get MSK bootstrap servers
aws kafka get-bootstrap-brokers --cluster-arn <ClusterArn from outputs>

# 3. Store bootstrap in SSM (used by Lambda)
aws ssm put-parameter --name /mcp-demo/msk-bootstrap --value "<bootstrap-servers>" --type String

# 4. Run server and simulator with MSK endpoint
export MSK_BOOTSTRAP="<bootstrap-servers>"
python src/streaming_mcp_server.py
python src/log_simulator.py
python src/bedrock_agent.py

Key Differences from Original

Original This Version
Local Kafka (Docker) Amazon MSK Serverless
Custom Python agent Bedrock Agent + direct invoke_model client
No auth IAM OAUTHBEARER (MSK) + IAM roles (Bedrock)
Manual remediation mapping Claude-powered root cause analysis
docker-compose only CloudFormation IaC

What You'll See

  1. Normal log traffic flowing through the agent in real-time
  2. Every ~30 seconds, an error spike hits
  3. The agent detects the spike (>30% error rate in sliding window)
  4. Bedrock Claude analyzes the errors and provides root cause + remediation

Teardown

# Local
docker compose down -v

# AWS
aws cloudformation delete-stack --stack-name mcp-streaming-demo

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured