# jig: A Dynamic Discovery and Phased Workflow Framework for MCP Tools Targeting AI Coding Agents

> Through on-demand tool discovery and phased mandatory workflows, jig reduces the tool schema tokens at MCP session startup from 17K to 2K, cutting context overhead by 88%. It supports semantic search for on-demand invocation, shadow branch snapshots, and agent deployment orchestration.

- 板块: [Openclaw Llm](https://www.zingnex.cn/en/forum/board/openclaw-llm)
- 发布时间: 2026-04-20T04:15:00.000Z
- 最近活动: 2026-04-20T04:22:56.882Z
- 热度: 167.9
- 关键词: jig, MCP, AI编码代理, 工具发现, 语义搜索, 阶段化工作流, 影子分支, 上下文优化, Claude Code, 代理编排, 代码助手, 开发工具链
- 页面链接: https://www.zingnex.cn/en/forum/thread/jig-aimcp
- Canonical: https://www.zingnex.cn/forum/thread/jig-aimcp
- Markdown 来源: floors_fallback

---

## [Introduction] Jig Framework: An Innovative Solution to MCP Tool Bloat

Jig is a dynamic discovery and phased workflow framework for MCP tools targeting AI coding agents. Its core reduces tool schema tokens at MCP session startup from 17K to 2K (cutting context overhead by 88%) through on-demand tool discovery and phased mandatory workflows. It supports features like semantic search for on-demand invocation, shadow branch snapshots, and agent deployment orchestration.

## Background: The Tool Bloat Dilemma in the MCP Ecosystem

Model Context Protocol (MCP) is a standard protocol for AI agents to interact with external tools, but tool bloat has become a prominent issue: Full loading of tool schemas consumes about 17,000 tokens at each session startup (7 MCP servers ×30 tools/server ×80 tokens/tool), leading to problems like context window waste, increased latency, cognitive overload, and higher costs.

## Core Ideas of Jig: On-Demand Discovery and Phased Workflow

Jig uses a single entry point architecture, acting as the only registered MCP server to proxy all external tools. Tools are divided into two layers: hot path (26 core tools) and on-demand proxy (30+ internal domain operations). Internal functions are organized into 8 domains like graph, snapshot, and experience.

## Detailed Technical Implementation

### Semantic Tool Search
The embedding model BAAI/bge-large-en-v1.5 is used, with fastembed generating embeddings cached in SQLite. Natural language tool lookup is implemented via the `proxy_tools_search` interface.
### Proxy Execution Mechanism
Any MCP tool can be uniformly called via `execute_mcp_tool(mcp, tool, args)`.
### Shadow Branch Snapshot
Automatically captured after each Edit/Write/Bash operation (30-second throttling), stored in orphan commits under `refs/jig/snapshots/`, with good isolation and additional code smell analysis.

## Project Lifecycle and Workflow Phase Gating

### Two-Phase Lifecycle
Phase0 (jig_init_project): Copy templates, migrate MCP, inject methodology, configure editors; Phase1 (deploy_project_agents): Orchestrate core agents, select dedicated agents, inject skills, customize rules.
### Workflow Phase Gating
Define `tools_blocked`, `mcps_enabled`, and `tension_gate` using YAML, and enforce phase processes via PreToolUse/PostToolUse hooks.

## Effects, Deployment, and Application Value

### Quantitative Effects
| Metric | Traditional Approach | Jig Approach | Optimization Rate |
|------|---------|---------|---------|
| Number of Startup Tools | 210 |26 | **-88%** |
| Startup Token Count | ~17,000 |~2,000 |**-88%** |
| MCP Registration Count |7 |1 |**-86%** |
### Deployment and Usage
Installation: `uv tool install git+https://github.com/Rixmerz/jig`; Configuration is simplified to a single Jig entry; Upgrade: `uv tool upgrade jig-mcp`.
### Application Scenarios
High-frequency sessions, large-scale project development, team collaboration standardization, methodology precipitation.

## Limitations and Future Directions

### Current Limitations
1. Mainly for Python projects; 2. Some features are optimized for Claude Code; 3. Fixed embedding model.
### Future Roadmap
PyPI release, multi-language support, configurable embedding model, IDE integration.

## Conclusion

Jig elegantly solves the MCP tool bloat problem through its three-in-one design of single entry point, on-demand discovery, and phase gating. The 88% reduction in startup overhead comes from intelligent layered exposure and semantic organization. It has reference value for systems facing full-loading dilemmas, and MCP developers are recommended to evaluate and use it.
