MCP Server POC
A cutting-edge Proof of Concept (POC) implementation of a Model Context Protocol (MCP) server using Python and modern technologies. This server provides tools and resources that can be accessed by AI assistants and other MCP clients.
๐๏ธ Architecture
The MCP Server follows a modular architecture with clear separation of concerns:
Workflow Diagram
๐ Features
Modern Python Stack: Built with Python 3.10+ and async/await patterns
Type Safety: Full type hints with Pydantic models
High Performance: Uses
uvloopfor enhanced async performanceComprehensive Tools: Multiple example tools demonstrating various capabilities
Resource Management: File and configuration resource providers
Testing: Complete test suite with pytest
Configuration: Environment-based configuration management
๐ Prerequisites
Python 3.10 or higher
pip or poetry for package management
Git (for cloning the repository)
๐ ๏ธ Installation
Step 1: Clone the Repository
Step 2: Create Virtual Environment
Step 3: Install Dependencies
Step 4: Configure Environment
๐งช Testing
Run All Tests
Run Tests with Coverage
Run Specific Test
๐ฏ Usage
Running the Server
Method 1: Direct Python Execution
Method 2: Using the Script
Method 3: As a Module
Example Client Usage
Run the example client to see the server in action:
Available Tools
The server provides the following tools:
calculate: Perform mathematical calculations
Input:
{"expression": "2 + 2"}Output: Calculation result
fetch_url: Fetch content from URLs
Input:
{"url": "https://example.com", "method": "GET"}Output: HTTP response content
get_system_info: Get system information
Input:
{}Output: System details and environment variables
process_data: Process and transform data
Input:
{"data": "hello", "operation": "uppercase"}Operations:
reverse,uppercase,lowercase,count
write_file: Write content to files
Input:
{"filepath": "output.txt", "content": "Hello World"}Output: Confirmation message
Available Resources
Example File:
file://example.txt- Example file resourceServer Configuration:
config://server-config- Current server configuration
๐ Project Structure
๐ง Configuration
The server can be configured using environment variables:
MCP_SERVER_NAME: Server name (default:mcp-server-poc)MCP_SERVER_VERSION: Server version (default:0.1.0)LOG_LEVEL: Logging level (default:INFO)ENABLE_METRICS: Enable metrics collection (default:true)
๐งฉ Technology Stack
MCP SDK: Official Model Context Protocol SDK for Python
Pydantic: Data validation and settings management
httpx: Modern async HTTP client
aiofiles: Async file operations
uvloop: High-performance event loop
pytest: Testing framework
python-dotenv: Environment variable management
๐ Development
Code Formatting
Adding New Tools
Add tool definition in
list_tools()functionImplement tool logic in
call_tool()functionAdd tests in
tests/test_server.py
Example:
๐ Troubleshooting
Common Issues
Import Errors: Ensure all dependencies are installed
pip install -r requirements.txtPython Version: Ensure Python 3.10+ is being used
python --versionVirtual Environment: Make sure virtual environment is activated
source venv/bin/activatePermission Errors: Check file permissions for write operations
๐ License
See LICENSE file for details.
๐ค Contributing
Fork the repository
Create a feature branch
Make your changes
Add tests
Submit a pull request
๐ Additional Resources
๐ Next Steps
Add more sophisticated tools (database queries, API integrations)
Implement authentication and authorization
Add metrics and monitoring
Support for streaming responses
WebSocket transport support
Resource caching and optimization
Note: This is a POC project. For production use, consider adding:
Proper error handling and logging
Security measures (authentication, input validation)
Rate limiting
Comprehensive monitoring
Documentation generation
CI/CD pipelines
This server cannot be installed
hybrid server
The server is able to function both locally and remotely, depending on the configuration or use case.
A proof-of-concept MCP server demonstrating various capabilities including mathematical calculations, URL fetching, system information retrieval, data processing, and file operations.