Secure MCP gateway with auditing and access control
Project description
Watchgate
A simple, focused proxy for Model Context Protocol (MCP) communications with basic auditing and tool filtering.
Watchgate sits between your MCP client and server to give you visibility and basic control over what your AI agents are doing. This initial release focuses on the core proxy functionality with basic tool filtering and auditing.
How it works: Your MCP client connects to Watchgate as if it were any other MCP server, while Watchgate forwards requests to your actual MCP server with filtering and auditing.
๐ฏ Is This For You?
Watchgate is useful if you're dealing with any of these:
- "I need to protect sensitive data in transit" - Block and log personally identifiable information, security tokens, and malicious prompts flowing between your LLM/MCP client and server
- "I need to control tool access" - Built-in allowlist/blocklist for tool execution, plus plugin support for advanced security policies
- "I need audit logs" - Plain text logs out of the box, or build custom formats and destinations via plugins
- "I need to tweak messages" en-route between my MCP client and server
๐ Quick Start
Prerequisites
- Python 3.11 or higher
- An existing MCP server to proxy
Installation
# Install from PyPI (recommended)
uv add watchgate
# Or install from source
git clone https://github.com/watchgate/watchgate.git
cd watchgate
uv sync
Basic Usage
- Create a configuration file:
# Option 1: Start with the full example (recommended for new users)
cp watchgate.example.yaml watchgate.yaml
# Option 2: Start with minimal configuration (for experienced users)
cp watchgate.minimal.yaml watchgate.yaml
- Edit
watchgate.yamlto match your MCP server setup:
# Minimal example - edit the command to start your MCP server
proxy:
transport: stdio
upstream:
command: "python -m your_mcp_server" # <- Change this
timeouts:
connection_timeout: 30
request_timeout: 60
- Start Watchgate:
watchgate --config watchgate.yaml
- Connect your MCP client to Watchgate instead of directly to your MCP server.
Usage Examples
# Basic usage with default config
watchgate --config watchgate.yaml
# Enable verbose logging
watchgate --config watchgate.yaml --verbose
# Show version
watchgate --version
# Show help
watchgate --help
๐ง Features
Core Capabilities (v0.1.0)
-
โ Foundation Components - Protocol, transport, and config systems (90% test coverage)
-
โ YAML Configuration - Simple configuration file support with plugin parameters
-
โ Plugin System Architecture - Plugin interfaces, manager, and discovery
-
โ Tool Allowlist Plugin - Tool allowlist/blocklist with comprehensive validation
-
โ Default Auditing Plugin - File-based logging with rotation and error handling
-
โ MCP Gateway Server - Complete request/response pipeline with plugin integration
-
โ Stdio Transport - Full stdio communication with subprocess management
-
โ Concurrent Request Handling - High-performance parallel processing of multiple MCP requests
Performance
Watchgate handles concurrent requests efficiently with significant performance improvements:
- Concurrent Processing: Up to 100 simultaneous requests by default
- Performance Gains: 5-250x faster than sequential processing for concurrent workloads
- Resource Management: Automatic cleanup and configurable request limits
- High Throughput: Optimized for production environments with multiple clients
Additional Features
The plugin architecture supports extensibility for additional transport protocols, advanced security policies, and enterprise features as needed.
Architecture
โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ
โ MCP Client โโโโโถโ Watchgate โโโโโถโ MCP Server โ
โ โ โ (filter, โ โ โ
โ โ โ log) โ โ โ
โ โโโโโโ โโโโโโ โ
โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโ
โ Text Logs โ
โโโโโโโโโโโโโโโ
๐ Configuration
Configuration File Structure
# Plugin-based configuration
proxy:
transport: stdio
upstream:
command: "python -m my_mcp_server"
timeouts:
connection_timeout: 30
request_timeout: 120
# Plugin configuration (policy-based)
plugins:
security:
- policy: "tool_allowlist"
enabled: true
config:
mode: "allowlist" # allowlist, blocklist, or allow_all
tools:
- "read_file"
- "write_file"
priority: 50 # Optional: execution order (lower = higher priority)
auditing:
- policy: "file_auditing"
enabled: true
config:
file: "watchgate.log"
format: "simple"
๐ Basic Auditing
Watchgate provides simple text file auditing:
YYYY-MM-DD HH:MM:SS,mmm INFO [watchgate.proxy] MCP Request: tools/list from client
YYYY-MM-DD HH:MM:SS,mmm INFO [watchgate.policy] Tool allowed: file_read (allowlist match)
YYYY-MM-DD HH:MM:SS,mmm INFO [watchgate.proxy] MCP Response: success (42 tools)
YYYY-MM-DD HH:MM:SS,mmm WARN [watchgate.policy] Tool blocked: system_exec (blocklist match)
๐ Simple Security Features
Plugin-Based Architecture
Watchgate uses a modern plugin-based architecture for flexibility and extensibility:
- Plugin Discovery: Automatic discovery of available plugins by policy name
- Execution Sequencing: Configurable plugin execution order with priority and dependency support
- Request/Response Filtering: Plugins can modify requests and responses in addition to allowing/blocking requests
Built-in Security Plugins
Tool Access Control Plugin
- Dual Protection: Filters both
tools/callrequests andtools/listresponses - Multiple Modes: Allowlist, blocklist, and allow_all modes
- Consistent Policy: Same security rules apply to tool execution and tool discovery
- Detailed Auditing: Comprehensive logging of all filtering decisions
Example audit log:
Tool access control filtered tools/list response: original=5 tools, filtered=2 tools,
removed=['delete_file', 'execute_command'], allowed=['read_file', 'write_file'],
mode=allowlist, request_id=123
Basic Policy Engine
Watchgate includes a simple policy engine for basic access control:
- Tool Allowlists - Only specified tools are permitted
- Tool Blocklists - Specified tools are always denied
- Pass-through Mode - If no policy configured, all tools allowed
- Sequential Processing - Plugins execute in configurable order
๐ง Development
Running Tests
# Run all tests
pytest
# Run with coverage
pytest --cov=watchgate --cov-report=term
# Run specific test categories
pytest tests/unit/ # Unit tests
pytest tests/integration/ # Integration tests
pytest tests/performance/ # Performance tests
Development Setup
# Clone and setup development environment
git clone https://github.com/watchgate/watchgate.git
cd watchgate
# Ensure Python 3.11+ is available
python --version # Should show 3.11.x or higher
# Install in development mode
pip install -e .
# Or use uv for faster development setup
uv sync --dev
# Install pre-commit hooks
pre-commit install
# Run linting
black watchgate/
ruff watchgate/
mypy watchgate/
Project Structure
watchgate/
โโโ watchgate/ # Main package
โ โโโ proxy/ # Core proxy implementation โ
โ โ โโโ server.py # Main MCP gateway server
โ โ โโโ stdio_server.py # Stdio server management
โ โโโ plugins/ # Plugin architecture โ
โ โ โโโ security/ # Security plugins โ
โ โ โโโ auditing/ # Auditing plugins โ
โ โโโ protocol/ # MCP protocol layer โ
โ โโโ transport/ # Transport protocols โ
โ โโโ config/ # Configuration system โ
โโโ tests/ # Test suite (285+ tests)
โ โโโ unit/ # Unit tests โ
โ โโโ integration/ # Integration tests โ
โ โโโ performance/ # Performance tests
โโโ docs/ # Documentation
โโโ examples/ # Usage examples
๐ Performance
Current Capabilities
- Basic Functionality: MCP gateway works correctly
- Startup: <5 seconds to get running
- Memory: Reasonable resource usage for development
- Latency: Minimal proxy overhead
๐ ๏ธ Supported MCP Methods
Core Methods
- โ
initialize- Protocol initialization - โ
tools/list- List available tools - โ
tools/call- Execute tools (with policy filtering) - โ
resources/list- List resources - โ
resources/read- Read resource content - ๐
prompts/list- List prompts - ๐
prompts/get- Get prompt content - ๐
notifications- Server notifications - ๐ Custom methods and extensions
๐ง Transport Protocols
Standard I/O (stdio)
Current transport supported:
server:
command: "python -m your_server"
The plugin architecture supports extensibility for additional transport protocols as needed.
๐ง Development Status
Current Version: v0.1.0
Implementation Progress
โ Foundation Components - COMPLETED
- โ Protocol Layer - Message types, validation, error handling (90% test coverage)
- โ Transport Layer - Stdio transport with subprocess management (90% test coverage)
- โ Configuration System - YAML loading and validation (90% test coverage)
โ Plugin System Architecture - COMPLETED
- โ Plugin Interfaces - Abstract base classes for security and auditing plugins (14 tests, 85% coverage)
- โ Plugin Manager - Dynamic loading, orchestration, and error isolation (30 tests, 97% coverage)
- โ Plugin Discovery - Automatic plugin detection and configuration system
โ Plugin Implementation - COMPLETED
- โ Default Security Plugin - Tool allowlist/blocklist implementation with comprehensive validation
- โ Default Auditing Plugin - File-based logging with rotation and error handling
- โ Core Proxy Server - Plugin-integrated message forwarding with stdio server support
- โ Configuration Extension - YAML-based plugin configuration with path-based discovery
Current Test Status
# Run all tests
uv run pytest --no-header -v
# Current results: 285 passed, 1 skipped
# Test Coverage: 90%+ across all components
Environment Notes
Python Version: Requires Python 3.11+ (aligned with .python-version and pyproject.toml)
- All asyncio compatibility issues resolved for Python 3.11+
๐ Documentation
- Requirements Overview - High-level project requirements and strategy
- v0.1.0 Requirements - Complete v0.1.0 specifications
- v0.1.0 Implementation Plan - Implementation strategy and components
- v0.1.0 Test Plan - Comprehensive testing strategy
๐ค Contributing
We welcome contributions! Please see our contributing guidelines for details.
Development Process
- Fork the repository
- Create a feature branch
- Add tests for your changes
- Ensure all tests pass with
uv run pytest - Submit a pull request
Reporting Issues
Please use the GitHub Issues tracker to report bugs or request features.
๐ License
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.
๐ Support & Documentation
- ๐ Project Overview: docs/overview.md - Project strategy, architecture, and requirements
- ๐ Requirements & Status: docs/versions/v0.1.0/ - Detailed v0.1.0 requirements and progress
- ๐ Documentation Guide: docs/README.md - Complete documentation structure
- ๐ Issues: GitHub Issues
- ๐ฌ Discussions: GitHub Discussions
Watchgate v0.1.0 - An MCP server proxy for monitoring and controlling AI tool usage
Project details
Release history Release notifications | RSS feed
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 watchgate-0.1.0.tar.gz.
File metadata
- Download URL: watchgate-0.1.0.tar.gz
- Upload date:
- Size: 902.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
14e10b55ebac808d7830a566ef212f878221c75f397d8d51057d993c8ea5a180
|
|
| MD5 |
f64eafb7e6cbe5adbe9f70276f766b7a
|
|
| BLAKE2b-256 |
3963d31a8821dceaf1510f5d21fe713901a0fad859e1f487153ba7fee616b4e9
|
File details
Details for the file watchgate-0.1.0-py3-none-any.whl.
File metadata
- Download URL: watchgate-0.1.0-py3-none-any.whl
- Upload date:
- Size: 195.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
30f284be89eb7ad0df613e02479c0411982a7458c5172ae6499b45173018ba0b
|
|
| MD5 |
80a29915d6b559c42bd248a41e0c62a8
|
|
| BLAKE2b-256 |
ce9a8f62ec352cc403fbe8f42af0743b0a0ab7c88edfd34fe90bed471c89e18f
|