Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .env.mcp
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# MCP Server Configuration
MCP_PORT=8811
PROMETHEUS_URL=http://prometheus:9090
GRAFANA_URL=http://grafana:3001
MODEL_RUNNER_URL=http://model-runner:12434
JAEGER_URL=http://jaeger:16686

# Docker Network
COMPOSE_PROJECT_NAME=genai-mcp
DOCKER_BUILDKIT=1
27 changes: 27 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -271,3 +271,30 @@ Contributions are welcome! Please feel free to submit a Pull Request.
3. Commit your changes (`git commit -m 'Add some amazing feature'`)
4. Push to the branch (`git push origin feature/amazing-feature`)
5. Open a Pull Request

## 🤖 MCP Integration

This project now includes Model Context Protocol (MCP) integration, enabling AI-powered monitoring through Claude Desktop.

### Features
- Real-time performance analysis through Claude
- AI-powered health recommendations
- Custom Prometheus query execution
- Intelligent resource optimization suggestions

### Quick Setup
```bash
# Build and start MCP integration
./start-mcp-stack.sh

# Configure Claude Desktop with the provided config
# Start asking Claude about your model performance!
```

For detailed MCP documentation, see [docs/mcp/README.md](docs/mcp/README.md).

### Example Claude Interactions
- "How is my model performing right now?"
- "Analyze GPU utilization and suggest optimizations"
- "Show me error patterns from the last hour"
- "What's the 95th percentile latency trend?"
39 changes: 39 additions & 0 deletions docker-compose.mcp-override.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
version: '3.8'

services:
mcp-metrics-server:
build:
context: ./mcp-metrics-server
dockerfile: Dockerfile
container_name: genai-mcp-metrics
environment:
- PROMETHEUS_URL=http://prometheus:9090
- GRAFANA_URL=http://grafana:3001
- MODEL_RUNNER_URL=http://model-runner:12434
- JAEGER_URL=http://jaeger:16686
- MCP_PORT=8811
ports:
- "8811:8811"
depends_on:
- prometheus
- grafana
networks:
- default
restart: unless-stopped
healthcheck:
test: ["CMD-SHELL", "nc -z localhost 8811 || exit 1"]
interval: 30s
timeout: 10s
retries: 3

# Optional: Add a dedicated stdio bridge if needed
mcp-bridge:
build:
context: ./mcp-stdio-bridge
dockerfile: Dockerfile
environment:
- TARGET_HOST=mcp-metrics-server
- TARGET_PORT=8811
depends_on:
- mcp-metrics-server
restart: unless-stopped
77 changes: 77 additions & 0 deletions docs/mcp/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# GenAI Model Runner MCP Integration

## Overview

This directory contains the Model Context Protocol (MCP) integration for the GenAI Model Runner metrics project. MCP enables AI-powered monitoring and analysis through Claude Desktop.

## Features

- **Real-time Performance Metrics**: Monitor model latency, throughput, and resource usage
- **AI-Powered Health Analysis**: Get intelligent insights about model health
- **Custom Prometheus Queries**: Execute and analyze PromQL queries through Claude
- **Automated Recommendations**: Receive optimization suggestions for performance and resources

## Quick Start

1. **Build the MCP server**:
```bash
cd mcp-metrics-server
npm install
npm run build
```

2. **Start the integrated stack**:
```bash
./start-mcp-stack.sh
```

3. **Configure Claude Desktop**:
Add to your Claude Desktop config:
```json
{
"mcpServers": {
"genai-metrics": {
"command": "docker",
"args": [
"run", "-i", "--rm", "--network=host",
"alpine/socat", "STDIO", "TCP:localhost:8811"
]
}
}
}
```

4. **Test the connection**:
```bash
./test-mcp-server.sh
```

## Available MCP Tools

### get_model_performance
Monitor real-time model performance metrics.

**Example**: "Show me the current model performance for the last 15 minutes"

### analyze_model_health
Get AI-powered health analysis with recommendations.

**Example**: "Analyze my model health and suggest optimizations"

### get_prometheus_query
Execute custom Prometheus queries.

**Example**: "Run this query: rate(http_requests_total[5m]) and explain the results"

## Architecture

```
Claude Desktop ←→ Socat Bridge ←→ MCP Server ←→ Prometheus/Grafana
```

## Support

For issues or questions about MCP integration:
1. Check the troubleshooting section in the main README
2. Review Docker logs: `docker logs genai-mcp-metrics`
3. Test connectivity: `./test-mcp-server.sh`
36 changes: 36 additions & 0 deletions grafana/dashboards/mcp-metrics-dashboard.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"dashboard": {
"title": "GenAI MCP Metrics Dashboard",
"tags": ["mcp", "genai", "metrics"],
"timezone": "browser",
"panels": [
{
"title": "Model Performance",
"type": "stat",
"targets": [
{
"expr": "histogram_quantile(0.95, rate(http_request_duration_seconds_bucket[5m]))",
"legendFormat": "95th percentile latency"
}
],
"gridPos": {"h": 8, "w": 12, "x": 0, "y": 0}
},
{
"title": "Request Rate",
"type": "graph",
"targets": [
{
"expr": "rate(model_requests_total[5m])",
"legendFormat": "Requests/sec"
}
],
"gridPos": {"h": 8, "w": 12, "x": 12, "y": 0}
}
],
"time": {
"from": "now-1h",
"to": "now"
},
"refresh": "5s"
}
}
26 changes: 26 additions & 0 deletions mcp-metrics-server/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
FROM node:18-alpine

WORKDIR /app

# Install dependencies
COPY package*.json ./
RUN npm install

# Copy source code
COPY src/ ./src/
COPY tsconfig.json ./

# Build TypeScript
RUN npm run build

# Install socat for TCP server functionality
RUN apk add --no-cache socat netcat-openbsd

# Create startup script
RUN echo '#!/bin/sh' > /app/start.sh && \
echo 'node dist/index.js | socat STDIO TCP-LISTEN:$MCP_PORT,reuseaddr,fork' >> /app/start.sh && \
chmod +x /app/start.sh

EXPOSE 8811

CMD ["/app/start.sh"]
21 changes: 21 additions & 0 deletions mcp-metrics-server/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"name": "genai-mcp-metrics-server",
"version": "1.0.0",
"description": "MCP server for GenAI model runner metrics",
"main": "dist/index.js",
"type": "module",
"scripts": {
"build": "tsc",
"start": "node dist/index.js",
"dev": "tsx src/index.ts"
},
"dependencies": {
"@modelcontextprotocol/sdk": "^0.5.0",
"axios": "^1.6.0"
},
"devDependencies": {
"@types/node": "^20.0.0",
"typescript": "^5.0.0",
"tsx": "^4.0.0"
}
}
Loading