A basic MCP (Model Context Protocol) server template demonstrating core capabilities.
- echo - Echoes back a message (useful for testing)
- calculate - Performs basic math operations (add, subtract, multiply, divide)
- get_info - Returns information about the server
- resource://examples/welcome - Welcome message for new users
- resource://examples/capabilities - JSON description of server capabilities
- Install dependencies:
pip install -r requirements.txt- Test the server locally:
python my_serv.pyAdd this server to your Cursor mcp.json file:
{
"mcpServers": {
"my-mcp-server": {
"command": "python",
"args": ["/Users/fpj/Development/python/mcp/my_serv.py"],
"env": {
"LOG_LEVEL": "INFO"
}
}
}
}You can add environment variables to customize behavior:
"env": {
"LOG_LEVEL": "DEBUG",
"CUSTOM_VAR": "value"
}mcp/
├── my_serv.py # Main server implementation
├── requirements.txt # Python dependencies
└── README.md # This file
To add a new tool:
- Add the tool definition to
list_tools():
Tool(
name="my_tool",
description="Description of what it does",
inputSchema={
"type": "object",
"properties": {
"param": {"type": "string"}
},
"required": ["param"]
}
)- Add the tool handler in
call_tool():
elif name == "my_tool":
param = arguments.get("param")
# Your logic here
return [TextContent(type="text", text=f"Result: {param}")]To add a new resource:
- Add to
list_resources():
Resource(
uri="resource://my/resource",
name="Resource Name",
mimeType="text/plain",
description="What this resource provides"
)- Add the handler in
read_resource():
elif uri == "resource://my/resource":
return "Resource content here"After adding the server to your mcp.json and restarting Cursor:
- Open any file in Cursor
- In the chat, you can now use commands like:
- "Use the echo tool to say hello"
- "Calculate 15 + 27"
- "Show me the server capabilities"
The AI will automatically call your MCP server tools!
Logs are written to stderr. In Cursor:
- Go to View → Output
- Select your server from the dropdown
- View real-time logs
Server not starting:
- Check that Python 3.8+ is installed
- Verify dependencies are installed:
pip install -r requirements.txt - Check the path in
mcp.jsonis correct
Tools not available:
- Restart Cursor (Cmd/Ctrl + Shift + P → "Developer: Reload Window")
- Check Output panel for error messages
- Verify
mcp.jsonsyntax is valid
Errors during tool execution:
- Check the Output panel for stack traces
- Ensure your tool logic handles edge cases
- Validate input parameters match the schema
-
File System Operations
- Read/write files
- Search directories
- File management
-
API Integrations
- Connect to external services
- Fetch data from APIs
- Send notifications
-
Database Access
- Query databases
- Execute SQL
- Data analysis
-
Custom Workflows
- Automate repetitive tasks
- Code generation
- Project scaffolding
-
System Operations
- Run shell commands
- Process monitoring
- Environment management
MIT