- 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:
- > 5 integrations planned
- Share tools across multiple apps
- Want community to use (open-source)
- Long-term maintenance
- Service provider exposing for AI use
Build MCP client when:
- Connect to existing MCP servers
- Enterprise integrating multiple systems
- Cross-app tool access needed
Skip MCP (use plain tool use):
- Simple app, 1-3 custom tools
- Proof of concept, MVP
- Tools deeply tied to app logic
- Short-term project
Skip API direct (use MCP):
- Slack/GitHub/etc. provide MCP → use MCP (less maintenance)
- You expose service to AI clients → MCP standard
Production checklist
Server side
- 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)
Client side
- Reuse sessions (not per-request)
- Handle
isErrorfrom 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
Integration with Claude
- 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:
- Filesystem
- GitHub
- PostgreSQL
- Brave Search
- Google Drive
- Slack
- Memory
- Sequential thinking
- Many more
Community
- Python SDK:
pip install mcp - TypeScript SDK:
npm install @modelcontextprotocol/sdk - Docs: modelcontextprotocol.io
- Spec: github.com/modelcontextprotocol/specification
Claude Desktop
Native MCP integration. Install MCP servers, use directly trong Desktop chat.
Config: ~/Library/Application Support/Claude/claude_desktop_config.json
{
"mcpServers": {
"filesystem": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-filesystem", "/Users/you/docs"]
}
}
}
Advanced topics (not covered in course)
- 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
Anthropic docs có chi tiết.
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:
mcp_server.py— FastMCP với tools, prompts, resourcesmcp_client.py— Python client wrappermain.py— chatbot với Claude + MCP integration- Inspector testing workflow
- Slash commands
- @mention resources
Production-ready skeleton. Real apps add:
- 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:
- Production checklist pass?
- Any anti-patterns present?
- Performance acceptable?
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.
Tóm tắt bài học
- 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.