mcp-management
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseMCP Management
MCP管理
Skill for managing and interacting with Model Context Protocol (MCP) servers.
用于管理和与Model Context Protocol (MCP)服务器交互的Skill。
Overview
概述
MCP is an open protocol enabling AI agents to connect to external tools and data sources. This skill provides scripts and utilities to discover, analyze, and execute MCP capabilities from configured servers without polluting the main context window.
Key Benefits:
- Progressive disclosure of MCP capabilities (load only what's needed)
- Intelligent tool/prompt/resource selection based on task requirements
- Multi-server management from single config file
- Context-efficient: subagents handle MCP discovery and execution
- Persistent tool catalog: automatically saves discovered tools to JSON for fast reference
MCP是一种开放协议,允许AI agents连接到外部工具和数据源。本Skill提供脚本和实用程序,可从已配置的服务器中发现、分析和执行MCP功能,同时不会占用主上下文窗口的空间。
核心优势:
- 渐进式披露MCP功能(仅加载所需内容)
- 根据任务需求智能选择工具/提示词/资源
- 通过单个配置文件管理多台服务器
- 高效上下文:由子代理处理MCP发现和执行
- 持久化工具目录:自动将发现的工具保存到JSON中以便快速参考
When to Use This Skill
适用场景
Use this skill when:
- Discovering MCP Capabilities: Need to list available tools/prompts/resources from configured servers
- Task-Based Tool Selection: Analyzing which MCP tools are relevant for a specific task
- Executing MCP Tools: Calling MCP tools programmatically with proper parameter handling
- MCP Integration: Building or debugging MCP client implementations
- Context Management: Avoiding context pollution by delegating MCP operations to subagents
在以下场景中使用本Skill:
- 发现MCP功能:需要列出已配置服务器中的可用工具/提示词/资源
- 基于任务的工具选择:分析哪些MCP工具与特定任务相关
- 执行MCP工具:通过编程方式调用MCP工具并处理参数
- MCP集成:构建或调试MCP客户端实现
- 上下文管理:通过将MCP操作委托给子代理来避免上下文污染
Core Capabilities
核心功能
1. Configuration Management
1. 配置管理
MCP servers configured in .
.claude/.mcp.jsonGemini CLI Integration (recommended): Create symlink to :
.gemini/settings.jsonbash
mkdir -p .gemini && ln -sf .claude/.mcp.json .gemini/settings.jsonSee references/configuration.md and references/gemini-cli-integration.md.
MCP服务器配置存储在中。
.claude/.mcp.jsonGemini CLI集成(推荐):创建指向的符号链接:
.gemini/settings.jsonbash
mkdir -p .gemini && ln -sf .claude/.mcp.json .gemini/settings.json详情请参阅references/configuration.md和references/gemini-cli-integration.md。
2. Capability Discovery
2. 功能发现
bash
npx tsx scripts/cli.ts list-tools # Saves to assets/tools.json
npx tsx scripts/cli.ts list-prompts
npx tsx scripts/cli.ts list-resourcesAggregates capabilities from multiple servers with server identification.
bash
npx tsx scripts/cli.ts list-tools # 保存到assets/tools.json
npx tsx scripts/cli.ts list-prompts
npx tsx scripts/cli.ts list-resources汇总多台服务器的功能并标记来源服务器。
3. Intelligent Tool Analysis
3. 智能工具分析
LLM analyzes directly - better than keyword matching algorithms.
assets/tools.jsonLLM直接分析——比关键词匹配算法更高效。
assets/tools.json4. Tool Execution
4. 工具执行
Primary: Gemini CLI (if available)
bash
gemini -y -m gemini-2.5-flash -p "Take a screenshot of https://example.com"Secondary: Direct Scripts
bash
npx tsx scripts/cli.ts call-tool memory create_entities '{"entities":[...]}'Fallback: mcp-manager Subagent
See references/gemini-cli-integration.md for complete examples.
首选:Gemini CLI(若可用)
bash
gemini -y -m gemini-2.5-flash -p "Take a screenshot of https://example.com"备选:直接脚本
bash
npx tsx scripts/cli.ts call-tool memory create_entities '{"entities":[...]}'Fallback:mcp-manager子代理
完整示例请参阅references/gemini-cli-integration.md。
Implementation Patterns
实现模式
Pattern 1: Gemini CLI Auto-Execution (Primary)
模式1:Gemini CLI自动执行(首选)
Use Gemini CLI for automatic tool discovery and execution. See references/gemini-cli-integration.md for complete guide.
Quick Example:
bash
gemini -y -m gemini-2.5-flash -p "Take a screenshot of https://example.com"Benefits: Automatic tool discovery, natural language execution, faster than subagent orchestration.
使用Gemini CLI进行自动工具发现和执行。完整指南请参阅references/gemini-cli-integration.md。
快速示例:
bash
gemini -y -m gemini-2.5-flash -p "Take a screenshot of https://example.com"优势:自动工具发现、自然语言执行、比子代理编排更快。
Pattern 2: Subagent-Based Execution (Fallback)
模式2:基于子代理的执行(备选)
Use agent when Gemini CLI unavailable. Subagent discovers tools, selects relevant ones, executes tasks, reports back.
mcp-managerBenefit: Main context stays clean, only relevant tool definitions loaded when needed.
当Gemini CLI不可用时,使用代理。子代理会发现工具、选择相关工具、执行任务并返回结果。
mcp-manager优势:主上下文保持整洁,仅在需要时加载相关工具定义。
Pattern 3: LLM-Driven Tool Selection
模式3:LLM驱动的工具选择
LLM reads , intelligently selects relevant tools using context understanding, synonyms, and intent recognition.
assets/tools.jsonLLM读取,利用上下文理解、同义词和意图识别智能选择相关工具。
assets/tools.jsonPattern 4: Multi-Server Orchestration
模式4:多服务器编排
Coordinate tools across multiple servers. Each tool knows its source server for proper routing.
协调多台服务器上的工具。每个工具都知道其来源服务器,以便正确路由。
Scripts Reference
脚本参考
scripts/mcp-client.ts
scripts/mcp-client.ts
Core MCP client manager class. Handles:
- Config loading from
.claude/.mcp.json - Connecting to multiple MCP servers
- Listing tools/prompts/resources across all servers
- Executing tools with proper error handling
- Connection lifecycle management
核心MCP客户端管理类。负责:
- 从加载配置
.claude/.mcp.json - 连接到多台MCP服务器
- 列出所有服务器中的工具/提示词/资源
- 执行工具并处理错误
- 连接生命周期管理
scripts/cli.ts
scripts/cli.ts
Command-line interface for MCP operations. Commands:
- - Display all tools and save to
list-toolsassets/tools.json - - Display all prompts
list-prompts - - Display all resources
list-resources - - Execute a tool
call-tool <server> <tool> <json>
Note: persists complete tool catalog to with full schemas for fast reference, offline browsing, and version control.
list-toolsassets/tools.jsonMCP操作的命令行界面。支持的命令:
- - 显示所有工具并保存到
list-toolsassets/tools.json - - 显示所有提示词
list-prompts - - 显示所有资源
list-resources - - 执行工具
call-tool <server> <tool> <json>
注意:会将完整的工具目录(包含完整模式)持久化到中,以便快速参考、离线浏览和版本控制。
list-toolsassets/tools.jsonQuick Start
快速开始
Method 1: Gemini CLI (recommended)
bash
npm install -g gemini-cli
mkdir -p .gemini && ln -sf .claude/.mcp.json .gemini/settings.json
gemini -y -m gemini-2.5-flash -p "Take a screenshot of https://example.com"Method 2: Scripts
bash
cd .claude/skills/mcp-management/scripts && npm install
npx tsx cli.ts list-tools # Saves to assets/tools.json
npx tsx cli.ts call-tool memory create_entities '{"entities":[...]}'Method 3: mcp-manager Subagent
See references/gemini-cli-integration.md for complete guide.
方法1:Gemini CLI(推荐)
bash
npm install -g gemini-cli
mkdir -p .gemini && ln -sf .claude/.mcp.json .gemini/settings.json
gemini -y -m gemini-2.5-flash -p "Take a screenshot of https://example.com"方法2:脚本
bash
cd .claude/skills/mcp-management/scripts && npm install
npx tsx cli.ts list-tools # 保存到assets/tools.json
npx tsx cli.ts call-tool memory create_entities '{"entities":[...]}'方法3:mcp-manager子代理
完整指南请参阅references/gemini-cli-integration.md。
Technical Details
技术细节
See references/mcp-protocol.md for:
- JSON-RPC protocol details
- Message types and formats
- Error codes and handling
- Transport mechanisms (stdio, HTTP+SSE)
- Best practices
请参阅references/mcp-protocol.md了解:
- JSON-RPC协议细节
- 消息类型和格式
- 错误代码和处理
- 传输机制(stdio、HTTP+SSE)
- 最佳实践
Integration Strategy
集成策略
Execution Priority
执行优先级
-
Gemini CLI (Primary): Fast, automatic, intelligent tool selection
- Check:
command -v gemini - Execute:
gemini -y -m gemini-2.5-flash -p "<task>" - Best for: All tasks when available
- Check:
-
Direct CLI Scripts (Secondary): Manual tool specification
- Use when: Need specific tool/server control
- Execute:
npx tsx scripts/cli.ts call-tool <server> <tool> <args>
-
mcp-manager Subagent (Fallback): Context-efficient delegation
- Use when: Gemini unavailable or failed
- Keeps main context clean
-
Gemini CLI(首选):快速、自动、智能工具选择
- 检查:
command -v gemini - 执行:
gemini -y -m gemini-2.5-flash -p "<task>" - 最佳适用场景:所有可用场景
- 检查:
-
直接CLI脚本(备选):手动指定工具
- 适用场景:需要特定工具/服务器控制时
- 执行:
npx tsx scripts/cli.ts call-tool <server> <tool> <args>
-
mcp-manager子代理(Fallback):高效上下文委托
- 适用场景:Gemini不可用或执行失败时
- 保持主上下文整洁
Integration with Agents
与Agents的集成
The agent uses this skill to:
mcp-manager- Check Gemini CLI availability first
- Execute via command if available
gemini - Fallback to direct script execution
- Discover MCP capabilities without loading into main context
- Report results back to main agent
This keeps main agent context clean and enables efficient MCP integration.
mcp-manager- 首先检查Gemini CLI是否可用
- 若可用则通过命令执行
gemini - 若不可用则回退到直接脚本执行
- 发现MCP功能而不加载到主上下文
- 将结果返回给主代理
这样可以保持主代理上下文整洁,并实现高效的MCP集成。