This guide shows you how to develop and debug the Onshape MCP server without constantly restarting Claude Code.
-
Open the project in VSCode:
code /path/to/onshape-mcp
-
Press F5 or go to Run → Start Debugging
-
The server will start with:
- ✅ Full debugging support (breakpoints, step-through, etc.)
- ✅ Environment variables loaded
- ✅ Console output visible
- ✅ Auto-reload when you make changes (just restart with F5)
cd /path/to/onshape-mcp
python run_mcp_server.pyImportant: You only need to configure this ONCE. After that, you can restart the MCP server as many times as you want without touching Claude Code.
{
"mcpServers": {
"onshape": {
"command": "python",
"args": ["-m", "onshape_mcp.server"],
"cwd": "/absolute/path/to/onshape-mcp",
"env": {
"ONSHAPE_ACCESS_KEY": "your_access_key_here",
"ONSHAPE_SECRET_KEY": "your_secret_key_here"
}
}
}
}Important: Replace /absolute/path/to/onshape-mcp with the actual absolute path to your cloned repository.
If your editor or MCP client makes environment variables awkward to set, scripts/run-with-creds.sh decrypts them at start-up instead. Put the two lines below in a file, encrypt it (gpg -e -a -o ~/.credentials/onshape.env.asc creds.env), and point mcp.json at the script as the command:
ONSHAPE_ACCESS_KEY=xxxxxxxx
ONSHAPE_SECRET_KEY=yyyyyyyy
The script uses the active virtualenv, else the repo's .venv, else python3; override with ONSHAPE_MCP_PYTHON, and the file location with ONSHAPE_CREDS_GPG.
- Edit your code in VSCode
- Stop the server (Ctrl+C or stop debugger)
- Restart the server (F5 or
python run_mcp_server.py) - Claude Code will automatically reconnect when you ask it to use a tool
- ❌ Restart Claude Code
- ❌ Reload VSCode
- ❌ Edit
mcp.jsonagain
- Make your code changes
- Restart the MCP server (F5)
- In Claude Code, ask: "Can you list my Onshape documents?"
- Claude Code will use your updated server!
- Click in the left margin of any
.pyfile to set a breakpoint (red dot appears) - When Claude Code calls that tool, execution will pause
- You can:
- Inspect variables
- Step through code (F10 = step over, F11 = step into)
- View the call stack
- Evaluate expressions in the Debug Console
- Terminal Output: Shows server startup and MCP protocol messages
- Debug Console: Shows Python print statements and errors
- Variables Panel: Shows current variable values when paused
Scenario 1: Tool not working as expected
- Set breakpoint in the tool handler (e.g., line 539 for
get_parts) - Run the tool from Claude Code
- Step through the code to see what's happening
Scenario 2: API call failing
- Set breakpoint in the API client (
onshape_mcp/api/client.py) - Inspect the request URL and headers
- Check the response data
Scenario 3: Data parsing issues
- Set breakpoint where you parse the API response
- Inspect the raw data structure
- Check the data models in the Variables panel
.vscode/launch.json- VSCode debugger configurationrun_mcp_server.py- Development runner script with environment setupDEV_SETUP.md- This guide
If you prefer Docker, you can create a Dockerfile:
FROM python:3.11-slim
WORKDIR /app
COPY . .
RUN pip install -e .
ENV ONSHAPE_ACCESS_KEY=your_access_key_here
ENV ONSHAPE_SECRET_KEY=your_secret_key_here
CMD ["python", "-m", "onshape_mcp.server"]Then update ~/.claude/mcp.json:
{
"mcpServers": {
"onshape": {
"command": "docker",
"args": ["run", "-i", "onshape-mcp"]
}
}
}- Check Python version:
python --version(needs 3.10+) - Verify virtual environment:
which python - Install dependencies:
pip install -e ".[dev]"
- Make sure the server is running (you should see startup messages)
- Check that
cwdinmcp.jsonpoints to the correct directory - Try asking Claude Code: "List my Onshape documents" to trigger reconnection
- Make sure
justMyCodeisfalseinlaunch.json - Verify the breakpoint is on an executable line (not a comment or blank line)
- Check that the code path is actually being executed
- Make sure you restarted the server after making changes
- Check the terminal output to confirm the server restarted
- Try asking Claude Code to use a different tool, then retry
- Test the setup: Press F5 to start debugging
- Make a change: Edit a tool handler to add a print statement
- Test it: Restart server, ask Claude Code to use that tool
- See the output: Check the Debug Console
Happy debugging! 🎉