AgentSkillsCN

mcp-management

MCP 工具路由与执行技能。通过节省 Token 的隔离机制,实现 MCP 工具的高效路由。借助语义 AI 分类,支持任意 MCP 配置。可在 .opencode/mcp-tools.json 中缓存工具,以实现快速的工具发现。

SKILL.md
--- frontmatter
name: mcp-management
description: >-
  MCP tool routing and execution skill. Enables efficient routing of MCP tools
  with token-saving isolation. Uses semantic AI categorization to support ANY
  MCP configuration. Cache at .opencode/mcp-tools.json for fast tool discovery.
compatibility: "OpenCode with any MCP server"
metadata:
  author: Sisyphus
  version: "2.0.0"

MCP Management Skill

Version: 2.0.0 | Architecture: 3-Tier Progressive Disclosure | Categorization: Semantic AI

Overview

This skill enables the mcp-manager agent to efficiently route and execute MCP (Model Context Protocol) tools. By isolating MCP tool definitions in a dedicated subagent context, we reduce main agent token usage by 80-95%.

When to Use This Skill

TriggerCategoryExample
Browser automationbrowser"Take a screenshot", "Click the login button"
GitHub operationsgithub"Get PR #123 details", "List open issues"
GraphQL queriesgraphql"Get the schema", "List available mutations"
Documentation lookupdocs"How do I use useState?", "Find React docs"
Complex reasoningreasoning"Analyze this step by step"

Quick Reference

Tool Categories (AI-Generated)

Categories are generated by /mcp-refresh using semantic AI analysis. Common categories include:

CategoryDescriptionExample Tools
browser-automationWeb interaction, screenshots, DOMclick, screenshot, navigate
version-controlGit, PRs, issues, code reviewget_pull_request, list_issues
documentationLibrary docs, API referencesquery-docs, resolve-library-id
communicationMessaging, notificationspost_message, list_channels
databaseSQL queries, data operationsquery, insert, update

Note: Your actual categories depend on your MCP configuration. Run /mcp-refresh to generate.

Most Common Tools

TaskToolCategory
Screenshottake_screenshotbrowser
Click elementclickbrowser
Fill formfill, fill_formbrowser
Navigatenavigate_pagebrowser
Get page contenttake_snapshotbrowser
Get PR detailsget_pull_requestgithub
List issueslist_issuesgithub
Search codesearch_codegithub
Query docsquery-docsdocs
Step-by-step analysissequentialthinkingreasoning

Routing Decision Tree

code
Task received
│
├─ Explicit tool name mentioned?
│  └─ YES → Use that tool directly
│
├─ Read .opencode/mcp-tools.json cache
│  └─ Match task keywords against category keywords
│
├─ Multiple categories match?
│  └─ YES → Prefer category with more keyword matches
│
└─ No match?
   └─ Search tool descriptions or ask for clarification

Cache Usage

Location: .opencode/mcp-tools.json

If Cache Exists

  1. Read and parse JSON (v2.0.0 schema)
  2. Use categories for keyword-based routing
  3. Use tools map for O(1) tool lookup
  4. Check generated_at - if >24h old, suggest /mcp-refresh

If Cache Missing

  1. Inform user: "Run /mcp-refresh to create tool cache"
  2. Fall back to dynamic tool discovery (slower)

Full cache schema: tool-execution.md

Execution Flow

  1. Parse Intent → Extract keywords from task
  2. Match Category → Find best category match
  3. Select Tool → Choose specific tool within category
  4. Execute → Call tool with mapped parameters
  5. Summarize → Return concise result to main agent

Detailed patterns: tool-execution.md

Result Handling

Summarization Rules

Result TypeAction
Large (>1000 chars)Extract key info only
File operations"File X read/written successfully (N chars)"
Data queries"Found N items. First 3: [...]"
Screenshots"Screenshot saved to /path"
ErrorsInclude error + suggestions

Always Include

  • Success/failure status
  • Key identifiers (IDs, paths, URLs)
  • Count of items (for lists)
  • Actionable next steps
  • Error details (if failed)

Full patterns: result-handling.md

Error Recovery

ErrorRecovery
Tool not foundSuggest similar tools
Execution failedInclude context + retry suggestions
TimeoutReport partial result + suggestions
Cache missingPrompt /mcp-refresh

Full recovery procedures: error-handling.md

Example Invocations

Browser: Take Screenshot

code
Task: "Take a screenshot of the current page"
Tool: MetaMCP_chrome-devtools__take_screenshot
Result: "Screenshot saved to ./screenshot.png"

GitHub: Get PR

code
Task: "Get details of PR #123 in owner/repo"
Tool: MetaMCP_github-zengaming__get_pull_request
Params: { owner: "owner", repo: "repo", pull_number: 123 }
Result: "PR #123: 'Fix bug' by @user, open, +50/-20, 3 files"

Docs: Query Library

code
Task: "How do I use useState in React?"
1. MetaMCP_context7__resolve-library-id → "/facebook/react"
2. MetaMCP_context7__query-docs → Usage examples
Result: "useState returns [state, setState]. Example: ..."

Reference Documentation

DocumentContentWhen to Read
tool-categories.mdFull tool lists per categoryNeed specific tool
tool-execution.mdRouting algorithm, cache schemaComplex routing
result-handling.mdSummarization patternsLarge results
error-handling.mdRecovery proceduresErrors occur

Best Practices

  1. Prefer Cached Routing - Always check cache first
  2. Batch Operations - Execute related operations in sequence
  3. Summarize Aggressively - Main agent needs actions, not data
  4. Fail Fast - Ask for clarification rather than guessing
  5. Include Context - Errors should be actionable