A proof-of-concept implementation of a Model Context Protocol (MCP) server for enhancing AI assistant capabilities with custom tools and resources.
This project demonstrates how to create and use a Model Context Protocol (MCP) server that can provide custom tools and resources to AI assistants like Claude and others that support the MCP standard. The server includes:
requirements.txt
shell
git clone https://github.com/yourusername/mcp-server-poc.git
cd mcp-server-poc
```shell
# Create a Python 3.11 virtual environment
python -m venv venv
# Activate on Windows
.\venv\Scripts\Activate.ps1
# Activate on macOS/Linux
source venv/bin/activate
```
shell
pip install -r requirements.txt
Create a .env
file in the root directory with the following:
plaintext
SERPER_API_KEY=your_serper_api_key_here
To run the MCP server:
python main.py
The server will start and wait for connections using the stdio transport method.
To use this MCP server with Cursor IDE:
~/.cursor/mcp.json
(on Windows: C:\Users\<username>\.cursor\mcp.json
) with the following content:json
{
"mcpServers": {
"mcp-server": {
"command": "python",
"args": ["ABSOLUTE/PATH/TO/main.py"]
}
}
}
Replace the path with the absolute path to your main.py
file.
On Windows, use double backslashes: C:\\Users\\username\\path\\to\\main.py
On macOS/Linux, use regular slashes: /Users/username/path/to/main.py
Restart Cursor completely (including ending any background processes) to load the MCP server.
This server includes a specific fix for Windows to ensure proper operation with stdio transport:
# Set binary mode for stdin/stdout on Windows
if os.name == 'nt':
import msvcrt
msvcrt.setmode(sys.stdin.fileno(), os.O_BINARY)
msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY)
This fix is necessary because Windows distinguishes between text and binary modes for file handling, which can cause issues with the stdio transport mechanism used by MCP.
If you encounter issues with the MCP server:
pip list
to check).env
file contains the required API keypip uninstall mcp && pip install mcp