- Review toàn bộ MCP architecture
- Decision framework: khi nào MCP vs tool use vs API
- Production checklist
- Resource để continue learning
MCP architecture summary
┌───────────────────────────────────────────────┐ │ │ │ YOUR APP │ │ ├─ Anthropic client (Claude) │ │ └─ MCP client(s) │ │ │ │ │ ├─ Connect via stdio/HTTP/WS │ │ ▼ │ │ MCP server(s) │ │ ├─ Tools (actions) │ │ ├─ Prompts (templates) │ │ └─ Resources (read-only data) │ │ │ │ │ ▼ │ │ External services / data │ │ │ └───────────────────────────────────────────────┘
3 primitives
| Tools | Prompts | Resources | |
|---|---|---|---|
| Purpose | Actions | Templates | Data |
| Read/write | Execute | Generate messages | Read only |
| URI | No | No | Yes |
| Claude invokes | Yes | Indirectly (user triggers) | Via prompt mention |
| SDK | @mcp.tool | @mcp.prompt | @mcp.resource |
Decision framework
Build MCP server when:
Build MCP client when:
Skip MCP (use plain tool use):
Skip API direct (use MCP):
- ✅ > 5 integrations planned
- ✅ Share tools across multiple apps
- ✅ Want community to use (open-source)
- ✅ Long-term maintenance
- ✅ Service provider exposing for AI use
- ✅ Connect to existing MCP servers
- ✅ Enterprise integrating multiple systems
- ✅ Cross-app tool access needed
- ⚠️ Simple app, 1-3 custom tools
- ⚠️ Proof of concept, MVP
- ⚠️ Tools deeply tied to app logic
- ⚠️ Short-term project
- Slack/GitHub/etc. provide MCP → use MCP (less maintenance)
- You expose service to AI clients → MCP standard
Production checklist
Server side
Client side
Integration with Claude
- [ ] Tools have descriptive names + rich descriptions
- [ ] Pydantic Field descriptions cho mỗi param
- [ ] Error handling với raise ValueError("message")
- [ ] Auth/permission checks if sensitive
- [ ] Rate limiting if external API backend
- [ ] Logging qua log_level
- [ ] Tested qua Inspector + pytest
- [ ] Resource URIs follow consistent scheme
- [ ] Prompts well-crafted (expert-level)
- [ ] Reuse sessions (not per-request)
- [ ] Handle isError from tool calls
- [ ] Timeout on tool calls
- [ ] Tool name namespacing (if multi-server)
- [ ] Error recovery / retry
- [ ] UX for slash commands (prompts)
- [ ] Resource caching
- [ ] Monitor: tool call volume, success rate, latency
- [ ] MCP tools converted correctly to Anthropic schema
- [ ] Multi-turn loop with max_turns safety
- [ ] Tool results formatted correctly back to Claude
- [ ] Conversation history managed
Common mistakes
1. MCP server with side effects in resources
Violates contract. Debug hell.
Fix: Resources = read only. Side effects = tools.
2. Tool name collision between servers
Multiple servers → same tool name → ambiguity.
Fix: Namespace github:get_user, slack:get_user.
3. Not handling disconnection
Server crashes → client hangs.
Fix: Heartbeat, auto-reconnect.
4. Exposing too much
All DB tables as resources → security risk, confusion.
Fix: Curated views only.
5. Per-tool manual schema
Manually maintain JSON schemas → drift from code.
Fix: Use @mcp.tool + type hints.
Ecosystem resources
Official servers (curated list)
github.com/modelcontextprotocol/servers
Includes:
Community
Claude Desktop
Native MCP integration. Install MCP servers, use directly trong Desktop chat.
Config: ~/Library/Application Support/Claude/claude_desktop_config.json
- Filesystem
- GitHub
- PostgreSQL
- Brave Search
- Google Drive
- Slack
- Memory
- Sequential thinking
- Many more
- Python SDK: pip install mcp
- TypeScript SDK: npm install @modelcontextprotocol/sdk
- Docs: modelcontextprotocol.io
- Spec: github.com/modelcontextprotocol/specification
{
"mcpServers": {
"filesystem": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-filesystem", "/Users/you/docs"]
}
}
}Advanced topics (not covered in course)
Anthropic docs có chi tiết.
- Authentication/OAuth — MCP 2.0+ spec
- Streaming responses — large data streams
- Logging / observability — structured MCP logs
- Compression — cho large resource content
- Federated MCP — one server aggregating others
- Security model — sandboxing untrusted servers
When MCP không fit
- Latency critical (< 50ms) — MCP adds overhead
- Simple 1-tool integration — plain tool use simpler
- Ephemeral tools — tạo cho 1 conversation rồi bỏ
Review code: Full MCP chatbot
Bạn đã build:
Production-ready skeleton. Real apps add:
- ✅ mcp_server.py — FastMCP với tools, prompts, resources
- ✅ mcp_client.py — Python client wrapper
- ✅ main.py — chatbot với Claude + MCP integration
- ✅ Inspector testing workflow
- ✅ Slash commands
- ✅ @mention resources
- Auth
- Persistent storage
- UI (web, desktop)
- Deployment (containerize MCP server)
Áp dụng ngay
Bài tập 1: Evaluate your project (20 phút)
Review your MCP implementation:
Bài tập 2: Explore ecosystem (30 phút)
Visit github.com/modelcontextprotocol/servers. Try 1 official server (filesystem, sqlite, memory).
Connect qua your MCP client. Test.
- Production checklist pass?
- Any anti-patterns present?
- Performance acceptable?
Tóm tắt
🎯 MCP = open standard cho AI-tool integration. Gaining adoption 2025-2026.
🎯 3 primitives: Tools (actions), Prompts (templates), Resources (data).
🎯 Build server if exposing service. Build client if consuming.
🎯 Production checklist ensures robust implementation.
🎯 Ecosystem growing fast — check registry regularly.
Củng cố những gì bạn vừa học
12 câu trắc nghiệm · đạt từ 70% · câu hỏi và đáp án xáo trộn mỗi lần.