mcp-integration
Skill này làm gì
Skill này giải thích cách thêm các máy chủ Model Context Protocol vào một plugin Claude Code, để AI có thể dùng dịch vụ bên ngoài như công cụ. Nó dành cho người xây dựng plugin.
Khi nào nên dùng
- ✓Khi bạn muốn plugin kết nối với một cơ sở dữ liệu, API hoặc dịch vụ bên ngoài khác.
- ✓Khi bạn cần chọn giữa loại máy chủ cục bộ và từ xa.
- ✓Khi bạn muốn máy chủ tự khởi động cùng plugin.
Liên kết skill
https://github.com/anthropics/claude-plugins-official/blob/main/plugins/plugin-dev/skills/mcp-integration/SKILL.mdSao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.
Cách dùng
Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.
Tin nhắn có sẵn để dán
Dành cho Claude Code, Codex hoặc Cursor: chạy lệnh trong thư mục dự án của bạn và skill sẽ được cài đặt.
Tải tệp SKILL.md về và thả vào thư mục skill của agent.
Ví dụ cách nhờ AI
“Giúp tôi kết nối plugin với dịch vụ ticket của công ty bằng MCP.”
5 skill mới mỗi tuần. Đọc chỉ 1 phút.
Cách hoạt động
Bạn thêm một file cấu hình để nói cho Claude Code biết cách khởi động hoặc truy cập máy chủ. Các hàm của dịch vụ sau đó xuất hiện như những công cụ mà AI có thể gọi.
Nội dung kỹ thuật (SKILL.md gốc)
Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.
MCP Integration for Claude Code Plugins
Overview
Model Context Protocol (MCP) enables Claude Code plugins to integrate with external services and APIs by providing structured tool access. Use MCP integration to expose external service capabilities as tools within Claude Code.
Key capabilities:
- Connect to external services (databases, APIs, file systems)
- Provide 10+ related tools from a single service
- Handle OAuth and complex authentication flows
- Bundle MCP servers with plugins for automatic setup
MCP Server Configuration Methods
Plugins can bundle MCP servers in two ways:
Method 1: Dedicated .mcp.json (Recommended)
Create .mcp.json at plugin root:
{
"database-tools": {
"command": "${CLAUDE_PLUGIN_ROOT}/servers/db-server",
"args": ["--config", "${CLAUDE_PLUGIN_ROOT}/config.json"],
"env": {
"DB_URL": "${DB_URL}"
}
}
}
Benefits:
- Clear separation of concerns
- Easier to maintain
- Better for multiple servers
Method 2: Inline in plugin.json
Add mcpServers field to plugin.json:
{
"name": "my-plugin",
"version": "1.0.0",
"mcpServers": {
"plugin-api": {
"command": "${CLAUDE_PLUGIN_ROOT}/servers/api-server",
"args": ["--port", "8080"]
}
}
}
Benefits:
- Single configuration file
- Good for simple single-server plugins
MCP Server Types
stdio (Local Process)
Execute local MCP servers as child processes. Best for local tools and custom servers.
Configuration:
{
"filesystem": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-filesystem", "/allowed/path"],
"env": {
"LOG_LEVEL": "debug"
}
}
}
Use cases:
- File system access
- Local database connections
- Custom MCP servers
- NPM-packaged MCP servers
Process management:
- Claude Code spawns and manages the process
- Communicates via stdin/stdout
- Terminates when Claude Code exits
SSE (Server-Sent Events)
Connect to hosted MCP servers with OAuth support. Best for cloud services.
Configuration:
{
"hosted-service": {
"type": "sse",
"url": "https://mcp.example.com/sse"
}
}
Use cases:
- Official hosted MCP servers (Asana, GitHub, etc.)
- Cloud services with MCP endpoints
- OAuth-based authentication
- No local installation needed
Authentication:
- OAuth flows handled automatically
- User prompted on first use
- Tokens managed by Claude Code
HTTP (REST API)
Connect to RESTful MCP servers with token authentication.
Configuration:
{
"api-service": {
"type": "http",
"url": "https://api.example.com/mcp",
"headers": {
"Authorization": "Bearer ${API_TOKEN}",
"X-Custom-Header": "value"
}
}
}
Use cases:
- REST API-based MCP servers
- Token-based authentication
- Custom API backends
- Stateless interactions
WebSocket (Real-time)
Connect to WebSocket MCP servers for real-time bidirectional communication.
Configuration:
{
"realtime-service": {
"type": "ws",
"url": "wss://mcp.example.com/ws",
"headers": {
"Authorization": "Bearer ${TOKEN}"
}
}
}
Use cases:
- Real-time data streaming
- Persistent connections
- Push notifications from server
- Low-latency requirements
Environment Variable Expansion
All MCP configurations support environment variable substitution:
${CLAUDE_PLUGIN_ROOT} - Plugin directory (always use for portability):
{
"command": "${CLAUDE_PLUGIN_ROOT}/servers/my-server"
}
User environment variables - From user's shell:
{
"env": {
"API_KEY": "${MY_API_KEY}",
"DATABASE_URL": "${DB_URL}"
}
}
Best practice: Document all required environment variables in plugin README.
MCP Tool Naming
When MCP servers provide tools, they're automatically prefixed:
Format: mcp__plugin_<plugin-name>_<server-name>__<tool-name>
Example:
- Plugin:
asana - Server:
asana - Tool:
create_task - Full name:
mcp__plugin_asana_asana__asana_create_task
Using MCP Tools in Commands
Pre-allow specific MCP tools in command frontmatter:
---
allowed-tools: [
"mcp__plugin_asana_asana__asana_create_task",
"mcp__plugin_asana_asana__asana_search_tasks"
]
---
Wildcard (use sparingly):
---
allowed-tools: ["mcp__plugin_asana_asana__*"]
---
Best practice: Pre-allow specific tools, not wildcards, for security.
Lifecycle Management
Câu hỏi thường gặp
Cấu hình máy chủ đặt ở đâu?
Nó có thể nằm trong file .mcp.json riêng ở thư mục gốc của plugin, hoặc bên trong file plugin.json.
Những loại máy chủ nào được đề cập?
Skill bao phủ máy chủ stdio cục bộ và máy chủ từ xa dùng SSE, HTTP hoặc WebSocket.
Nó có xử lý đăng nhập cho các dịch vụ đã kết nối không?
Skill có nhắc đến việc xử lý OAuth và các luồng xác thực phức tạp khác.
Chi tiết
Mô tả gốc của tác giả
This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context Protocol", "connect external service", mentions "${CLAUDE_PLUGIN_ROOT} with MCP", or discusses MCP server types (SSE, stdio, HTTP, WebSocket). Provides comprehensive guidance for integrating Model Context Protocol servers into Claude Code plugins for external tool and service integration.
Độ phổ biến
- Sao GitHub
- 46k
- Vị trí xếp hạng
- #6347
- Giấy phép
- Apache-2.0
- Cập nhật
- 2/11/2026
Bình luận
- …
Thêm skill từ kho mã này
access
46kCho phép bạn quản lý ai được nhắn tin với trợ lý qua kênh Discord, bao gồm duyệt ghép đôi và danh sách cho phép.
configure
46kThiết lập kênh Discord cho trợ lý của bạn bằng cách lưu bot token và kiểm tra ai có thể tiếp cận nó.
access
46kCho phép bạn quản lý ai được nhắn tin cho trợ lý qua kênh iMessage, bao gồm duyệt và danh sách cho phép.
configure
46kKiểm tra thiết lập kênh iMessage của bạn, gồm Full Disk Access, và giải thích ai có thể tiếp cận trợ lý của bạn.
Skill tương tự
mcporter
394kGiúp agent của bạn liệt kê, gọi và kiểm tra các máy chủ MCP cùng công cụ của chúng qua HTTP hoặc stdio, và quản lý cài đặt đăng nhập.
fastmcp
260kGiúp bạn xây dựng, kiểm thử và triển khai một máy chủ MCP bằng Python, cấp cho trợ lý AI quyền truy cập API, cơ sở dữ liệu hoặc file của bạn dưới dạng công cụ.
mcp-oauth-remote-gateway
260kHướng dẫn bạn đăng nhập OAuth cho máy chủ MCP từ xa khi Hermes chạy trên máy chủ, nơi đăng nhập bằng trình duyệt thông thường không thể truy cập được.