โ† Back to list
ShunsukeHayashi

mcp-context-optimizer

by ShunsukeHayashi

๐Ÿค– First open-source, economically-governed, beginner-friendly autonomous development framework built on Issue-Driven Development | ่ถ…ๅˆๅฟƒ่€…ใงใ‚‚ไฝฟใˆใ‚‹่‡ชๅพ‹ๅž‹้–‹็™บใƒ•ใƒฌใƒผใƒ ใƒฏใƒผใ‚ฏ

โญ 13๐Ÿด 8๐Ÿ“… Jan 24, 2026

SKILL.md


name: mcp-context-optimizer description: Optimize MCP tool context loading through progressive disclosure and hierarchical indexing. Use when working with large MCP tool sets (e.g., Miyabi's 172 tools) to prevent context window bloat. Triggers include "find tool", "search mcp", "tool lookup", "which tool", "context optimization", or when dealing with many MCP tools. version: 1.0.0 author: Miyabi

MCP Context Optimizer

Solve the context window bloat problem when working with large MCP tool collections through progressive disclosure and hierarchical indexing.

Problem Statement

Large MCP implementations (like Miyabi with 172 tools across 22 categories) can overwhelm the context window:

  • All tool definitions load into main context
  • Token consumption increases dramatically
  • Risk of selecting wrong tools
  • Slower response times

Solution: Progressive Disclosure Pattern

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  Level 1: Category Index (Always Loaded)                    โ”‚
โ”‚  ~200 tokens - 22 categories with descriptions              โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚  Level 2: Tool Index (On-Demand)                            โ”‚
โ”‚  ~50 tokens per category - tool names + short descriptions  โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚  Level 3: Full Tool Schema (On-Demand)                      โ”‚
โ”‚  Variable - complete parameters and usage                   โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Quick Reference: Miyabi MCP Categories

CategoryCountPrimary Use Case
github21Issues, PRs, workflows, releases
git19Version control operations
network15Connectivity, diagnostics
process14Process management
tmux10Terminal multiplexer
resource10CPU, memory, disk monitoring
file10File operations
docker10Container management
speckit9Spec-driven development
claude8Claude Code session
log7Log analysis
k8s6Kubernetes
db6Database operations
compose4Docker Compose
time4Time utilities
gen4UUID, password, hash
linux3Systemd services
mcp3Tool discovery
calc3Math calculations
think3Reasoning chains
windows2Windows services
health1System health

Workflow: Tool Discovery Protocol

Step 1: Identify Category

User Request โ†’ Parse Intent โ†’ Match Category

Category Matching Rules:

  • Git operations (commit, branch, diff) โ†’ git
  • GitHub (PR, issue, workflow) โ†’ github
  • Container (docker run, logs) โ†’ docker
  • System monitoring (CPU, memory) โ†’ resource
  • File operations (read, search) โ†’ file
  • Network (ping, port check) โ†’ network

Step 2: Search Within Category

// Use mcp_search_tools with category filter
miyabi:mcp_search_tools({
  category: "docker",
  query: "logs"  // optional refinement
})

Step 3: Get Full Tool Info

// Only load full schema when needed
miyabi:mcp_get_tool_info({
  tool: "docker_logs"
})

Implementation Patterns

Pattern 1: Intent-Based Routing

## User says: "Check container logs for errors"

1. Parse: container + logs โ†’ category: docker
2. Search: mcp_search_tools(category: "docker", query: "logs")
3. Result: docker_logs tool
4. Load: mcp_get_tool_info("docker_logs")
5. Execute: docker_logs(container: "x", tail: 100)

Pattern 2: Multi-Category Workflow

## User says: "Deploy and verify"

1. Parse: deploy โ†’ docker/compose, verify โ†’ health/network
2. Workflow:
   a. compose_up (compose category)
   b. network_port_check (network category)
   c. docker_logs (docker category)
   d. health_check (health category)
## When category unclear:

1. Use broad search: mcp_search_tools(query: "user's keywords")
2. Review results
3. Narrow if needed

Best Practices

DO:

  • โœ… Start with category identification
  • โœ… Use mcp_search_tools before loading full schemas
  • โœ… Cache frequently used tool info in conversation
  • โœ… Combine related tools in single workflow

DON'T:

  • โŒ Load all 172 tool definitions upfront
  • โŒ Guess tool names without searching
  • โŒ Repeat tool info lookups in same conversation
  • โŒ Use broad search when category is known

Tool Discovery Commands

List All Categories

miyabi:mcp_list_categories()

Search Tools

miyabi:mcp_search_tools({
  category: "git",      // optional filter
  query: "branch"       // optional keyword
})

Get Tool Details

miyabi:mcp_get_tool_info({
  tool: "git_branch_list"
})

Context Budget Guidelines

ScenarioToken BudgetStrategy
Simple task~500Direct tool call
Multi-step~1000Category + 2-3 tools
Complex workflow~2000Full tool chain
Exploration~300Category list only

Integration with Other Skills

With full-dev-cycle Skill

1. mcp-context-optimizer identifies tools
2. full-dev-cycle executes workflow
3. Progressive loading throughout

With miyabi-agent-orchestration

1. Lead agent uses optimizer for tool selection
2. Sub-agents receive only needed tool schemas
3. Reduced context per agent

Troubleshooting

"Can't find the right tool"

  1. Check category mapping above
  2. Try broader search query
  3. List all tools in suspected category

"Context too large"

  1. Use mcp_list_categories first (lowest token cost)
  2. Filter by category before detailed search
  3. Don't request tool info until needed

"Tool doesn't exist"

  1. Verify category with mcp_list_categories
  2. Search without typos
  3. Check if tool is platform-specific (linux/windows)

Metrics for Success

  • Token Reduction: 60-80% vs loading all tools
  • Accuracy: Higher tool selection accuracy
  • Speed: Faster response with targeted loading
  • Scalability: Works with 100+ tools

Future Enhancements

  • Auto-categorization from natural language
  • Tool usage frequency caching
  • Cross-category tool suggestions
  • Workflow template library

Score

Total Score

75/100

Based on repository quality metrics

โœ“SKILL.md

SKILL.mdใƒ•ใ‚กใ‚คใƒซใŒๅซใพใ‚Œใฆใ„ใ‚‹

+20
โœ“LICENSE

ใƒฉใ‚คใ‚ปใƒณใ‚นใŒ่จญๅฎšใ•ใ‚Œใฆใ„ใ‚‹

+10
โœ“่ชฌๆ˜Žๆ–‡

100ๆ–‡ๅญ—ไปฅไธŠใฎ่ชฌๆ˜ŽใŒใ‚ใ‚‹

+10
โ—‹ไบบๆฐ—

GitHub Stars 100ไปฅไธŠ

0/15
โœ“ๆœ€่ฟ‘ใฎๆดปๅ‹•

1ใƒถๆœˆไปฅๅ†…ใซๆ›ดๆ–ฐ

+10
โ—‹ใƒ•ใ‚ฉใƒผใ‚ฏ

10ๅ›žไปฅไธŠใƒ•ใ‚ฉใƒผใ‚ฏใ•ใ‚Œใฆใ„ใ‚‹

0/5
โœ“Issue็ฎก็†

ใ‚ชใƒผใƒ—ใƒณIssueใŒ50ๆœชๆบ€

+5
โœ“่จ€่ชž

ใƒ—ใƒญใ‚ฐใƒฉใƒŸใƒณใ‚ฐ่จ€่ชžใŒ่จญๅฎšใ•ใ‚Œใฆใ„ใ‚‹

+5
โœ“ใ‚ฟใ‚ฐ

1ใคไปฅไธŠใฎใ‚ฟใ‚ฐใŒ่จญๅฎšใ•ใ‚Œใฆใ„ใ‚‹

+5

Reviews

๐Ÿ’ฌ

Reviews coming soon