Skip to content

Commit 28523cc

Browse files
authored
Merge pull request #24 from redis-applied-ai/feature/mcp-server-support
Add support for using tools via MCP servers and connecting to the SRE agent via MCP
2 parents 1a1be72 + 31316f9 commit 28523cc

File tree

93 files changed

+8840
-771
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

93 files changed

+8840
-771
lines changed

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,3 +133,8 @@ artifacts/
133133
ui/node_modules/
134134
ui/ui-kit/node_modules/
135135
ui/test-results/
136+
137+
# SSL certificates (generated locally)
138+
monitoring/nginx/certs/
139+
config.yaml
140+
eval_reports

Dockerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ RUN --mount=type=cache,target=/root/.cache/uv \
4747
# This is the final image. It will be much smaller.
4848
FROM python:3.12-slim
4949

50+
# Copy uv from the official image for runtime use (needed by entrypoint)
51+
COPY --from=ghcr.io/astral-sh/uv:latest /uv /bin/uv
52+
5053
WORKDIR /app
5154

5255
# Install ONLY runtime system dependencies

config.yaml.example

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
# Redis SRE Agent Configuration
2+
# Copy this file to config.yaml and customize for your environment.
3+
#
4+
# Settings can be loaded from (priority order):
5+
# 1. Environment variables (highest priority)
6+
# 2. .env file
7+
# 3. config.yaml (this file)
8+
# 4. Default values (lowest priority)
9+
#
10+
# Set SRE_AGENT_CONFIG environment variable to use a custom path.
11+
12+
# Application settings
13+
# debug: false
14+
# log_level: INFO
15+
16+
# Server settings
17+
# host: "0.0.0.0"
18+
# port: 8000
19+
20+
# MCP (Model Context Protocol) servers configuration
21+
# This is the primary use case for YAML config - complex nested structures
22+
mcp_servers:
23+
# Memory server for long-term agent memory
24+
redis-memory-server:
25+
command: uv
26+
args:
27+
- tool
28+
- run
29+
- --from
30+
- agent-memory-server
31+
- agent-memory
32+
- mcp
33+
env:
34+
REDIS_URL: redis://localhost:6399
35+
tools:
36+
get_current_datetime:
37+
description: |
38+
Get the current date and time. Use this when you need to
39+
record timestamps for Redis instance events or incidents.
40+
41+
{original}
42+
create_long_term_memories:
43+
description: |
44+
Save long-term memories about Redis instances. Use this to
45+
record: past incidents and their resolutions, configuration
46+
changes, performance baselines, known issues, maintenance
47+
history, and lessons learned. Always include the instance_id
48+
in the memory text for future retrieval.
49+
50+
{original}
51+
search_long_term_memory:
52+
description: |
53+
Search saved memories about Redis instances. ALWAYS use this
54+
before troubleshooting a Redis instance to recall past issues,
55+
solutions, and context. Search by instance_id, error patterns,
56+
or symptoms.
57+
58+
{original}
59+
get_long_term_memory:
60+
description: |
61+
Retrieve a specific memory by ID. Use this to get full details
62+
of a memory found via search.
63+
64+
{original}
65+
edit_long_term_memory:
66+
description: |
67+
Update an existing memory. Use this to add new information to
68+
a past incident record, update resolution status, or correct
69+
outdated information.
70+
71+
{original}
72+
delete_long_term_memories:
73+
description: |
74+
Delete memories that are no longer relevant. Use sparingly -
75+
prefer editing to add context rather than deleting.
76+
77+
{original}
78+
79+
# GitHub MCP server for repository operations
80+
# Option 1: Local Docker (requires Docker to be running)
81+
github:
82+
command: docker
83+
args:
84+
- run
85+
- -i
86+
- --rm
87+
- -e
88+
- GITHUB_PERSONAL_ACCESS_TOKEN
89+
- ghcr.io/github/github-mcp-server
90+
env:
91+
# Set your GitHub Personal Access Token here or via environment variable
92+
GITHUB_PERSONAL_ACCESS_TOKEN: ${GITHUB_PERSONAL_ACCESS_TOKEN}
93+
94+
# Option 2: Remote GitHub MCP server (recommended, no Docker needed)
95+
# Uncomment the following and comment out the local Docker option above:
96+
# github:
97+
# url: "https://api.githubcopilot.com/mcp/"
98+
# headers:
99+
# Authorization: "Bearer ${GITHUB_PERSONAL_ACCESS_TOKEN}"
100+
# # transport: streamable_http # default, uses Streamable HTTP protocol
101+
102+
# Tool providers configuration (fully qualified class paths)
103+
# tool_providers:
104+
# - redis_sre_agent.tools.metrics.prometheus.provider.PrometheusToolProvider
105+
# - redis_sre_agent.tools.diagnostics.redis_command.provider.RedisCommandToolProvider
106+
# - redis_sre_agent.tools.logs.loki.provider.LokiToolProvider
107+
# - redis_sre_agent.tools.host_telemetry.provider.HostTelemetryToolProvider

docker-compose.test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ services:
8787
context: .
8888
dockerfile: Dockerfile
8989
ports:
90-
- "8000:8000"
90+
- "8080:8000"
9191
environment:
9292
- REDIS_URL=redis://redis-demo:6379/0 # Internal container port stays 6379
9393
- PROMETHEUS_URL=http://prometheus:9090

