A modular MCP (Model Context Protocol) server for AI agents with plugin-based architecture
Project description
Pythonium
A modular Model Context Protocol (MCP) server designed to enable advanced capabilities for AI agents through a robust, extensible architecture built on the official MCP SDK.
Overview
Pythonium provides a comprehensive, production-ready foundation for building sophisticated AI agent tools and capabilities. Built around the Model Context Protocol specification and leveraging the official MCP SDK (FastMCP), it offers a clean separation of concerns through its modular package structure and streamlined configuration management.
Architecture
Core Packages
pythonium.common- Shared utilities, configuration management, and base componentspythonium.core- Central server implementation, configuration, and tool managementpythonium.tools- Comprehensive standard tool library with extensible frameworkpythonium.managers- Lightweight management systems for specialized functionality
Features
MCP SDK Integration
- Built on the official MCP SDK's FastMCP framework
- Full Model Context Protocol compliance
- Multiple transport support (stdio, HTTP, WebSocket)
- Native tool registration and capability negotiation
Comprehensive Tool Library
- System Operations: Command execution, environment access, system monitoring (
pythonium.tools.std.execution) - File Operations: Advanced file and directory management (
pythonium.tools.std.file_ops) - Web Operations: HTTP client, web search with multiple engines (
pythonium.tools.std.web) - Tool Management: Meta-tools for tool discovery and introspection (
pythonium.tools.std.tool_ops)
Advanced Configuration
- Pydantic-based configuration with validation
- Environment variable integration
- Multiple format support (YAML, JSON, TOML)
- Hot-reload capability and override support
Production Features
- Structured logging with multiple output formats
- Comprehensive error handling and recovery
- Resource management and connection pooling
- Security considerations and rate limiting
- Performance optimizations with async architecture
Quick Start
Installation
# Clone the repository
git clone https://github.com/dwharve/pythonium.git
cd pythonium
# Create and activate virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install dependencies
pip install -r requirements.txt
# Install in development mode
pip install -e .
Basic Usage
# Run the MCP server
python -m pythonium --help
# Start with default configuration (stdio transport)
python -m pythonium serve
# Start with HTTP transport
python -m pythonium serve --transport http --host localhost --port 8080
# Start with WebSocket transport
python -m pythonium serve --transport websocket --host localhost --port 8080
# Start with custom configuration file
python -m pythonium serve --config config/server.yaml
# Alternative: Use installed script
pythonium --help
pythonium serve
Development
Setup Development Environment
# Install development dependencies
pip install -r requirements-dev.txt
# Install pre-commit hooks
pre-commit install
# Run tests
pytest
# Run tests with coverage
pytest --cov=pythonium --cov-report=html
# Format code
black pythonium tests
isort pythonium tests
# Type checking
mypy pythonium
Project Structure
pythonium/
├── pythonium/ # Main package
│ ├── common/ # Shared utilities and base components
│ │ ├── config.py # Pydantic configuration management
│ │ ├── base.py # Base classes and result types
│ │ ├── logging.py # Structured logging system
│ │ └── ... # HTTP client, error handling, etc.
│ ├── core/ # Core server and management
│ │ ├── server.py # Main MCP server implementation
│ │ ├── config.py # Configuration manager
│ │ └── tools/ # Tool registry and discovery
│ ├── tools/ # Tool implementations
│ │ ├── base.py # Base tool framework
│ │ └── std/ # Standard tool library
│ ├── managers/ # Specialized managers
│ ├── main.py # CLI entry point
│ └── __main__.py # Module entry point
├── tests/ # Comprehensive test suite (335 tests)
├── docs/ # Documentation
├── config/ # Configuration examples
└── requirements.txt # Dependencies
Testing
The project uses pytest for testing with comprehensive coverage across all components:
- Unit Tests: Individual component testing
- Integration Tests: Cross-component interaction testing
- Core Tests: Configuration, server, and tool management
- End-to-End Tests: Full MCP server functionality
- Performance Tests: Load testing and benchmarks
Current Status: Comprehensive test coverage across all modules ensuring reliability and maintainability.
# Run all tests
pytest
# Run with coverage reporting
pytest --cov=pythonium --cov-report=html
# Run specific test categories
pytest tests/core/ # Core functionality tests
pytest tests/tools/ # Tool implementation tests
pytest tests/common/ # Common utilities tests
# Quick test run
pytest -q
# Verbose test output
pytest -v
Configuration
Pythonium uses Pydantic-based configuration with support for multiple formats (YAML, JSON, TOML) and environment variable integration:
# config/server.yaml
server:
name: "Pythonium MCP Server"
description: "A modular MCP server for AI agents"
host: "localhost"
port: 8080
transport: "stdio" # stdio, http, websocket
tools:
# Tool discovery and loading configuration
auto_discover: true
categories:
- "system"
- "web"
- "file_operations"
logging:
level: "INFO" # DEBUG, INFO, WARNING, ERROR
format: "structured" # structured, plain
output: "console" # console, file
security:
authentication: "none" # none, api_key
rate_limit:
enabled: false
requests_per_minute: 60
Tool Development
Creating a Custom Tool
from pythonium.tools.base import BaseTool, ToolMetadata, ToolParameter, ParameterType
from pythonium.common.base import Result
from pythonium.common.parameters import validate_parameters
class MyCustomTool(BaseTool):
"""A custom tool example with proper parameter validation."""
@property
def metadata(self) -> ToolMetadata:
return ToolMetadata(
name="my_custom_tool",
description="A custom tool example that demonstrates the framework",
brief_description="Custom tool example",
category="custom",
tags=["example", "custom"],
parameters=[
ToolParameter(
name="message",
type=ParameterType.STRING,
description="Message to process",
required=True,
min_length=1,
max_length=1000
)
]
)
@validate_parameters # Automatic parameter validation
async def execute(self, message: str, context: ToolContext) -> Result:
"""Execute the tool with validated parameters."""
try:
result = f"Processed: {message}"
return Result.success_result(
data={"result": result, "original": message},
metadata={"tool": "my_custom_tool"}
)
except Exception as e:
return Result.error_result(f"Tool execution failed: {e}")
Tool Registration
Tools are automatically discovered and registered when placed in the appropriate package structure. The tool discovery system handles:
- Automatic tool detection and registration
- Parameter validation and schema generation
- Error handling and logging
- Integration with the MCP protocol
Contributing
We welcome contributions! Please see our Contributing Guidelines for details.
For a detailed history of changes, see CHANGELOG.md.
Development Workflow
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for new functionality
- Ensure all tests pass
- Submit a pull request
Code Standards
- Follow PEP 8 style guidelines
- Use type hints throughout the codebase
- Maintain comprehensive test coverage
- Document all public APIs with detailed docstrings
- Use conventional commit messages
- Leverage Pydantic for data validation and configuration
- Implement proper async/await patterns for I/O operations
License
This project is licensed under the MIT License - see the LICENSE file for details.
Support
- Documentation: Available in the
docs/directory - Issues: GitHub Issues
- Discussions: GitHub Discussions
Acknowledgments
- Official Model Context Protocol SDK and specification
- The open-source Python community
- Pydantic and FastAPI ecosystems for configuration and validation patterns
- Contributors and maintainers
Status: Production-ready Beta - Core functionality stable, comprehensive test coverage, active development
Current Version: 0.1.5
Last Updated: July 6, 2025
Maintainer: David Harvey
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 pythonium-0.1.5.tar.gz.
File metadata
- Download URL: pythonium-0.1.5.tar.gz
- Upload date:
- Size: 86.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c7360cfaa7332af4321b99a9e40f7eefa17670d04607b7c4983f3a47f1fc3677
|
|
| MD5 |
60f4dafc73ccacbcaf1f2674effb9669
|
|
| BLAKE2b-256 |
507f2ce42ddf85b5e20192e6a14ffc959ff3c1c689208b00637c021aefd93c40
|
File details
Details for the file pythonium-0.1.5-py3-none-any.whl.
File metadata
- Download URL: pythonium-0.1.5-py3-none-any.whl
- Upload date:
- Size: 91.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d4d0488f961b1822b1aced5402ccf64eda89bfb8c29742fae9a1e202a726381c
|
|
| MD5 |
dadf4026ae4308aefec806262319d6de
|
|
| BLAKE2b-256 |
5719e05e3270925a1ebb4364caea4d855620eacf80f0b9c222a3dd53b621fcc1
|