Adding Your Server
Configure your MCP server to work with Claude Desktop.
Step-by-Step Configuration
Let's walk through adding the MCP server you built in this course to
Claude Desktop. We'll use stdio_example.py from Lesson 7.
Step 1: Locate Your Server
First, find the absolute path to your server script:
# Navigate to your server directory
cd /path/to/your/mcp-project
# Get the absolute path
pwd
# Output: /Users/you/projects/mcp-learning
# Your server script
ls *.py
# Output: stdio_example.py
Step 2: Test Your Server Manually
Before configuring Claude Desktop, verify your server works from the command line:
# Test that your server starts
python3 /Users/you/projects/mcp-learning/stdio_example.py
# It should wait for input (STDIO mode)
# Type this to test initialization:
{"jsonrpc": "2.0", "id": 1, "method": "initialize", "params": {"protocolVersion": "2024-11-05", "capabilities": {}, "clientInfo": {"name": "test", "version": "1.0"}}}
# You should see a JSON response with server info
# Press Ctrl+C to exit
Your server must use STDIO transport (reading from stdin, writing to stdout). If you followed Lesson 7, your server is already set up correctly.
Step 3: Open the Configuration File
Open or create the Claude Desktop configuration file:
# macOS
code ~/Library/Application\ Support/Claude/claude_desktop_config.json
# Or create the directory and file if they don't exist
mkdir -p ~/Library/Application\ Support/Claude
touch ~/Library/Application\ Support/Claude/claude_desktop_config.json
# Windows (PowerShell)
code $env:APPDATA\Claude\claude_desktop_config.json
# Linux
code ~/.config/claude/claude_desktop_config.json
Step 4: Add Your Server Configuration
Add your server to the configuration. If the file is empty or doesn't exist, start with this template:
{
"mcpServers": {
"mcp-tools": {
"command": "python3",
"args": ["/Users/you/projects/mcp-learning/stdio_example.py"]
}
}
}
If you already have servers configured, add yours to the existing
mcpServers object:
{
"mcpServers": {
"existing-server": {
"command": "node",
"args": ["/path/to/existing/server.js"]
},
"mcp-tools": {
"command": "python3",
"args": ["/Users/you/projects/mcp-learning/stdio_example.py"]
}
}
}
Step 5: Add Environment Variables (If Needed)
If your server requires environment variables (like API keys or config), add them to the configuration:
{
"mcpServers": {
"mcp-tools": {
"command": "python3",
"args": ["/Users/you/projects/mcp-learning/stdio_example.py"],
"env": {
"DEBUG": "true",
"LOG_LEVEL": "info"
}
}
}
}
Be careful with API keys in the config file. The file is stored in plain text. For production use, consider using environment variable references or a secrets manager.
Step 6: Using Virtual Environments
If your server uses a Python virtual environment, specify the full path to the virtual environment's Python:
{
"mcpServers": {
"mcp-tools": {
"command": "/Users/you/projects/mcp-learning/.venv/bin/python",
"args": ["/Users/you/projects/mcp-learning/stdio_example.py"]
}
}
}
This ensures Claude Desktop uses the correct Python with all your dependencies installed.
Step 7: Restart Claude Desktop
After saving the configuration file, you need to restart Claude Desktop for changes to take effect:
1. Quit Claude Desktop completely (not just close the window)
- macOS: Claude menu → Quit Claude (or Cmd+Q)
- Windows: Right-click tray icon → Exit
2. Reopen Claude Desktop
3. Claude Desktop will:
- Read the updated configuration
- Launch your server process
- Perform the MCP handshake
- Make your tools/resources available
Complete Example Configuration
Here's a complete example with multiple servers:
{
"mcpServers": {
"mcp-tools": {
"command": "/Users/you/projects/mcp-learning/.venv/bin/python",
"args": ["/Users/you/projects/mcp-learning/stdio_example.py"]
},
"calculator": {
"command": "python3",
"args": ["/Users/you/projects/mcp-learning/calculator_example.py"]
},
"files": {
"command": "python3",
"args": ["/Users/you/projects/mcp-learning/file_example.py"]
}
}
}
Configuration Checklist
Before moving on, verify:
- JSON syntax is valid (no trailing commas, proper quotes)
- All paths are absolute (start with / on macOS/Linux or drive letter on Windows)
- The Python/Node path is correct for your environment
- Your server script path is correct
- All required environment variables are set
- File permissions allow Claude Desktop to execute the server
Use a JSON validator or editor with syntax highlighting to catch common mistakes like missing commas or unmatched braces.
What's Next?
Your server is configured. In the next step, we'll test the integration and verify that Claude can use your server's tools and resources.