-
Notifications
You must be signed in to change notification settings - Fork 1
Add support for using tools via MCP servers #24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Add support for configuring MCP (Model Context Protocol) servers in the agent's config.py file. This allows the agent to connect to MCP servers and use their tools with optional filtering and overrides. New features: - MCPToolConfig: Configure capability and description overrides for individual MCP tools - MCPServerConfig: Configure MCP server connection (command/args for stdio, or URL for HTTP transport) with optional tool filtering - mcp_servers setting in Settings class for defining multiple MCP servers - MCPToolProvider: Dynamic tool provider that connects to MCP servers, discovers tools, and exposes them to the agent - ToolManager integration to automatically load MCP providers from config The MCP provider supports: - Stdio transport (command + args) - HTTP/SSE transport (url) - Tool filtering via 'tools' mapping - Capability overrides per tool - Description overrides per tool Tests added: - 9 tests for MCP config models - 13 tests for MCP tool provider
- Add mcp package as a project dependency - Implement _connect() with stdio and SSE transport support - Implement tool discovery from MCP server via list_tools() - Implement _call_mcp_tool() to invoke tools on the MCP server - Handle MCP tool results including text, structured content, images, and embedded resources - Update tests to avoid hanging on actual MCP connections - Rename test directory from mcp to mcp_provider to avoid import conflicts The MCP provider now fully supports: - Connecting to MCP servers via stdio (command + args) or SSE (url) - Discovering and listing available tools from the server - Filtering tools based on configuration - Calling tools and parsing responses - Automatic cleanup on disconnection
This adds an MCP server that allows other AI agents to use the Redis SRE Agent's capabilities via the Model Context Protocol. The server exposes the following tools: - triage: Start a Redis troubleshooting session with the SRE agent - knowledge_search: Search Redis documentation, runbooks, and best practices - list_instances: List all configured Redis instances (sensitive data masked) - create_instance: Register a new Redis instance configuration The server supports two transport modes: - stdio: For integration with Claude Desktop, Cursor, and other MCP clients - SSE: For HTTP-based access CLI commands: - redis-sre-agent mcp serve [--transport stdio|sse] [--host HOST] [--port PORT] - redis-sre-agent mcp list-tools This enables multi-agent workflows where other AI assistants can delegate Redis troubleshooting and operations to the specialized SRE agent.
In stdio mode, stdout must only contain valid JSON-RPC messages. The 'Starting MCP server...' message was corrupting the protocol.
These tools allow MCP clients (like Claude) to check on the progress and results of triage requests: - get_thread: Retrieve thread contents including messages, tool calls, and results. Use this after a triage to see the full conversation. - get_task_status: Check if a background task is still running, completed, or failed. Use this to poll for task completion. This enables Claude to follow up on triage requests by checking task status and retrieving final results from the thread.
Updated tool descriptions to clearly explain: - The 3-step triage workflow (triage → poll status → get results) - What each tool returns and how to use the return values - Status values and their meanings - Polling recommendations (every 5-10 seconds) Also added comprehensive server instructions that explain: - Complete triage workflow with examples - When to use each tool - Tips for effective usage
Docker Compose exposes the API on host port 8080 (mapped to container port 8000), while local uvicorn development uses port 8000 directly. Updated docs to: - Use port 8080 in Docker Compose examples - Add notes clarifying which port to use in each context - Keep port 8000 for local development examples (local-dev.md, vm-deployment.md)
Add Streamable HTTP transport support so Claude can connect to an already-running MCP server via the Custom Connectors feature. Usage: 1. Start the agent: docker compose up -d 2. Start MCP server: redis-sre-agent mcp serve --transport http --port 8081 3. In Claude: Settings > Connectors > Add Custom Connector URL: http://your-host:8081/mcp Changes: - Add run_http() and get_http_app() functions to server.py - Update CLI with --transport http option (now default port 8081) - Update CLI help to show HTTP mode as recommended for remote access - Use streamable_http_app() method from FastMCP The HTTP transport is recommended over SSE for new deployments.
Adds sre-mcp service that runs the MCP server in HTTP mode on port 8081. To connect Claude to the running agent: 1. docker compose up -d 2. In Claude: Settings > Connectors > Add Custom Connector URL: http://localhost:8081/mcp
Adds nginx-based SSL termination for the MCP server: Setup: 1. Generate certs: ./scripts/generate-mcp-certs.sh 2. Start with SSL: docker compose --profile ssl up -d 3. Connect Claude to: https://localhost:8443/mcp Files added: - scripts/generate-mcp-certs.sh - Generates self-signed certs - monitoring/nginx/mcp-ssl.conf - nginx config for SSL proxy - sre-mcp-ssl service in docker-compose (uses 'ssl' profile) The SSL proxy is optional - use --profile ssl to enable it. HTTP still works at http://localhost:8081/mcp
Using a variable for proxy_pass forces nginx to resolve the hostname at runtime instead of startup, which avoids the 'host not found' error when sre-mcp isn't up yet.
1. Redis healthcheck now waits for loading:0 before marking healthy, preventing BusyLoadingError when worker starts too early 2. Removed emojis from worker error messages to avoid UnicodeEncodeError in Docker environments with limited encoding support
The MCP triage tool was only calling create_task() which creates the task record in Redis, but it wasn't submitting the task to Docket for actual processing. This is why tasks stayed in 'queued' status forever. Now matches the API behavior: after create_task(), open Docket and call docket.add(process_agent_turn) to queue the task for the worker.
- Add emitter parameter to ChatAgent._build_workflow() to enable progress notifications - Emit tool_call updates in ChatAgent.tool_node() before executing tools - Remove duplicate imports in docket_tasks.py (process_chat_turn, process_knowledge_query) - Remove unused API_BASE_URL and os import from mcp_server/server.py - Fix ASGI app initialization in mcp_server/server.py for uvicorn - Remove unused ThreadManager import from progress.py - Fix import ordering and remove unused imports across test files - Apply ruff format to all modified files
- Move StructuredTool and build_result_envelope imports to top of chat_agent.py
- Add tests for ChatAgent._build_workflow emitter parameter
- Add test for MCP provider description templating with {original} placeholder
- Apply ruff format to modified files
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds support for extending the agent with tools via MCP (Model Context Protocol) servers, allowing integration with external tools like GitHub, Slack, Prometheus, and Loki. It includes configuration for constrained tool sets with alternative descriptions and manual category assignments.
Key Changes:
- Implemented MCP tool provider infrastructure with dynamic server connections
- Added MCP server configuration with tool filtering and description overrides
- Created dedicated MCP server exposing agent capabilities to external clients
- Restructured thread/task data model to separate conversation history from progress updates
- Added version filtering for knowledge base documentation
Reviewed changes
Copilot reviewed 91 out of 93 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| redis_sre_agent/tools/mcp/provider.py | New MCP tool provider with server connection and tool discovery |
| redis_sre_agent/mcp_server/server.py | New MCP server implementation with FastMCP exposing agent tools |
| redis_sre_agent/core/threads.py | Refactored to separate messages from updates, deprecated result/error on Thread |
| redis_sre_agent/core/progress.py | New progress emission abstraction with TaskEmitter, MCPEmitter implementations |
| redis_sre_agent/core/config.py | Added MCPServerConfig and YAML configuration support |
| redis_sre_agent/tools/manager.py | Added MCP provider loading with category-based filtering |
| redis_sre_agent/core/docket_tasks.py | Added process_chat_turn and process_knowledge_query tasks for MCP |
| ui/src/services/sreAgentApi.ts | Refactored to use centralized API methods instead of raw fetch |
| redis_sre_agent/core/knowledge_helpers.py | Added offset and version parameters for pagination and version filtering |
| redis_sre_agent/core/redis.py | Added version field to knowledge index and recreate_indices helper |
Comments suppressed due to low confidence (8)
redis_sre_agent/mcp_server/server.py:1
- The docstring table uses inconsistent pipe character formatting. The table should use standard markdown table syntax with properly aligned pipes for better readability.
redis_sre_agent/core/threads.py:1 - The
rolefield type is inconsistent with the context_excerpt which showsOptional[str]. This file defines it asstrwith a default, but the existing code may expectOptional[str]. This could cause validation errors when deserializing old data that hasrole=None.
redis_sre_agent/core/config.py:1 - Use a named constant for the magic number calculation (e.g.,
SECONDS_PER_DAY = 86400) to improve readability and maintainability.
ui/src/services/sreAgentApi.ts:1 - The fallback to
status.metadata.updated_atmay fail ifstatus.metadatais undefined. Add null-safe access using optional chaining:status.metadata?.updated_at.
ui/src/pages/Schedules.tsx:1 parseIntcan returnNaNif the input is invalid. This should be validated before submitting to the API, or the error should be caught and displayed to the user with a clear message like "Interval value must be a valid number".
ui/src/pages/Schedules.tsx:1parseIntcan returnNaNif the input is invalid. This should be validated before submitting to the API, or the error should be caught and displayed to the user with a clear message like "Interval value must be a valid number".
redis_sre_agent/tools/knowledge/knowledge_base.py:1- The hardcoded list of available versions ('7.8', '7.4', '7.2') in the description will become stale as new versions are released. Consider dynamically generating this list or referencing a configuration source, or add a comment noting that this needs manual updates.
redis_sre_agent/core/knowledge_helpers.py:1 - Fetching
limit + offsetresults and then slicing introduces unnecessary overhead for large offsets. This means fetching 1000 results to return 10 when offset=990. Consider implementing true offset support in the query layer or documenting this limitation for large offsets.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Add \\b markers in query command docstring for proper list formatting - Add \\b markers in mcp serve command docstring for tools list and examples - Regenerate CLI reference docs
- Add --agent/-a option with choices: auto, triage, chat, knowledge - Default to 'auto' which uses the router to select the agent - Update help text to document all agent types - Add comprehensive tests for each agent selection mode - Regenerate CLI reference docs
Tests were hanging in CI because they tried to connect to Redis. Added fixtures for mock_thread_manager and mock_redis_client, and patched get_redis_client and ThreadManager in all test functions.
Add support for extending the agent with tools using MCP servers. Allows defining constrained sets of tools with alternative descriptions and manual category assignments (metrics, etc.).