diff --git a/docs/first-server/python.mdx b/docs/first-server/python.mdx index 52d6abd..d3ace3f 100644 --- a/docs/first-server/python.mdx +++ b/docs/first-server/python.mdx @@ -285,6 +285,67 @@ Let's build your first MCP server in Python! We'll create a weather server that + + + +## Connect to Claude Desktop + + + + Add to `claude_desktop_config.json`: + + ```json + { + "mcpServers": { + "weather": { + "command": "uv", + "args": "--directory path/to/your/project run weather-service", + "env": { + "OPENWEATHER_API_KEY": "your-api-key", + } + } + } + } + ``` + + + + 1. Quit Claude completely + + 2. Start Claude again + + 3. Look for your weather server in the 🔌 menu + + + +## Try it out! + + + + Ask Claude: + + ``` + What's the current weather in San Francisco? Can you analyze the conditions and tell me if it's a good day for outdoor activities? + ``` + + + + Ask Claude: + + ``` + Can you get me a 5-day forecast for Tokyo and help me plan what clothes to pack for my trip? + ``` + + + + Ask Claude: + + ``` + Can you analyze the forecast for both Tokyo and San Francisco and tell me which city would be better for outdoor photography this week? + ``` + + + ## Understanding the code @@ -445,87 +506,6 @@ import uvicorn uvicorn.run(app, host="0.0.0.0", port=8000) ``` -## Troubleshooting - -### Installation issues - -```bash -# Check Python version -python --version - -# Reinstall dependencies -uv sync --reinstall -``` - - -### Type checking - -```bash -# Install mypy -uv add --dev pyright - -# Run type checker -uv run pyright src -``` - -## Connect to Claude Desktop - - - - Add to `claude_desktop_config.json`: - - ```json - { - "mcpServers": { - "weather": { - "command": "uv", - "args": "--directory path/to/your/project run weather-service", - "env": { - "OPENWEATHER_API_KEY": "your-api-key", - } - } - } - } - ``` - - - - 1. Quit Claude completely - - 2. Start Claude again - - 3. Look for your weather server in the 🔌 menu - - - -## Try it out! - - - - Ask Claude: - - ``` - What's the current weather in San Francisco? Can you analyze the conditions and tell me if it's a good day for outdoor activities? - ``` - - - - Ask Claude: - - ``` - Can you get me a 5-day forecast for Tokyo and help me plan what clothes to pack for my trip? - ``` - - - - Ask Claude: - - ``` - Can you analyze the forecast for both Tokyo and San Francisco and tell me which city would be better for outdoor photography this week? - ``` - - - ## Advanced features @@ -789,6 +769,28 @@ uv run pyright src +## Troubleshooting + +### Installation issues + +```bash +# Check Python version +python --version + +# Reinstall dependencies +uv sync --reinstall +``` + +### Type checking + +```bash +# Install mypy +uv add --dev pyright + +# Run type checker +uv run pyright src +``` + ## Next steps