This MCP server template is designed for creating the server side of a VS Code Agent, allowing you to extend VS Code with custom AI-powered tools. It provides a foundation for building MCP (Model Context Protocol) servers that can be used with VS Code's AI features.
First, install uv, a Python package manager and installer. Visit the official uv documentation for various installation options.
# Initialize project
uv init external-recon
cd external-recon
You may need to adjust the Python version in two files:
.python-version
, set to 3.11
or higherpyproject.toml
, modify the line requires-python = ">=3.11"
to version 3.11 or higher# Create virtual environment with Python 3.11
uv venv --python 3.11
# Activate the virtual environment
source .venv/bin/activate
# Install MCP and dependencies
uv add "mcp[cli]"
uv pip install dnspython
# Create the MCP server file
touch external-recon.py
You need to modify your VS Code settings.json
to register the MCP server:
which uv
"mcp": {
"servers": {
"external-recon": {
"command": "/path/to/uv",
"args": [
"--directory",
"/path/to/project/external-recon",
"run",
"external-recon.py"
]
}
}
},
To start the MCP server, activate the virtual environment and run:
uv run external-recon.py
Example output:
(external-recon) user@workstation external-recon % uv run external-recon.py
When implementing functionality in your external-recon.py
file, use the @mcp.tool()
decorator instead of @mcp.prompt()
for defining your tools.
There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json
file so that it is available in all of your projects.
If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json
file.
To add a global MCP server go to Cursor Settings > MCP and click "Add new global MCP server".
When you click that button the ~/.cursor/mcp.json
file will be opened and you can add your server like this:
{
"mcpServers": {
"cursor-rules-mcp": {
"command": "npx",
"args": [
"-y",
"cursor-rules-mcp"
]
}
}
}
To add an MCP server to a project you can create a new .cursor/mcp.json
file or add it to the existing one. This will look exactly the same as the global MCP server example above.
Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.
The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.
You can also explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.