docker-compose.yml

Lines changed: 71 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,12 @@ services:
99
- ./monitoring/redis.conf:/usr/local/etc/redis/redis.conf
1010
command: redis-server /usr/local/etc/redis/redis.conf
1111
healthcheck:
12-
test: ["CMD", "redis-cli", "ping"]
13-
interval: 10s
12+
# Wait for Redis to finish loading before marking healthy
13+
test: ["CMD-SHELL", "redis-cli ping | grep -q PONG && redis-cli INFO persistence | grep -q 'loading:0'"]
14+
interval: 5s
1415
timeout: 5s
15-
retries: 3
16+
retries: 10
17+
start_period: 10s
1618
networks:
1719
- sre-network
1820

@@ -273,7 +275,7 @@ services:
273275
context: .
274276
dockerfile: Dockerfile
275277
ports:
276-
- "8000:8000"
278+
- "8080:8000"
277279
environment:
278280
- REDIS_URL=redis://redis:6379/0 # Internal container port stays 6379
279281
- TOOLS_PROMETHEUS_URL=http://prometheus:9090
@@ -327,6 +329,71 @@ services:
327329
networks:
328330
- sre-network
329331

332+
# GitHub MCP Server - Exposes GitHub tools via MCP
333+
# This runs the GitHub MCP server behind an SSE/HTTP proxy so the sre-worker
334+
# can connect to it without needing Docker-in-Docker permissions.
335+
github-mcp:
336+
image: ghcr.io/sparfenyuk/mcp-proxy:latest
337+
ports:
338+
- "8082:8082"
339+
environment:
340+
- GITHUB_PERSONAL_ACCESS_TOKEN=${GITHUB_PERSONAL_ACCESS_TOKEN}
341+
command: >
342+
--pass-environment
343+
--port=8082
344+
--host=0.0.0.0
345+
docker run -i --rm -e GITHUB_PERSONAL_ACCESS_TOKEN ghcr.io/github/github-mcp-server
346+
volumes:
347+
- /var/run/docker.sock:/var/run/docker.sock
348+
networks:
349+
- sre-network
350+
profiles:
351+
- mcp # Start with: docker compose --profile mcp up
352+
353+
# SRE Agent MCP Server - Exposes agent capabilities via Model Context Protocol
354+
# Connect Claude to this via: Settings > Connectors > Add Custom Connector
355+
# HTTP: http://localhost:8081/mcp
356+
# HTTPS: https://localhost:8450/mcp (requires running scripts/generate-mcp-certs.sh first)
357+
sre-mcp:
358+
build:
359+
context: .
360+
dockerfile: Dockerfile
361+
ports:
362+
- "8081:8081"
363+
environment:
364+
- REDIS_URL=redis://redis:6379/0
365+
- REDIS_SRE_MASTER_KEY=${REDIS_SRE_MASTER_KEY}
366+
- TOOLS_PROMETHEUS_URL=http://prometheus:9090
367+
- TOOLS_LOKI_URL=http://loki:3100
368+
depends_on:
369+
redis:
370+
condition: service_healthy
371+
volumes:
372+
- .env:/app/.env
373+
- ./redis_sre_agent:/app/redis_sre_agent
374+
command: uv run redis-sre-agent mcp serve --transport http --host 0.0.0.0 --port 8081
375+
networks:
376+
- sre-network
377+
profiles:
378+
- mcp # Start with: docker compose --profile mcp up
379+
- ssl # Or with SSL: docker compose --profile ssl up
380+
381+
# MCP SSL Proxy - HTTPS termination for MCP server
382+
# Run scripts/generate-mcp-certs.sh first to generate self-signed certs
383+
sre-mcp-ssl:
384+
image: nginx:alpine
385+
ports:
386+
- "8450:443"
387+
volumes:
388+
- ./monitoring/nginx/mcp-ssl.conf:/etc/nginx/conf.d/default.conf:ro
389+
- ./monitoring/nginx/certs:/etc/nginx/certs:ro
390+
depends_on:
391+
- sre-mcp
392+
networks:
393+
- sre-network
394+
profiles:
395+
- ssl # Only start with: docker compose --profile ssl up
396+
330397
# SRE Agent UI
331398
sre-ui:
332399
build:

docs/concepts/core.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ This section explains the core ideas behind Redis SRE Agent and how pieces fit t
2727
When you create a task, the API creates or reuses a thread to store the execution history. You can:
2828
- Poll the task for status: `GET /api/v1/tasks/{task_id}`
2929
- Read the thread for results: `GET /api/v1/threads/{thread_id}`
30-
- Stream updates via WebSocket: `ws://localhost:8000/api/v1/ws/tasks/{thread_id}`
30+
- Stream updates via WebSocket: `ws://localhost:8080/api/v1/ws/tasks/{thread_id}` (Docker Compose) or port 8000 (local)
3131

3232
- **Jobs**
3333
- Ad-hoc jobs: On-demand via CLI or API. Each run creates a task and streams results to a thread.

0 commit comments

Comments
 (0)