A utility Model Context Protocol (MCP) server with remote repository support
Project description
Utility MCP Server
Description
A Model Context Protocol (MCP) server providing utility tools for development workflows. Built with Python and FastMCP, this server offers tools like automated release notes generation from git commits.
Features include structured logging, configuration management, multiple transport protocols (HTTP, SSE, streamable-HTTP), SSL support, and containerized deployment.
Code Structure
utility-mcp-server/
├── utility_mcp_server/ # Main package directory
│ ├── __init__.py
│ ├── src/ # Core source code
│ │ ├── __init__.py
│ │ ├── main.py # Application entry point & startup logic
│ │ ├── api.py # FastAPI application & transport setup
│ │ ├── mcp.py # MCP server implementation & tool registration
│ │ ├── settings.py # Pydantic-based configuration management
│ │ └── tools/ # MCP tool implementations
│ │ ├── __init__.py
│ │ ├── release_notes_tool.py # Release notes generation tool
│ │ └── assets/ # Static resource files
│ └── utils/ # Shared utilities
│ ├── __init__.py
│ └── pylogger.py # Structured logging with structlog
├── tests/ # Comprehensive test suite
│ ├── conftest.py # Pytest fixtures and configuration
│ ├── test_settings.py # Unit tests for configuration
│ ├── test_mcp.py # Unit tests for MCP server
│ ├── test_release_notes_tool.py # Unit tests for release notes tool
│ ├── test_api.py # Unit tests for API endpoints
│ ├── test_main.py # Unit tests for main module
│ └── test_integration.py # Integration tests
├── pyproject.toml # Project metadata & dependencies
├── Containerfile # Red Hat UBI-based container build
├── compose.yaml # Docker Compose orchestration
├── .env.example # Environment configuration template
├── .gitignore # Version control exclusions
├── .pre-commit-config.yaml # Code quality automation
└── README.md # Project documentation
Key Components
main.py: Application entry point with configuration validation, error handling, and uvicorn server startupapi.py: FastAPI application setup with transport protocol selection (HTTP/SSE/streamable-HTTP) and health endpointsmcp.py: Core MCP server class that registers tools using FastMCP decoratorssettings.py: Environment-based configuration using Pydantic BaseSettings with validationtools/: MCP tool implementations for utility operationsutils/pylogger.py: Structured JSON logging using structlog
Current MCP Tools
generate_release_notes: Generates structured release notes from git commits and tags- Remote Repository Support: Fetch commits from GitHub/GitLab via API (no local clone needed)
- Local Repository Support: Fallback to local git repositories via subprocess
- AI Agent Integration: Returns structured data for intelligent AI-driven categorization
- Provider Pattern: Extensible architecture for adding new git hosting services
Release Notes Tool
The generate_release_notes tool automatically creates comprehensive release notes from git commits. It supports both remote repositories (GitHub, GitLab) and local repositories, with optional AI agent integration for intelligent categorization.
Remote Repository Support
The tool can fetch commits directly from GitHub and GitLab repositories without requiring a local clone:
GitHub:
- Provide
repo_urllikehttps://github.com/owner/repo - Optionally provide
github_token(or setGITHUB_TOKENenvironment variable) - Uses PyGithub API to fetch commits and PR associations
GitLab:
- Provide
repo_urllikehttps://gitlab.com/owner/repo - Optionally provide
gitlab_token(or setGITLAB_TOKENenvironment variable) - Uses python-gitlab API to fetch commits and MR associations
Local Repository (fallback):
- Provide
repo_pathto a local git repository - Uses git subprocess commands
AI Agent Integration
The tool returns structured commit data with embedded AI instructions for intelligent categorization:
- Returns raw commit list with hashes, messages, authors, dates, and PR/MR numbers
- Includes
ai_instructionsfield with comprehensive guidance on categorization - Instructions travel with data - ensures consistent categorization across all AI agents
- AI creates dynamic categories based on actual changes instead of predefined patterns
- Better context understanding than regex-based categorization
Example response structure:
result = await generate_release_notes(
version="v1.0.0",
previous_version="v0.9.0",
repo_url="https://github.com/owner/repo"
)
# Returns:
{
"status": "success",
"data": {
"commits": [...],
"version": "v1.0.0",
...
},
"ai_instructions": {
"role": "release_notes_categorizer",
"task": "Analyze commits and create intelligent release notes",
"guidelines": [
"Create dynamic categories based on actual changes",
"Group related commits intelligently",
"Understand context beyond pattern matching",
...
],
"categorization_strategy": {...},
"suggested_sections": {...},
"output_format": {...}
}
}
Why instructions are embedded:
- ✅ Instructions version-controlled with tool
- ✅ Consistent categorization across all workflows
- ✅ Self-documenting - AI knows how to use the data
- ✅ No need to duplicate instructions in each workflow
See USE_CASES.md for detailed use cases and integration scenarios.
Installation
From PyPI (Recommended)
Install the package directly from PyPI:
# Using pip
pip install utility-mcp-server
# Using uv (recommended)
uv pip install utility-mcp-server
From Source
For development or to get the latest changes:
git clone https://github.com/redhat-data-and-ai/utility-mcp-server
cd utility-mcp-server
uv pip install -e .
Using with Cursor IDE
The MCP server integrates with Cursor IDE using the STDIO transport protocol.
Quick Setup
-
Install the package:
pip install utility-mcp-server
-
Configure Cursor:
- Open Cursor Settings (
Cmd+,on Mac /Ctrl+,on Windows/Linux) - Navigate to
Tools & Integrations→MCP Tools - Click
Add MCP Serverand add the following configuration:
{ "mcpServers": { "utility-mcp-server": { "command": "utility-mcp-server-stdio", "args": [] } } }
- Open Cursor Settings (
-
Restart Cursor to load the MCP server
Alternative Configuration (if command not in PATH)
If you encounter spawn utility-mcp-server-stdio ENOENT error:
{
"mcpServers": {
"utility-mcp-server": {
"command": "python",
"args": ["-m", "utility_mcp_server.src.stdio_main"]
}
}
}
Or with a virtual environment:
{
"mcpServers": {
"utility-mcp-server": {
"command": "/path/to/your/venv/bin/python",
"args": ["-m", "utility_mcp_server.src.stdio_main"]
}
}
}
For detailed setup instructions and troubleshooting, see CURSOR_SETUP.md.
Using with Claude Desktop
The MCP server can also be used with Claude Desktop application.
Setup
-
Install the package:
pip install utility-mcp-server
-
Locate the Claude Desktop config file:
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json - Windows:
%APPDATA%\Claude\claude_desktop_config.json - Linux:
~/.config/Claude/claude_desktop_config.json
- macOS:
-
Add the MCP server configuration:
{ "mcpServers": { "utility-mcp-server": { "command": "utility-mcp-server-stdio", "args": [] } } }
Or if the command is not in your PATH:
{ "mcpServers": { "utility-mcp-server": { "command": "python", "args": ["-m", "utility_mcp_server.src.stdio_main"] } } }
-
Restart Claude Desktop to load the MCP server
Using the Release Notes Tool
Once configured, you can use the generate_release_notes tool in your conversations:
"Generate release notes for version v1.0.0 comparing with v0.9.0 for the repository at /path/to/repo"
The tool will analyze git commits between the specified tags and generate structured release notes with categorized changes.
Usage Examples
Remote GitHub Repository
# Using with AI agent integration
result = await generate_release_notes(
version="v1.0.0",
previous_version="v0.9.0",
repo_url="https://github.com/owner/repo",
github_token=os.getenv('GITHUB_TOKEN'), # Optional, but recommended
return_raw_data=True # Returns structured data for AI processing
)
# Standard formatted output
result = await generate_release_notes(
version="v1.0.0",
previous_version="v0.9.0",
repo_url="https://github.com/owner/repo",
github_token=os.getenv('GITHUB_TOKEN')
)
Remote GitLab Repository
result = await generate_release_notes(
version="v2.0.0",
previous_version="v1.5.0",
repo_url="https://gitlab.com/owner/repo",
gitlab_token=os.getenv('GITLAB_TOKEN') # Optional for public repos
)
Local Repository
# Existing behavior - still fully supported
result = await generate_release_notes(
version="v1.0.0",
previous_version="v0.9.0",
repo_path="/path/to/local/repo"
)
Running as HTTP Server
For development, testing, or integration with other tools, you can run the MCP server as an HTTP service.
Prerequisites
- Python 3.12 or higher
- uv (fast Python package installer and resolver)
Setup
-
Install uv (if not already installed):
# On macOS/Linux: curl -LsSf https://astral.sh/uv/install.sh | sh # On MacOS using brew brew install uv # On Windows: powershell -c "irm https://astral.sh/uv/install.ps1 | iex" # Or with pip: pip install uv
-
Clone the repository:
git clone https://github.com/redhat-data-and-ai/utility-mcp-server cd utility-mcp-server
-
Create and activate a virtual environment with uv:
uv venv # Activate the virtual environment: # On macOS/Linux: source .venv/bin/activate # On Windows: .venv\Scripts\activate
-
Install the package and dependencies:
# Install in editable mode with all dependencies uv pip install -e .
-
Configure environment variables:
cp .env.example .env # Edit .env file with your configuration
-
Run the server:
# Using the installed console script utility-mcp-server # Or directly with Python module python -m utility_mcp_server.src.main # Or using uv to run directly uv run python -m utility_mcp_server.src.main
HTTP Server Configuration
The HTTP server configuration is managed through environment variables:
| Variable | Default | Description |
|---|---|---|
MCP_HOST |
0.0.0.0 |
Server bind address |
MCP_PORT |
3000 |
Server port (1024-65535) |
MCP_TRANSPORT_PROTOCOL |
streamable-http |
Transport protocol (http, sse, streamable-http) |
MCP_SSL_KEYFILE |
None |
SSL private key file path |
MCP_SSL_CERTFILE |
None |
SSL certificate file path |
PYTHON_LOG_LEVEL |
INFO |
Logging level (DEBUG, INFO, WARNING, ERROR, CRITICAL) |
Using Podman
-
Build and run with Podman Compose:
podman-compose up --build
-
Or build manually:
podman build -t utility-mcp-server . podman run -p 3000:3000 --env-file .env utility-mcp-server
Verify Installation
-
Health check:
curl http://localhost:3000/health -
Test MCP tools:
# List available tools via MCP endpoint curl -X POST "http://localhost:3000/mcp" \ -H "Content-Type: application/json" \ -d '{"method": "tools/list"}'
How to Test the Code Locally
Development Environment Setup
-
Install development dependencies:
uv pip install -e ".[dev]"
-
Install pre-commit hooks:
pre-commit install
Running Tests
The project includes a comprehensive test suite covering unit tests, integration tests, and various edge cases.
-
Run all tests:
pytest
-
Run tests with coverage reporting:
pytest --cov=utility_mcp_server --cov-report=html --cov-report=term
-
Run tests by category:
# Unit tests only pytest -m unit # Integration tests only pytest -m integration # Slow running tests pytest -m slow # Tests requiring network access pytest -m network
-
Run specific test modules:
# Test individual components pytest tests/test_settings.py -v pytest tests/test_mcp.py -v pytest tests/test_release_notes_tool.py -v # Run integration tests pytest tests/test_integration.py -v
-
Run tests with different output formats:
# Verbose output with detailed test names pytest -v # Short traceback format pytest --tb=short # Quiet output (minimal) pytest -q
Code Quality Checks
-
Linting and formatting with Ruff:
# Check for issues ruff check . # Auto-fix issues ruff check . --fix # Format code ruff format .
-
Type checking with MyPy:
mypy utility_mcp_server/ -
Docstring validation:
pydocstyle utility_mcp_server/ --convention=google
-
Run all pre-commit checks:
pre-commit run --all-files
Test Suite Overview
| Test Category | Description |
|---|---|
| Unit Tests | Individual component testing with mocking |
| Integration Tests | End-to-end workflow testing |
Test Files:
test_settings.py- Configuration, environment variables, validationtest_mcp.py- Server initialization, tool registration, error handlingtest_release_notes_tool.py- Release notes generation tool functionalitytest_api.py- API endpoints and health checkstest_main.py- Main module and server startuptest_integration.py- Complete workflows and system integration
Manual Testing
-
Container testing:
docker-compose up -d curl -f http://localhost:3000/health docker-compose down
-
SSL testing (if configured):
curl -k https://localhost:3000/health
Continuous Integration
GitHub Actions runs automated CI on push and PRs:
- Multi-Python version testing (3.12, 3.13)
- Test suite execution with coverage reporting
- Ruff linting and MyPy type checking
- Bandit security scanning
Running CI Checks Locally
# Run all pre-commit checks
pre-commit run --all-files
# Run tests with coverage
pytest --cov=utility_mcp_server --cov-fail-under=80
# Run security checks
bandit -r utility_mcp_server/
How to Contribute
Development Workflow
- Fork and clone the repository
- Create a feature branch:
git checkout -b feature/your-feature-name - Set up development environment:
uv venv && source .venv/bin/activate uv pip install -e ".[dev]" pre-commit install
- Make changes and run tests:
pytest --cov=utility_mcp_server - Run pre-commit checks:
pre-commit run --all-files - Commit and push, then create a Pull Request
Coding Standards
- Follow PEP 8 (enforced by Ruff)
- Type annotations for public functions
- Google-style docstrings
- Conventional commit format (
feat:,fix:,docs:, etc.)
Adding New Tools
- Create a tool module in
utility_mcp_server/src/tools/ - Register the tool in
utility_mcp_server/src/mcp.pyusingself.mcp.tool()(your_function) - Add tests in
tests/ - Update documentation
Getting Help
Open GitHub issues for bugs or feature requests.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file utility_mcp_server-0.2.0.tar.gz.
File metadata
- Download URL: utility_mcp_server-0.2.0.tar.gz
- Upload date:
- Size: 193.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b83b81a8bb2099dce69010dc17c322d93fa39c28dda6f720c2ef7c908e991b37
|
|
| MD5 |
c6dda7bf8293758c7d9287b73fe45c5e
|
|
| BLAKE2b-256 |
7d84babf193a4f90dda65f750d1216680fbd7836e64ed7f839259e2dcfc6b197
|
File details
Details for the file utility_mcp_server-0.2.0-py3-none-any.whl.
File metadata
- Download URL: utility_mcp_server-0.2.0-py3-none-any.whl
- Upload date:
- Size: 163.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
62a9f0a84227285a34cb9f424cc9229cf339bd683ce09868cff4b53d0a9016e9
|
|
| MD5 |
88afeaca1d2c15c690818febc83f40d1
|
|
| BLAKE2b-256 |
26b69af2c48b3b323197df15aeada13b39b8534a1ebc8676de47b50a798309b7
|