Skip to content

kiryazovi-redis/redis-test-mcp-tools

Repository files navigation

Redis Test MCP Tools

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.

Python 3.10+ MCP Compatible MIT License

Features

  • 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

Installation

Prerequisites

  • Python 3.10 or higher
  • pip (Python package installer)

Install from Source

# 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]

Quick Start

Command Line Usage

# 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 5

MCP Client Integration

Add to your MCP client configuration:

{
  "servers": {
    "redis-test-mcp": {
      "command": "redis-test-mcp",
      "args": ["--debug"]
    }
  }
}

Available Tools

The server provides 14 specialized tools organized into three main categories:

πŸ“ File System Tools (4 tools)

find_python_files

List all Python files in the project with metadata.

Parameters:

  • directory (optional): Directory to search in (relative to project root)

Example:

{"directory": "redis/"}

read_file

Read the contents of a file with size limits.

Parameters:

  • file_path (required): Path to the file to read
  • max_size (optional): Maximum file size in bytes (default: 1MB)

Example:

{"file_path": "redis/client.py", "max_size": 2048000}

get_directory_structure

Show the directory structure of the project as a tree.

Parameters:

  • directory (optional): Directory to show structure for
  • max_depth (optional): Maximum depth to traverse (default: 3)

Example:

{"directory": "tests/", "max_depth": 2}

get_project_info

Get comprehensive information about the project including structure, dependencies, and metadata.

Parameters:

  • random_string (required): Dummy parameter for no-parameter tools

πŸ” AST Parsing Tools (5 tools)

parse_module

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_function_details

Get detailed information about a specific function including parameters, return type, and docstring.

Parameters:

  • file_path (required): Path to the Python file
  • function_name (required): Name of the function to analyze

Example:

{"file_path": "redis/client.py", "function_name": "execute_command"}

get_class_details

Get class methods, properties, and inheritance information.

Parameters:

  • file_path (required): Path to the Python file
  • class_name (required): Name of the class to analyze

Example:

{"file_path": "redis/client.py", "class_name": "Redis"}

find_imports

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"}

get_type_hints

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"}

πŸ§ͺ Test Analysis Tools (5 tools)

analyze_test_files

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/"}

get_test_patterns

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/"}

find_untested_code

Compare source files with test files to find untested functions and classes.

Parameters:

  • source_dir (optional): Source directory to analyze
  • test_dir (optional): Test directory for comparison (default: 'tests')

Example:

{"source_dir": "redis/", "test_dir": "tests/"}

suggest_test_cases

Generate test case suggestions based on function signatures and docstrings.

Parameters:

  • file_path (required): Path to the Python file to analyze
  • function_name (optional): Specific function to generate suggestions for
  • class_name (optional): Specific class to generate suggestions for
  • framework (optional): Testing framework ('pytest' or 'unittest')

Example:

{
  "file_path": "redis/connection.py", 
  "function_name": "connect",
  "framework": "pytest"
}

get_test_coverage_info

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"}

Configuration

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

Development

Setup Development Environment

# 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]

Running Tests

# Run all tests
pytest

# Run with coverage
pytest --cov=redis_test_mcp_tools

# Run specific test categories
pytest -m unit
pytest -m integration

Code Quality

# Format code
black src/ tests/

# Sort imports
isort src/ tests/

# Type checking
mypy src/

Project Structure

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

Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Make your changes
  4. Add tests for new functionality
  5. Ensure all tests pass (pytest)
  6. Commit your changes (git commit -m 'Add amazing feature')
  7. Push to the branch (git push origin feature/amazing-feature)
  8. Open a Pull Request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Related Projects

Support


Made with ❀️ for the Redis-py community

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages