By the end of this lab, you will be able to:
In this lab, you'll create a Weather MCP Server that demonstrates:
---
The Model Context Protocol Python SDK provides the foundation for building custom MCP servers. You'll use version 1.9.3 with enhanced debugging capabilities.
A powerful debugging tool that provides:
---
1. Launch Agent Builder in VS Code through the AI Toolkit extension
2. Create a new agent with the following configuration:
- Agent Name: WeatherAgent
1. Navigate to Tools β Add Tool in Agent Builder
2. Select "MCP Server" from the available options
3. Choose "Create A new MCP Server"
4. Select the python-weather template
5. Name your server: weather_mcp
1. Open the generated project in VS Code
2. Review the project structure:
```
weather_mcp/
βββ src/
β βββ __init__.py
β βββ server.py
βββ inspector/
β βββ package.json
β βββ package-lock.json
βββ .vscode/
β βββ launch.json
β βββ tasks.json
βββ pyproject.toml
βββ README.md
```
> π Why Upgrade? We want to use the latest MCP SDK (v1.9.3) and Inspector service (0.14.0) for enhanced features and better debugging capabilities.
Edit pyproject.toml: update ./code/weather_mcp/pyproject.toml
Edit inspector/package.json: update ./code/weather_mcp/inspector/package.json
Edit inspector/package-lock.json: update ./code/weather_mcp/inspector/package-lock.json
> π Note: This file contains extensive dependency definitions. Below is the essential structure - the full content ensures proper dependency resolution.
> β‘ Full Package Lock: The complete package-lock.json contains ~3000 lines of dependency definitions. The above shows the key structure - use the provided file for complete dependency resolution.
*Note: Please copy the file in the specified path to replace the corresponding local file*
Edit .vscode/launch.json:
{
"version": "0.2.0",
"configurations": [
{
"name": "Attach to Local MCP",
"type": "debugpy",
"request": "attach",
"connect": {
"host": "localhost",
"port": 5678
},
"presentation": {
"hidden": true
},
"internalConsoleOptions": "neverOpen",
"postDebugTask": "Terminate All Tasks"
},
{
"name": "Launch Inspector (Edge)",
"type": "msedge",
"request": "launch",
"url": "http://localhost:6274?timeout=60000&serverUrl=http://localhost:3001/sse#tools",
"cascadeTerminateToConfigurations": [
"Attach to Local MCP"
],
"presentation": {
"hidden": true
},
"internalConsoleOptions": "neverOpen"
},
{
"name": "Launch Inspector (Chrome)",
"type": "chrome",
"request": "launch",
"url": "http://localhost:6274?timeout=60000&serverUrl=http://localhost:3001/sse#tools",
"cascadeTerminateToConfigurations": [
"Attach to Local MCP"
],
"presentation": {
"hidden": true
},
"internalConsoleOptions": "neverOpen"
}
],
"compounds": [
{
"name": "Debug in Agent Builder",
"configurations": [
"Attach to Local MCP"
],
"preLaunchTask": "Open Agent Builder",
},
{
"name": "Debug in Inspector (Edge)",
"configurations": [
"Launch Inspector (Edge)",
"Attach to Local MCP"
],
"preLaunchTask": "Start MCP Inspector",
"stopAll": true
},
{
"name": "Debug in Inspector (Chrome)",
"configurations": [
"Launch Inspector (Chrome)",
"Attach to Local MCP"
],
"preLaunchTask": "Start MCP Inspector",
"stopAll": true
}
]
}
Edit .vscode/tasks.json:
{
"version": "2.0.0",
"tasks": [
{
"label": "Start MCP Server",
"type": "shell",
"command": "python -m debugpy --listen 127.0.0.1:5678 src/__init__.py sse",
"isBackground": true,
"options": {
"cwd": "${workspaceFolder}",
"env": {
"PORT": "3001"
}
},
"problemMatcher": {
"pattern": [
{
"regexp": "^.*$",
"file": 0,
"location": 1,
"message": 2
}
],
"background": {
"activeOnStart": true,
"beginsPattern": ".*",
"endsPattern": "Application startup complete|running"
}
}
},
{
"label": "Start MCP Inspector",
"type": "shell",
"command": "npm run dev:inspector",
"isBackground": true,
"options": {
"cwd": "${workspaceFolder}/inspector",
"env": {
"CLIENT_PORT": "6274",
"SERVER_PORT": "6277",
}
},
"problemMatcher": {
"pattern": [
{
"regexp": "^.*$",
"file": 0,
"location": 1,
"message": 2
}
],
"background": {
"activeOnStart": true,
"beginsPattern": "Starting MCP inspector",
"endsPattern": "Proxy server listening on port"
}
},
"dependsOn": [
"Start MCP Server"
]
},
{
"label": "Open Agent Builder",
"type": "shell",
"command": "echo ${input:openAgentBuilder}",
"presentation": {
"reveal": "never"
},
"dependsOn": [
"Start MCP Server"
],
},
{
"label": "Terminate All Tasks",
"command": "echo ${input:terminate}",
"type": "shell",
"problemMatcher": []
}
],
"inputs": [
{
"id": "openAgentBuilder",
"type": "command",
"command": "ai-mlstudio.agentBuilder",
"args": {
"initialMCPs": [ "local-server-weather_mcp" ],
"triggeredFrom": "vsc-tasks"
}
},
{
"id": "terminate",
"type": "command",
"command": "workbench.action.tasks.terminate",
"args": "terminateAll"
}
]
}
---
After making the configuration changes, run the following commands:
Install Python dependencies:
uv sync
Install Inspector dependencies:
cd inspector
npm install
1. Press F5 or use the "Debug in Agent Builder" configuration
2. Select the compound configuration from the debug panel
3. Wait for the server to start and Agent Builder to open
4. Test your weather MCP server with natural language queries
Input prompt like this
SYSTEM_PROMPT
You are my weather assistant
USER_PROMPT
How's the weather like in Seattle
1. Use the "Debug in Inspector" configuration (Edge or Chrome)
2. Open the Inspector interface at http://localhost:6274
3. Explore the interactive testing environment:
- View available tools
- Test tool execution
- Monitor network requests
- Debug server responses
---
By completing this lab, you have:
| Feature | Description | Use Case |
|---------|-------------|----------|
| MCP Python SDK v1.9.3 | Latest protocol implementation | Modern server development |
| MCP Inspector 0.14.0 | Interactive debugging tool | Real-time server testing |
| VS Code Debugging | Integrated development environment | Professional debugging workflow |
| Agent Builder Integration | Direct AI Toolkit connection | End-to-end agent testing |
---
π Congratulations! You've successfully completed Lab 3 and can now create, debug, and deploy custom MCP servers using professional development workflows.
Ready to apply your MCP skills to a real-world development workflow? Continue to Module 4: Practical MCP Development - Custom GitHub Clone Server where you'll:
μ΄ μ€μ΅μ λ§μΉλ©΄ λ€μμ ν μ μμ΅λλ€:
μ΄λ² μ€μ΅μμλ Weather MCP Serverλ₯Ό λ§λ€μ΄ λ€μμ 보μ¬μ€λλ€:
---
Model Context Protocol Python SDKλ λ§μΆ€ν MCP μλ² κ΅¬μΆμ κΈ°λ°μ λλ€. λλ²κΉ κΈ°λ₯μ΄ κ°νλ 1.9.3 λ²μ μ μ¬μ©ν©λλ€.
κ°λ ₯ν λλ²κΉ λκ΅¬λ‘ λ€μ κΈ°λ₯μ μ 곡ν©λλ€:
---
1. AI Toolkit νμ₯ νλ‘κ·Έλ¨μ ν΅ν΄ VS Codeμμ Agent Builder μ€ν
2. λ€μ μ€μ μΌλ‘ μ μμ΄μ νΈ μμ±:
- μμ΄μ νΈ μ΄λ¦: WeatherAgent
1. Agent Builderμμ Tools β Add Toolλ‘ μ΄λ
2. "MCP Server" μ ν
3. "Create A new MCP Server" μ ν
4. python-weather ν
νλ¦Ώ μ ν
5. μλ² μ΄λ¦ μ§μ : weather_mcp
1. μμ±λ νλ‘μ νΈλ₯Ό VS Codeμμ μ΄κΈ°
2. νλ‘μ νΈ κ΅¬μ‘° κ²ν :
```
weather_mcp/
βββ src/
β βββ __init__.py
β βββ server.py
βββ inspector/
β βββ package.json
β βββ package-lock.json
βββ .vscode/
β βββ launch.json
β βββ tasks.json
βββ pyproject.toml
βββ README.md
```
> π μ μ κ·Έλ μ΄λνλμ? μ΅μ MCP SDK(v1.9.3)μ Inspector μλΉμ€(0.14.0)λ₯Ό μ¬μ©ν΄ ν₯μλ κΈ°λ₯κ³Ό λλ²κΉ μ±λ₯μ μ»κΈ° μν¨μ λλ€.
pyproject.toml νΈμ§: ./code/weather_mcp/pyproject.toml μ
λ°μ΄νΈ
inspector/package.json νΈμ§: ./code/weather_mcp/inspector/package.json μ
λ°μ΄νΈ
inspector/package-lock.json νΈμ§: ./code/weather_mcp/inspector/package-lock.json μ
λ°μ΄νΈ
> π μ°Έκ³ : μ΄ νμΌμ λ°©λν μμ‘΄μ± μ μλ₯Ό ν¬ν¨ν©λλ€. μλλ ν΅μ¬ ꡬ쑰μ΄λ©°, μ 체 λ΄μ©μ μ¬λ°λ₯Έ μμ‘΄μ± ν΄κ²°μ μν΄ νμν©λλ€.
> β‘ μ 체 ν¨ν€μ§ λ½: package-lock.json μ 체 νμΌμ μ½ 3000μ€μ λ¬νλ μμ‘΄μ± μ μλ₯Ό ν¬ν¨ν©λλ€. μλ μ£Όμ κ΅¬μ‘°λ§ λ³΄μ¬μ£Όλ©°, μμ ν μμ‘΄μ± ν΄κ²°μ μν΄ μ 곡λ νμΌμ μ¬μ©νμΈμ.
*μ°Έκ³ : μ§μ λ κ²½λ‘μ νμΌμ 볡μ¬νμ¬ λ‘컬 νμΌμ κ΅μ²΄νμΈμ*
.vscode/launch.json νΈμ§:
{
"version": "0.2.0",
"configurations": [
{
"name": "Attach to Local MCP",
"type": "debugpy",
"request": "attach",
"connect": {
"host": "localhost",
"port": 5678
},
"presentation": {
"hidden": true
},
"internalConsoleOptions": "neverOpen",
"postDebugTask": "Terminate All Tasks"
},
{
"name": "Launch Inspector (Edge)",
"type": "msedge",
"request": "launch",
"url": "http://localhost:6274?timeout=60000&serverUrl=http://localhost:3001/sse#tools",
"cascadeTerminateToConfigurations": [
"Attach to Local MCP"
],
"presentation": {
"hidden": true
},
"internalConsoleOptions": "neverOpen"
},
{
"name": "Launch Inspector (Chrome)",
"type": "chrome",
"request": "launch",
"url": "http://localhost:6274?timeout=60000&serverUrl=http://localhost:3001/sse#tools",
"cascadeTerminateToConfigurations": [
"Attach to Local MCP"
],
"presentation": {
"hidden": true
},
"internalConsoleOptions": "neverOpen"
}
],
"compounds": [
{
"name": "Debug in Agent Builder",
"configurations": [
"Attach to Local MCP"
],
"preLaunchTask": "Open Agent Builder",
},
{
"name": "Debug in Inspector (Edge)",
"configurations": [
"Launch Inspector (Edge)",
"Attach to Local MCP"
],
"preLaunchTask": "Start MCP Inspector",
"stopAll": true
},
{
"name": "Debug in Inspector (Chrome)",
"configurations": [
"Launch Inspector (Chrome)",
"Attach to Local MCP"
],
"preLaunchTask": "Start MCP Inspector",
"stopAll": true
}
]
}
.vscode/tasks.json νΈμ§:
{
"version": "2.0.0",
"tasks": [
{
"label": "Start MCP Server",
"type": "shell",
"command": "python -m debugpy --listen 127.0.0.1:5678 src/__init__.py sse",
"isBackground": true,
"options": {
"cwd": "${workspaceFolder}",
"env": {
"PORT": "3001"
}
},
"problemMatcher": {
"pattern": [
{
"regexp": "^.*$",
"file": 0,
"location": 1,
"message": 2
}
],
"background": {
"activeOnStart": true,
"beginsPattern": ".*",
"endsPattern": "Application startup complete|running"
}
}
},
{
"label": "Start MCP Inspector",
"type": "shell",
"command": "npm run dev:inspector",
"isBackground": true,
"options": {
"cwd": "${workspaceFolder}/inspector",
"env": {
"CLIENT_PORT": "6274",
"SERVER_PORT": "6277",
}
},
"problemMatcher": {
"pattern": [
{
"regexp": "^.*$",
"file": 0,
"location": 1,
"message": 2
}
],
"background": {
"activeOnStart": true,
"beginsPattern": "Starting MCP inspector",
"endsPattern": "Proxy server listening on port"
}
},
"dependsOn": [
"Start MCP Server"
]
},
{
"label": "Open Agent Builder",
"type": "shell",
"command": "echo ${input:openAgentBuilder}",
"presentation": {
"reveal": "never"
},
"dependsOn": [
"Start MCP Server"
],
},
{
"label": "Terminate All Tasks",
"command": "echo ${input:terminate}",
"type": "shell",
"problemMatcher": []
}
],
"inputs": [
{
"id": "openAgentBuilder",
"type": "command",
"command": "ai-mlstudio.agentBuilder",
"args": {
"initialMCPs": [ "local-server-weather_mcp" ],
"triggeredFrom": "vsc-tasks"
}
},
{
"id": "terminate",
"type": "command",
"command": "workbench.action.tasks.terminate",
"args": "terminateAll"
}
]
}
---
μ€μ λ³κ²½ ν λ€μ λͺ λ Ήμ΄ μ€ν:
Python μμ‘΄μ± μ€μΉ:
uv sync
Inspector μμ‘΄μ± μ€μΉ:
cd inspector
npm install
1. F5 ν€λ₯Ό λλ₯΄κ±°λ "Debug in Agent Builder" κ΅¬μ± μ¬μ©
2. λλ²κ·Έ ν¨λμμ λ³΅ν© κ΅¬μ± μ ν
3. μλ²κ° μμλκ³ Agent Builderκ° μ΄λ¦΄ λκΉμ§ λκΈ°
4. μμ°μ΄ μΏΌλ¦¬λ‘ λ μ¨ MCP μλ² ν μ€νΈ
λ€μκ³Ό κ°μ μ λ ₯ ν둬ννΈ μμ
SYSTEM_PROMPT
You are my weather assistant
USER_PROMPT
How's the weather like in Seattle
1. "Debug in Inspector" κ΅¬μ± μ¬μ© (Edge λλ Chrome)
2. http://localhost:6274μμ Inspector μΈν°νμ΄μ€ μ΄κΈ°
3. μΈν°λν°λΈ ν μ€νΈ νκ²½ νμ:
- μ¬μ© κ°λ₯ν λꡬ νμΈ
- λꡬ μ€ν ν μ€νΈ
- λ€νΈμν¬ μμ² λͺ¨λν°λ§
- μλ² μλ΅ λλ²κΉ
---
μ΄ μ€μ΅μ μλ£νμ¬ λ€μμ λ¬μ±νμ΅λλ€:
| κΈ°λ₯ | μ€λͺ | νμ© μ¬λ‘ |
|---------|-------------|----------|
| MCP Python SDK v1.9.3 | μ΅μ νλ‘ν μ½ κ΅¬ν | νλμ μΈ μλ² κ°λ° |
| MCP Inspector 0.14.0 | μΈν°λν°λΈ λλ²κΉ λꡬ | μ€μκ° μλ² ν μ€νΈ |
| VS Code λλ²κΉ | ν΅ν© κ°λ° νκ²½ | μ λ¬Έμ μΈ λλ²κΉ μν¬νλ‘μ° |
| Agent Builder ν΅ν© | AI Toolkitκ³Ό μ§μ μ°κ²° | μλν¬μλ μμ΄μ νΈ ν μ€νΈ |
---
π μΆνν©λλ€! Lab 3μ μ±κ³΅μ μΌλ‘ μλ£νμ¬ μ λ¬Έμ μΈ κ°λ° μν¬νλ‘μ°λ‘ λ§μΆ€ν MCP μλ²λ₯Ό μμ±, λλ²κΉ , λ°°ν¬ν μ μκ² λμμ΅λλ€.
μ€μ κ°λ° μν¬νλ‘μ°μ MCP κΈ°μ μ μ μ©ν μ€λΉκ° λμ ¨λμ? λͺ¨λ 4: μ€μ MCP κ°λ° - λ§μΆ€ν GitHub ν΄λ‘ μλ²λ‘ μ΄λνμ¬:
λ©΄μ± μ‘°ν:
μ΄ λ¬Έμλ AI λ²μ μλΉμ€ Co-op Translatorλ₯Ό μ¬μ©νμ¬ λ²μλμμ΅λλ€.
μ νμ±μ μν΄ μ΅μ μ λ€νκ³ μμΌλ, μλ λ²μμλ μ€λ₯λ λΆμ νν λΆλΆμ΄ μμ μ μμμ μ μνμκΈ° λ°λλλ€.
μλ¬Έμ ν΄λΉ μΈμ΄μ μλ³Έ λ¬Έμκ° κΆμ μλ μΆμ²λ‘ κ°μ£Όλμ΄μΌ ν©λλ€.
μ€μν μ 보μ κ²½μ° μ λ¬Έμ μΈ μΈκ° λ²μμ κΆμ₯ν©λλ€.
λ³Έ λ²μ μ¬μ©μΌλ‘ μΈν΄ λ°μνλ μ€ν΄λ μλͺ»λ ν΄μμ λν΄ λΉμ¬λ μ± μμ μ§μ§ μμ΅λλ€.