mcp-integration by anthropics/claude-plugins-official
npx skills add https://github.com/anthropics/claude-plugins-official --skill mcp-integration模型上下文协议(MCP)通过提供结构化的工具访问,使 Claude Code 插件能够与外部服务和 API 集成。使用 MCP 集成,可以将外部服务功能作为工具暴露在 Claude Code 内部。
核心功能:
插件可以通过两种方式捆绑 MCP 服务器:
在插件根目录创建 .mcp.json:
{
"database-tools": {
"command": "${CLAUDE_PLUGIN_ROOT}/servers/db-server",
"args": ["--config", "${CLAUDE_PLUGIN_ROOT}/config.json"],
"env": {
"DB_URL": "${DB_URL}"
}
}
}
优点:
在 plugin.json 中添加 mcpServers 字段:
{
"name": "my-plugin",
"version": "1.0.0",
"mcpServers": {
"plugin-api": {
"command": "${CLAUDE_PLUGIN_ROOT}/servers/api-server",
"args": ["--port", "8080"]
}
}
}
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
优点:
将本地 MCP 服务器作为子进程执行。最适合本地工具和自定义服务器。
配置:
{
"filesystem": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-filesystem", "/allowed/path"],
"env": {
"LOG_LEVEL": "debug"
}
}
}
使用场景:
进程管理:
连接到支持 OAuth 的托管 MCP 服务器。最适合云服务。
配置:
{
"asana": {
"type": "sse",
"url": "https://mcp.asana.com/sse"
}
}
使用场景:
身份验证:
连接到使用令牌身份验证的 RESTful MCP 服务器。
配置:
{
"api-service": {
"type": "http",
"url": "https://api.example.com/mcp",
"headers": {
"Authorization": "Bearer ${API_TOKEN}",
"X-Custom-Header": "value"
}
}
}
使用场景:
连接到 WebSocket MCP 服务器,实现实时双向通信。
配置:
{
"realtime-service": {
"type": "ws",
"url": "wss://mcp.example.com/ws",
"headers": {
"Authorization": "Bearer ${TOKEN}"
}
}
}
使用场景:
所有 MCP 配置都支持环境变量替换:
${CLAUDE_PLUGIN_ROOT} - 插件目录(始终使用以确保可移植性):
{
"command": "${CLAUDE_PLUGIN_ROOT}/servers/my-server"
}
用户环境变量 - 来自用户的 shell:
{
"env": {
"API_KEY": "${MY_API_KEY}",
"DATABASE_URL": "${DB_URL}"
}
}
最佳实践: 在插件 README 中记录所有必需的环境变量。
当 MCP 服务器提供工具时,它们会自动添加前缀:
格式: mcp__plugin_<插件名称>_<服务器名称>__<工具名称>
示例:
asanaasanacreate_taskmcp__plugin_asana_asana__asana_create_task在命令前置元数据中预先允许特定的 MCP 工具:
---
allowed-tools: [
"mcp__plugin_asana_asana__asana_create_task",
"mcp__plugin_asana_asana__asana_search_tasks"
]
---
通配符(谨慎使用):
---
allowed-tools: ["mcp__plugin_asana_asana__*"]
---
最佳实践: 出于安全考虑,预先允许特定工具,而不是使用通配符。
自动启动:
生命周期:
mcp__plugin_...__... 形式可用查看服务器: 使用 /mcp 命令查看所有服务器,包括插件提供的服务器。
OAuth 由 Claude Code 自动处理:
{
"type": "sse",
"url": "https://mcp.example.com/sse"
}
用户首次使用时在浏览器中进行身份验证。无需额外配置。
静态或环境变量令牌:
{
"type": "http",
"url": "https://api.example.com",
"headers": {
"Authorization": "Bearer ${API_TOKEN}"
}
}
在 README 中记录所需的环境变量。
将配置传递给 MCP 服务器:
{
"command": "python",
"args": ["-m", "my_mcp_server"],
"env": {
"DATABASE_URL": "${DB_URL}",
"API_KEY": "${API_KEY}",
"LOG_LEVEL": "info"
}
}
命令使用 MCP 工具并与用户交互:
# 命令:create-item.md
---
allowed-tools: ["mcp__plugin_name_server__create_item"]
---
步骤:
1. 从用户处收集项目详情
2. 使用 mcp__plugin_name_server__create_item
3. 确认创建
适用于: 在调用 MCP 之前添加验证或预处理。
代理自主使用 MCP 工具:
# 代理:data-analyzer.md
分析过程:
1. 通过 mcp__plugin_db_server__query 查询数据
2. 处理并分析结果
3. 生成洞察报告
适用于: 无需用户交互的多步骤 MCP 工作流。
集成多个 MCP 服务器:
{
"github": {
"type": "sse",
"url": "https://mcp.github.com/sse"
},
"jira": {
"type": "sse",
"url": "https://mcp.jira.com/sse"
}
}
适用于: 跨越多个服务的工作流。
始终使用安全连接:
✅ "url": "https://mcp.example.com/sse"
❌ "url": "http://mcp.example.com/sse"
应该:
不应该:
仅预先允许必要的 MCP 工具:
✅ allowed-tools: [
"mcp__plugin_api_server__read_data",
"mcp__plugin_api_server__create_item"
]
❌ allowed-tools: ["mcp__plugin_api_server__*"]
处理 MCP 服务器不可用的情况:
处理失败的 MCP 操作:
验证 MCP 配置:
MCP 服务器按需连接:
尽可能批量处理类似请求:
# 良好:使用过滤器的单个查询
tasks = search_tasks(project="X", assignee="me", limit=50)
# 避免:许多单独的查询
for id in task_ids:
task = get_task(id)
.mcp.json 中配置 MCP 服务器.claude-plugin/)/mcp 以验证服务器出现claude --debug 日志中的连接问题/mcp 输出中claude --debug
查找:
服务器未连接:
工具不可用:
/mcp 查看可用工具身份验证失败:
| 类型 | 传输方式 | 最适合 | 身份验证 |
|---|---|---|---|
| stdio | 进程 | 本地工具,自定义服务器 | 环境变量 |
| SSE | HTTP | 托管服务,云 API | OAuth |
| HTTP | REST | API 后端,令牌认证 | 令牌 |
| ws | WebSocket | 实时,流式传输 | 令牌 |
应该:
不应该:
有关详细信息,请查阅:
references/server-types.md - 每种服务器类型的深入探讨references/authentication.md - 身份验证模式和 OAuthreferences/tool-usage.md - 在命令和代理中使用 MCP 工具examples/ 中的工作示例:
stdio-server.json - 本地 stdio MCP 服务器sse-server.json - 带有 OAuth 的托管 SSE 服务器http-server.json - 带有令牌认证的 REST APIclaude --debug 和 /mcp 命令为插件添加 MCP 集成:
.mcp.json/mcp 命令在本地测试对于自定义/本地服务器,重点关注 stdio;对于带有 OAuth 的托管服务,重点关注 SSE。
每周安装量
326
代码仓库
GitHub 星标
9.6K
首次出现
2026年2月5日
安全审计
安装于
opencode281
codex280
gemini-cli278
github-copilot270
amp262
claude-code257
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:
Plugins can bundle MCP servers in two ways:
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:
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:
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:
Process management:
Connect to hosted MCP servers with OAuth support. Best for cloud services.
Configuration:
{
"asana": {
"type": "sse",
"url": "https://mcp.asana.com/sse"
}
}
Use cases:
Authentication:
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:
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:
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.
When MCP servers provide tools, they're automatically prefixed:
Format: mcp__plugin_<plugin-name>_<server-name>__<tool-name>
Example:
asanaasanacreate_taskmcp__plugin_asana_asana__asana_create_taskPre-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.
Automatic startup:
Lifecycle:
mcp__plugin_...__...Viewing servers: Use /mcp command to see all servers including plugin-provided ones.
OAuth handled automatically by Claude Code:
{
"type": "sse",
"url": "https://mcp.example.com/sse"
}
User authenticates in browser on first use. No additional configuration needed.
Static or environment variable tokens:
{
"type": "http",
"url": "https://api.example.com",
"headers": {
"Authorization": "Bearer ${API_TOKEN}"
}
}
Document required environment variables in README.
Pass configuration to MCP server:
{
"command": "python",
"args": ["-m", "my_mcp_server"],
"env": {
"DATABASE_URL": "${DB_URL}",
"API_KEY": "${API_KEY}",
"LOG_LEVEL": "info"
}
}
Commands use MCP tools with user interaction:
# Command: create-item.md
---
allowed-tools: ["mcp__plugin_name_server__create_item"]
---
Steps:
1. Gather item details from user
2. Use mcp__plugin_name_server__create_item
3. Confirm creation
Use for: Adding validation or preprocessing before MCP calls.
Agents use MCP tools autonomously:
# Agent: data-analyzer.md
Analysis Process:
1. Query data via mcp__plugin_db_server__query
2. Process and analyze results
3. Generate insights report
Use for: Multi-step MCP workflows without user interaction.
Integrate multiple MCP servers:
{
"github": {
"type": "sse",
"url": "https://mcp.github.com/sse"
},
"jira": {
"type": "sse",
"url": "https://mcp.jira.com/sse"
}
}
Use for: Workflows spanning multiple services.
Always use secure connections:
✅ "url": "https://mcp.example.com/sse"
❌ "url": "http://mcp.example.com/sse"
DO:
DON'T:
Pre-allow only necessary MCP tools:
✅ allowed-tools: [
"mcp__plugin_api_server__read_data",
"mcp__plugin_api_server__create_item"
]
❌ allowed-tools: ["mcp__plugin_api_server__*"]
Handle MCP server unavailability:
Handle failed MCP operations:
Validate MCP configuration:
MCP servers connect on-demand:
Batch similar requests when possible:
# Good: Single query with filters
tasks = search_tasks(project="X", assignee="me", limit=50)
# Avoid: Many individual queries
for id in task_ids:
task = get_task(id)
.mcp.json.claude-plugin/)/mcp to verify server appearsclaude --debug logs for connection issues/mcp outputclaude --debug
Look for:
Server not connecting:
Tools not available:
/mcp to see available toolsAuthentication failing:
| Type | Transport | Best For | Auth |
|---|---|---|---|
| stdio | Process | Local tools, custom servers | Env vars |
| SSE | HTTP | Hosted services, cloud APIs | OAuth |
| HTTP | REST | API backends, token auth | Tokens |
| ws | WebSocket | Real-time, streaming | Tokens |
DO:
DON'T:
For detailed information, consult:
references/server-types.md - Deep dive on each server typereferences/authentication.md - Authentication patterns and OAuthreferences/tool-usage.md - Using MCP tools in commands and agentsWorking examples in examples/:
stdio-server.json - Local stdio MCP serversse-server.json - Hosted SSE server with OAuthhttp-server.json - REST API with token authclaude --debug and /mcp commandTo add MCP integration to a plugin:
.mcp.json at plugin root with configuration/mcp commandFocus on stdio for custom/local servers, SSE for hosted services with OAuth.
Weekly Installs
326
Repository
GitHub Stars
9.6K
First Seen
Feb 5, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykWarn
Installed on
opencode281
codex280
gemini-cli278
github-copilot270
amp262
claude-code257
agent-browser 浏览器自动化工具 - Vercel Labs 命令行网页操作与测试
136,300 周安装
YouTube视频分析师 - 逆向分析病毒内容公式,提取钩子、留存机制与情感触发点
647 周安装
SQLiteData 使用指南:SwiftData 轻量级替代方案,支持 CloudKit 同步
CTF密码学挑战速查指南 | 经典/现代密码攻击、RSA/ECC/流密码实战技巧
648 周安装
Bitrefill CLI:让AI智能体自主购买数字商品,支持加密货币支付
Bilibili 字幕提取工具 - 支持 AI 字幕检测与 ASR 转录,一键下载视频字幕
648 周安装
assistant-ui thread-list 线程列表:管理多聊天线程的 React AI SDK 组件
649 周安装