MCP Server Framework
A general-purpose MCP server that provides utility tools for echo, date/time, and file operations within Claude Code and Claude Desktop. It functions as an extensible framework designed to help developers easily build and register custom Python-based tools.
README
MCP Server Framework
A general-purpose Model Context Protocol (MCP) server that provides tools for Claude Code and Claude Desktop.
Quick Start
# Install dependencies
cd mcp-server
pip install -r requirements.txt
# Test the server runs (Ctrl+C to stop)
PYTHONPATH=src python -m mcp_server.server
Project Structure
mcp-server/
├── src/mcp_server/
│ ├── server.py # Main FastMCP server
│ ├── config.py # Environment-based configuration
│ └── tools/
│ ├── __init__.py # Tool registry
│ ├── echo_tool.py # Example: basic echo tools
│ ├── datetime_tool.py # Example: date/time utilities
│ └── file_tool.py # Example: file operations
├── configs/ # Client configuration templates
└── requirements.txt
Configuration
The server is configured via environment variables:
| Variable | Description | Default |
|---|---|---|
MCP_SERVER_NAME |
Display name for the server | mcp-server |
MCP_LOG_LEVEL |
Logging level (DEBUG, INFO, WARNING, ERROR) | INFO |
MCP_ALLOWED_PATHS |
Comma-separated paths for file tools | (none) |
MCP_CUSTOM_VAR_* |
Custom variables accessible via config | (none) |
Included Tools
Echo Tools
echo- Echo back a messageecho_uppercase- Echo in uppercaseecho_reverse- Echo reversed
DateTime Tools
get_current_time- Get current UTC timeget_timestamp- Get current Unix timestampparse_timestamp- Convert timestamp to readable formattime_difference- Calculate time between two timestamps
File Tools (requires MCP_ALLOWED_PATHS)
list_directory- List directory contentsread_file- Read file contentsget_file_info- Get file/directory metadataget_allowed_paths- Show configured allowed paths
Setting Up Clients
Claude Desktop
- Open
~/Library/Application Support/Claude/claude_desktop_config.json(macOS) - Add your server configuration:
{
"mcpServers": {
"my-mcp-server": {
"command": "python",
"args": ["-m", "mcp_server.server"],
"cwd": "/full/path/to/mcp-server",
"env": {
"PYTHONPATH": "/full/path/to/mcp-server/src",
"MCP_ALLOWED_PATHS": "/Users/you/Documents"
}
}
}
}
- Restart Claude Desktop completely (Cmd+Q, then relaunch)
Claude Code
Create .mcp.json in your project root:
{
"mcpServers": {
"my-mcp-server": {
"command": "python",
"args": ["-m", "mcp_server.server"],
"cwd": "${workspaceFolder}/mcp-server",
"env": {
"PYTHONPATH": "${workspaceFolder}/mcp-server/src",
"MCP_ALLOWED_PATHS": "${workspaceFolder}"
}
}
}
}
Adding New Tools
- Create a new file in
src/mcp_server/tools/:
# src/mcp_server/tools/my_tool.py
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from mcp.server.fastmcp import FastMCP
from ..config import ServerConfig
def register(mcp: "FastMCP", config: "ServerConfig") -> None:
"""Register my tools with the server."""
@mcp.tool()
def my_function(param: str, count: int = 1) -> str:
"""
Description shown to Claude.
Args:
param: What this parameter does
count: Optional count with default
Returns:
What the tool returns
"""
return f"Result: {param} x {count}"
- Register it in
src/mcp_server/tools/__init__.py:
def register_all_tools(mcp: "FastMCP", config: "ServerConfig") -> None:
from . import echo_tool, datetime_tool, file_tool, my_tool # Add import
echo_tool.register(mcp, config)
datetime_tool.register(mcp, config)
file_tool.register(mcp, config)
my_tool.register(mcp, config) # Add registration
- Restart Claude Desktop/Code to pick up the new tool.
Tool Design Guidelines
- Clear docstrings: The description and parameter docs are sent to Claude
- Type hints: All parameters and returns need type hints (defines the JSON schema)
- Return strings: Tools should return string results for best compatibility
- Error handling: Return user-friendly error messages rather than raising exceptions
- Use config: Access
configfor environment-specific settings (like allowed paths)
Troubleshooting
Server won't start:
- Ensure
PYTHONPATHincludes thesrcdirectory - Check that
mcppackage is installed:pip install mcp[cli]
Tools not appearing in Claude:
- Verify the config JSON is valid
- Check the
cwdpath is correct - Restart Claude Desktop completely (Cmd+Q on Mac)
File tools return "not in allowed directories":
- Set
MCP_ALLOWED_PATHSto comma-separated directory paths - Paths must be absolute
Dependencies
- Python 3.10+
mcp[cli]>=1.0.0
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.