🔧 Module 3: Advanced MCP Development with Microsoft Foundry Toolkit
🎯 Mga Layunin ng Pagkatuto
Sa pagtatapos ng lab na ito, magagawa mo na:
- ✅ Lumikha ng mga custom MCP server gamit ang Microsoft Foundry Toolkit
- ✅ I-configure at gamitin ang pinakabagong MCP Python SDK (v1.9.3)
- ✅ I-set up at gamitin ang MCP Inspector para sa debugging
- ✅ Mag-debug ng MCP server sa parehong Agent Builder at Inspector na mga kapaligiran
- ✅ Maunawaan ang mga advanced na workflow ng pag-develop ng MCP server
📋 Mga Kinakailangan
- Nakumpleto ang Lab 2 (MCP Fundamentals)
- VS Code na may Microsoft Foundry Toolkit extension na naka-install
- Python 3.10+ na kapaligiran
- Node.js at npm para sa pagsasaayos ng Inspector
🏗️ Ano ang Iyong Bubuoin
Sa lab na ito, lilikha ka ng isang Weather MCP Server na nagpapakita ng:
- Custom na implementasyon ng MCP server
- Integrasyon sa Microsoft Foundry Toolkit Agent Builder
- Propesyonal na workflow para sa debugging
- Mga modernong pattern ng paggamit ng MCP SDK
🔧 Pangunahing Mga Komponenteng Pangkalahatan
🐍 MCP Python SDK
Ang Model Context Protocol Python SDK ay nagbibigay ng pundasyon para sa pagbuo ng mga custom MCP server. Gagamitin mo ang bersyon 1.9.3 na may pinahusay na mga kakayahan sa debugging.
🔍 MCP Inspector
Isang makapangyarihang kasangkapan sa pag-debug na nagbibigay ng:
- Real-time na pagmamanman ng server
- Pagpapakita ng pagpapatakbo ng mga tool
- Pagsusuri ng mga network request/response
- Interaktibong testing environment
📖 Hakbang-hakbang na Implementasyon
Hakbang 1: Gumawa ng WeatherAgent sa Agent Builder
- Ilunsad ang Agent Builder sa VS Code sa pamamagitan ng Microsoft Foundry Toolkit extension
- Gumawa ng bagong agent gamit ang sumusunod na configuration:
- Pangalan ng Agent:
WeatherAgent
- Pangalan ng Agent:
Hakbang 2: I-initialize ang MCP Server Project
- Pumunta sa Tools → Add Tool sa Agent Builder
- Piliin ang "MCP Server" mula sa mga opsyon
- Piliin ang "Create A new MCP Server"
- Piliin ang
python-weathertemplate - Pangalanan ang iyong server:
weather_mcp
Hakbang 3: Buksan at Suriin ang Proyekto
- Buksan ang nalikhang proyekto sa VS Code
- Suriin ang istraktura ng proyekto:
weather_mcp/ ├── src/ │ ├── __init__.py │ └── server.py ├── inspector/ │ ├── package.json │ └── package-lock.json ├── .vscode/ │ ├── launch.json │ └── tasks.json ├── pyproject.toml └── README.md
Hakbang 4: I-upgrade sa Pinakabagong MCP SDK
🔍 Bakit Mag-upgrade? Gusto nating gamitin ang pinakabagong MCP SDK (v1.9.3) at Inspector service (0.14.0) para sa pinaigting na mga tampok at mas mahusay na kakayahan sa debugging.
4a. I-update ang Python Dependencies
I-edit ang pyproject.toml: i-update ang ./code/weather_mcp/pyproject.toml
4b. I-update ang Inspector Configuration
I-edit ang inspector/package.json: i-update ang ./code/weather_mcp/inspector/package.json
4c. I-update ang Inspector Dependencies
I-edit ang inspector/package-lock.json: i-update ang ./code/weather_mcp/inspector/package-lock.json
📝 Tala: Ang file na ito ay naglalaman ng malawak na depinisyon ng mga dependencies. Nasa ibaba ang mahalagang istraktura - tinitiyak ng buong nilalaman ang tamang resolusyon ng mga dependencies.
⚡ Buong Package Lock: Ang kumpletong package-lock.json ay naglalaman ng ~3000 linya na mga depinisyon ng dependencies. Ipinapakita sa itaas ang pangunahing istraktura - gamitin ang ibinigay na file para sa kumpletong pagresolba ng dependencies.
Hakbang 5: I-configure ang VS Code Debugging
Paalala: Pakikopya ang file sa tinukoy na landas upang palitan ang katugmang lokal na file
5a. I-update ang Launch Configuration
I-edit ang .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
}
]
}
I-edit ang .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"
}
]
}
🚀 Pagpapatakbo at Pagsubok ng Iyong MCP Server
Hakbang 6: I-install ang Mga Dependencies
Matapos gawin ang mga pagbabago sa configuration, patakbuhin ang mga sumusunod na utos:
I-install ang Python dependencies:
uv sync
I-install ang Inspector dependencies:
cd inspector
npm install
Hakbang 7: Mag-debug gamit ang Agent Builder
- Pindutin ang F5 o gamitin ang "Debug in Agent Builder" configuration
- Piliin ang compound configuration mula sa debug panel
- Maghintay na magsimula ang server at magbukas ang Agent Builder
- Subukan ang iyong weather MCP server gamit ang mga natural language queries
Maglagay ng prompt na tulad nito
SYSTEM_PROMPT
You are my weather assistant
USER_PROMPT
How's the weather like in Seattle
Hakbang 8: Mag-debug gamit ang MCP Inspector
- Gamitin ang "Debug in Inspector" configuration (Edge o Chrome)
- Buksan ang interface ng Inspector sa
http://localhost:6274 - Galugarin ang interaktibong testing environment:
- Tingnan ang mga magagamit na tool
- Subukan ang pagpapatakbo ng mga tool
- I-monitor ang mga network request
- Mag-debug ng mga tugon ng server
🎯 Pangunahing Mga Natutunan
Sa pagkompleto ng lab na ito, nagawa mo na ang mga sumusunod:
- Lumikha ng custom MCP server gamit ang mga template ng Microsoft Foundry Toolkit
- Nag-upgrade sa pinakabagong MCP SDK (v1.9.3) para sa pinahusay na functionality
- Na-configure ang propesyonal na mga workflow sa debugging para sa Agent Builder at Inspector
- Na-set up ang MCP Inspector para sa interaktibong pagsusuri ng server
- Naitatag ang VS Code debugging configurations para sa MCP development
🔧 Mga Advanced na Tampok na Natuklasan
| Tampok | Paglalarawan | Gamit |
|---|---|---|
| MCP Python SDK v1.9.3 | Pinakabagong implementasyon ng protocol | Modernong pagbuo ng server |
| MCP Inspector 0.14.0 | Interaktibong kasangkapan sa debugging | Real-time na pagsubok ng server |
| VS Code Debugging | Integrated development environment | Propesyonal na workflow sa debugging |
| Integrasyon ng Agent Builder | Direktang koneksyon sa Microsoft Foundry Toolkit | End-to-end na pagsusuri ng agent |
📚 Karagdagang Mga Mapagkukunan
- MCP Python SDK Documentation
- Microsoft Foundry Toolkit Extension Guide
- VS Code Debugging Documentation
- Model Context Protocol Specification
🎉 Congratulations! Matagumpay mong natapos ang Lab 3 at maaari ka nang gumawa, mag-debug, at mag-deploy ng mga custom MCP server gamit ang mga propesyonal na workflow sa pag-develop.
🔜 Magpatuloy sa Susunod na Module
Handa ka na bang ilapat ang iyong MCP skills sa isang totoong workflow sa pag-develop? Magpatuloy sa Module 4: Practical MCP Development - Custom GitHub Clone Server kung saan:
- Magtatayo ka ng production-ready na MCP server na nag-a-automate ng mga operasyon sa GitHub repository
- Magpapatupad ng functionality ng cloning ng GitHub repository sa pamamagitan ng MCP
- Mag-iintegrate ng custom MCP servers sa VS Code at GitHub Copilot Agent Mode
- Magsasagawa ng testing at pag-deploy ng custom MCP servers sa production environment
- Matututo ng praktikal na automation ng workflow para sa mga developer
Pagtatanggi: Ang dokumentong ito ay isinalin gamit ang serbisyo ng AI translation na Co-op Translator. Bagama't nagsusumikap kami para sa katumpakan, pakatandaan na ang awtomatikong pagsasalin ay maaaring maglaman ng mga pagkakamali o hindi pagkakatugma. Ang orihinal na dokumento sa orihinal nitong wika ang dapat ituring na pangunahing sanggunian. Para sa mahahalagang impormasyon, inirerekomenda ang propesyonal na pagsasalin ng tao. Hindi kami mananagot sa anumang maling pagkakaintindi o maling interpretasyon na nagmula sa paggamit ng pagsasaling ito.



