This is a sample MCP Server in Python implementing weather tools.
Prerequisites
To run the MCP Server in your local dev machine, you will need:
- Python
- (Optional - if you prefer uv) [uv] (https://github.com/astral-sh/uv)
- Python Debugger Extension
Using uv
-
Create virtual environment
uv venv -
Run VSCode Command "Python: Select Interpreter" and select the python from created virtual environment
(Note: reload VSCode and the terminal to ensure the virtual environment python is used)
-
Install dependencies (include dev dependencies)
uv pip install -r pyproject.toml --extra dev
Or, using pip
-
Create virtual environment
python -m venv .venv -
Run VSCode Command "Python: Select Interpreter" and select the python from created virtual environment
(Note: reload VSCode and the terminal to ensure the virtual environment python is used)
-
Install dependencies (include dev dependencies)
pip install -e .[dev]
- Open VSCode Debug panel. Select
Debug in Inspector (Edge)orDebug in Inspector (Chrome). Press F5 to start debugging. - When MCP Inspector launches in the browser, click the
Connectbutton to connect this MCP server. - Then you can
List Tools, select a tool, input parameters, andRun Toolto debug you server code. - And ofcourse, you can add breakpoint to the tool implementation code.
More Details
When launching debugging, it runs two tasks
- first, the MCP server is launched (by default on port 3001)
- then, the MCP Inspector is launched (by default on port 5173 and 3000)
The whole definition can be found in tasks.json. You can also edit launch.json, tasks.json, __init__.py to change above ports.
In addition, the MCP Inspector is implemented in Node.js. To launch it within this Python project, there are two tricky steps:
- Put the bundled inspector client and server to
inspector/. (Forked and added bundle logic to the inspector's source, see forked repo's branch)- Launch VSCode executable as Node.js. See tasks.json and launcher.py.