A Model Context Protocol (MCP) server that provides comprehensive tools for analyzing and testing Redis-py project infrastructure. This server offers 14 specialized tools organized into three categories: file operations, AST parsing, and test analysis.
- File System Analysis: Navigate and explore Python projects with intelligent file discovery
- AST-based Code Analysis: Deep code structure analysis using Python's Abstract Syntax Tree
- Test Infrastructure Tools: Comprehensive test analysis, coverage reporting, and test case generation
- Redis-py Focused: Specialized tools designed for Redis-py project workflows
- MCP Integration: Seamless integration with MCP-compatible AI assistants and tools
- Python 3.10 or higher
- pip (Python package installer)
# Clone the repository
git clone https://github.com/redis/redis-py.git
cd redis-test-mcp-tools
# Create virtual environment (recommended)
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install in development mode
pip install -e .
# Or install with development dependencies
pip install -e .[dev]# Start the MCP server
redis-test-mcp
# With debug logging
redis-test-mcp --debug
# Custom configuration
redis-test-mcp --max-file-size 2048000 --max-depth 5Add to your MCP client configuration:
{
"servers": {
"redis-test-mcp": {
"command": "redis-test-mcp",
"args": ["--debug"]
}
}
}The server provides 14 specialized tools organized into three main categories:
List all Python files in the project with metadata.
Parameters:
directory(optional): Directory to search in (relative to project root)
Example:
{"directory": "redis/"}Read the contents of a file with size limits.
Parameters:
file_path(required): Path to the file to readmax_size(optional): Maximum file size in bytes (default: 1MB)
Example:
{"file_path": "redis/client.py", "max_size": 2048000}Show the directory structure of the project as a tree.
Parameters:
directory(optional): Directory to show structure formax_depth(optional): Maximum depth to traverse (default: 3)
Example:
{"directory": "tests/", "max_depth": 2}Get comprehensive information about the project including structure, dependencies, and metadata.
Parameters:
random_string(required): Dummy parameter for no-parameter tools
Parse a Python file and return classes, functions, and their signatures.
Parameters:
file_path(required): Path to the Python file to parse
Example:
{"file_path": "redis/connection.py"}Get detailed information about a specific function including parameters, return type, and docstring.
Parameters:
file_path(required): Path to the Python filefunction_name(required): Name of the function to analyze
Example:
{"file_path": "redis/client.py", "function_name": "execute_command"}Get class methods, properties, and inheritance information.
Parameters:
file_path(required): Path to the Python fileclass_name(required): Name of the class to analyze
Example:
{"file_path": "redis/client.py", "class_name": "Redis"}Show what modules and packages a file imports.
Parameters:
file_path(required): Path to the Python file to analyze
Example:
{"file_path": "redis/__init__.py"}Extract type annotations from functions and methods in a Python file.
Parameters:
file_path(required): Path to the Python file
Example:
{"file_path": "redis/typing.py"}Find and parse existing test files, showing test structure including fixtures, markers, and test functions.
Parameters:
directory(optional): Directory to search for test files
Example:
{"directory": "tests/"}Identify common testing patterns used in the project (fixtures, mocks, frameworks, etc.).
Parameters:
directory(optional): Directory to analyze for test patterns
Example:
{"directory": "tests/test_asyncio/"}Compare source files with test files to find untested functions and classes.
Parameters:
source_dir(optional): Source directory to analyzetest_dir(optional): Test directory for comparison (default: 'tests')
Example:
{"source_dir": "redis/", "test_dir": "tests/"}Generate test case suggestions based on function signatures and docstrings.
Parameters:
file_path(required): Path to the Python file to analyzefunction_name(optional): Specific function to generate suggestions forclass_name(optional): Specific class to generate suggestions forframework(optional): Testing framework ('pytest' or 'unittest')
Example:
{
"file_path": "redis/connection.py",
"function_name": "connect",
"framework": "pytest"
}Parse and show coverage information from pytest-cov data.
Parameters:
coverage_file(optional): Path to coverage file (searches common locations if not specified)
Example:
{"coverage_file": ".coverage"}The server can be configured through command-line arguments:
redis-test-mcp [OPTIONS]
Options:
--debug Enable debug logging
--max-file-size INT Maximum file size to read in bytes (default: 1MB)
--max-depth INT Maximum directory depth to traverse (default: 3)
--help Show help message# Clone and setup
git clone https://github.com/redis/redis-py.git
cd redis-test-mcp-tools
# Create virtual environment
python -m venv venv
source venv/bin/activate
# Install in development mode with all dependencies
pip install -e .[dev]# Run all tests
pytest
# Run with coverage
pytest --cov=redis_test_mcp_tools
# Run specific test categories
pytest -m unit
pytest -m integration# Format code
black src/ tests/
# Sort imports
isort src/ tests/
# Type checking
mypy src/redis-test-mcp-tools/
βββ src/
β βββ redis_test_mcp_tools/
β βββ main.py # Entry point
β βββ server.py # MCP server implementation
β βββ config.py # Configuration management
β βββ tools/ # Tool implementations
β βββ ast_tools.py # AST parsing tools
β βββ file_tools.py # File system tools
β βββ test_tools.py # Test analysis tools
βββ tests/ # Test suite
βββ docs/ # Documentation
βββ examples/ # Usage examples
βββ pyproject.toml # Project configuration
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Make your changes
- Add tests for new functionality
- Ensure all tests pass (
pytest) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Redis-py - The Redis Python client
- Model Context Protocol - Protocol for AI assistant integrations
- π Documentation
- π Issue Tracker
- π¬ Discussions
Made with β€οΈ for the Redis-py community