원클릭으로
mcp-code-mode
MCP orchestration via TypeScript execution. Use Code Mode for ALL external MCP tool calls; ~98% context reduction, type-safe.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
메뉴
MCP orchestration via TypeScript execution. Use Code Mode for ALL external MCP tool calls; ~98% context reduction, type-safe.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
SOC 직업 분류 기준
Routes non-trivial requests to matching skills through standalone MCP metadata and stable advisor tool ids.
Unified spec-folder workflow + context preservation: Levels 1-3+, validation, Spec Kit Memory. Required for file modifications.
OpenCode CLI orchestrator: external dispatch, in-OpenCode parallel sessions, cross-AI handback with full runtime context.
Shared deep-loop runtime: executor + prompt-pack + validation + atomic state + coverage-graph + Bayesian scoring + fallback routing.
Iterative codebase-context-gathering deep loop. Runs a configurable pool over a shared scope in parallel (native-only by default; optional heterogeneous CLI seats) and synthesizes a reuse-first Context Report for planning/implementation. Use before /speckit:plan or /speckit:implement to map existing code, integration points, and conventions.
Unified deep-loop workflow skill: routes a request to one of five modes (context, research, review, ai-council, improvement) over the shared deep-loop-runtime backend. Holds no per-mode logic — it dispatches by workflowMode through mode-registry.json. Use for codebase-context gathering, autonomous research, iterative code review, multi-seat AI Council planning, and evaluator-first agent/model/skill/non-dev-system improvement.
| name | mcp-code-mode |
| description | MCP orchestration via TypeScript execution. Use Code Mode for ALL external MCP tool calls; ~98% context reduction, type-safe. |
| allowed-tools | ["mcp__code_mode__call_tool_chain","mcp__code_mode__list_tools","mcp__code_mode__search_tools","mcp__code_mode__tool_info"] |
| version | 1.0.7.0 |
Execute TypeScript code with direct access to 200+ MCP tools through progressive disclosure. Code Mode eliminates context overhead by loading tools on-demand, enabling complex multi-tool workflows in a single execution with state persistence and built-in error handling.
MANDATORY for ALL MCP tool calls:
Benefits over traditional tool calling:
Use native tools instead:
/speckit:resume first; only use native Spec Kit Memory tools after handover.md -> _memory.continuity -> spec docs has been exhausted)sequential_thinking_sequentialthinking() directly - NATIVE MCP)See Section 4 for details on Native MCP vs Code Mode distinction.
| Scenario | Code Mode Approach | Benefit |
|---|---|---|
| Create ClickUp task | call_tool_chain({ code: "await clickup.clickup_create_task({...})" }) | Type-safe, single execution |
| Multi-tool workflow | Figma → ClickUp → MyService in one execution | State persists, 5× faster |
| Browser automation | Chrome DevTools MCP for testing/screenshots | Sandboxed, reliable |
| Design-to-implementation | Fetch Figma design → Create task → Update CMS | Atomic workflow |
| External API access | Any MCP server (Notion, GitHub, etc.) | Progressive tool loading |
| Level | When to Load | Resources |
|---|---|---|
| ALWAYS | Every skill invocation | Core quick reference |
| CONDITIONAL | If intent signals match | Intent-mapped references |
| ON_DEMAND | Only on explicit request | Full configuration/workflows |
The authoritative routing logic for scoped loading, weighted intent scoring, and ambiguity handling.
discover_markdown_resources() recursively inventories references/ and assets/.load_if_available() guards paths, checks inventory, and de-duplicates with seen.UNKNOWN_FALLBACK returns a disambiguation checklist and missing matches return a "no knowledge base" notice.from pathlib import Path
SKILL_ROOT = Path(__file__).resolve().parent
RESOURCE_BASES = (SKILL_ROOT / "references", SKILL_ROOT / "assets")
DEFAULT_RESOURCE = "references/workflows.md"
INTENT_SIGNALS = {
"NAMING": {"weight": 4, "keywords": ["tool not found", "naming", "prefix", "format"]},
"SETUP": {"weight": 4, "keywords": ["setup", "install", "configure", ".utcp_config", ".env"]},
"VALIDATE": {"weight": 4, "keywords": ["validate", "validation", "check config", "schema"]},
"CATALOG": {"weight": 3, "keywords": ["what tools", "list tools", "discover tools", "catalog"]},
"WORKFLOW": {"weight": 3, "keywords": ["workflow", "orchestrate", "multi-tool", "error handling"]},
"ARCHITECTURE": {"weight": 2, "keywords": ["architecture", "token", "performance", "internals"]},
}
RESOURCE_MAP = {
"NAMING": ["references/naming_convention.md"],
"SETUP": ["references/configuration.md", "assets/config_template.md", "assets/env_template.md"],
"VALIDATE": ["references/configuration.md", "references/naming_convention.md"],
"CATALOG": ["references/tool_catalog.md"],
"WORKFLOW": ["references/workflows.md"],
"ARCHITECTURE": ["references/architecture.md"],
}
COMMAND_BOOSTS = {
"search_tools": "CATALOG",
"list_tools": "CATALOG",
"tool_info": "CATALOG",
"call_tool_chain": "WORKFLOW",
}
LOADING_LEVELS = {
"ALWAYS": [DEFAULT_RESOURCE],
"ON_DEMAND_KEYWORDS": ["full config", "deep dive", "full workflow", "all tools", "call_tool_chain", "tool chain", "mcp tools", "tool catalog", "code mode"],
"ON_DEMAND": ["references/configuration.md", "references/workflows.md"],
}
def _task_text(task) -> str:
parts = [
str(getattr(task, "query", "")),
str(getattr(task, "text", "")),
" ".join(getattr(task, "keywords", []) or []),
str(getattr(task, "command", "")),
]
return " ".join(parts).lower()
def _guard_in_skill(relative_path: str) -> str:
resolved = (SKILL_ROOT / relative_path).resolve()
resolved.relative_to(SKILL_ROOT)
if resolved.suffix.lower() != ".md":
raise ValueError(f"Only markdown resources are routable: {relative_path}")
return resolved.relative_to(SKILL_ROOT).as_posix()
def discover_markdown_resources() -> set[str]:
docs = []
for base in RESOURCE_BASES:
if base.exists():
docs.extend(p for p in base.rglob("*.md") if p.is_file())
return {doc.relative_to(SKILL_ROOT).as_posix() for doc in docs}
def score_intents(task) -> dict[str, float]:
"""Weighted intent scoring from request text and signals."""
text = _task_text(task)
scores = {intent: 0.0 for intent in INTENT_SIGNALS}
for intent, cfg in INTENT_SIGNALS.items():
for keyword in cfg["keywords"]:
if keyword in text:
scores[intent] += cfg["weight"]
command = str(getattr(task, "command", "")).lower()
for signal, intent in COMMAND_BOOSTS.items():
if signal in command:
scores[intent] += 4
return scores
def select_intents(scores: dict[str, float], ambiguity_delta: float = 1.0, max_intents: int = 2) -> list[str]:
ranked = sorted(scores.items(), key=lambda item: item[1], reverse=True)
if not ranked or ranked[0][1] <= 0:
return ["WORKFLOW"]
selected = [ranked[0][0]]
if len(ranked) > 1 and ranked[1][1] > 0 and (ranked[0][1] - ranked[1][1]) <= ambiguity_delta:
selected.append(ranked[1][0])
return selected[:max_intents]
def route_code_mode_resources(task):
inventory = discover_markdown_resources()
scores = score_intents(task)
intents = select_intents(scores, ambiguity_delta=1.0)
loaded = []
seen = set()
def load_if_available(relative_path: str) -> None:
guarded = _guard_in_skill(relative_path)
if guarded in inventory and guarded not in seen:
load(guarded)
loaded.append(guarded)
seen.add(guarded)
for relative_path in LOADING_LEVELS["ALWAYS"]:
load_if_available(relative_path)
if max(scores.values() or [0]) < 0.5:
return {
"routing_key": "code-mode",
"intents": intents,
"intent_scores": scores,
"load_level": "UNKNOWN_FALLBACK",
"needs_disambiguation": True,
"disambiguation_checklist": ["Confirm tool discovery, setup, validation, or workflow need", "Confirm target MCP/tool family", "Provide the tool call or error if available"],
"resources": loaded,
}
matched_intents = []
for intent in intents:
before_count = len(loaded)
for relative_path in RESOURCE_MAP.get(intent, []):
load_if_available(relative_path)
if len(loaded) > before_count:
matched_intents.append(intent)
text = _task_text(task)
if any(keyword in text for keyword in LOADING_LEVELS["ON_DEMAND_KEYWORDS"]):
for relative_path in LOADING_LEVELS["ON_DEMAND"]:
load_if_available(relative_path)
if not loaded:
load_if_available(DEFAULT_RESOURCE)
result = {"routing_key": "code-mode", "intents": intents, "intent_scores": scores, "resources": loaded}
if not matched_intents:
result["notice"] = f"No knowledge base found for intent(s): {', '.join(intents)}"
return result
The #1 most common error when using Code Mode is using wrong function names. All MCP tool calls MUST follow this pattern:
{manual_name}.{manual_name}_{tool_name}
Examples:
✅ Correct:
await myservice.myservice_sites_list({});
await clickup.clickup_create_task({...});
await figma.figma_get_file({...});
❌ Wrong (missing manual prefix):
await myservice.sites_list({}); // Error: Tool not found
await clickup.create_task({...}); // Error: Tool not found
See references/naming_convention.md for complete guide with troubleshooting.
Many Code Mode tools require a context parameter (15-25 words) for analytics:
await myservice.myservice_sites_list({
context: "Listing sites to identify collection structure for CMS update"
});
This helps with usage tracking and debugging.
Note:
list_tools()returns names ina.b.cformat (e.g.,myservice.myservice.sites_list). To call the tool, use underscore format:myservice.myservice_sites_list(). Thetool_info()function shows the correct calling syntax.
search_tools() or list_tools().tool_info().call_tool_chain() with {manual_name}.{manual_name}_{tool_name} calls.Full multi-tool examples live in references/workflows.md.
IMPORTANT: Code Mode only accesses tools in .utcp_config.json. Native MCP tools are NOT accessed through Code Mode.
1. Native MCP (opencode.json) - Direct tools (call directly, NOT through Code Mode):
sequential_thinking_sequentialthinking()/speckit:resume for recovery; native Spec Kit Memory tools such as session_bootstrap(), session_resume(), memory_context(), and memory_search() when canonical packet sources need deeper support2. Code Mode MCP (.utcp_config.json) - External tools accessed through Code Mode:
.utcp_config.json (project root).env (project root)call_tool_chain() wrapperThese discovery methods ONLY work for Code Mode tools in .utcp_config.json
They do NOT show Sequential Thinking (which is in .mcp.json)
Step 1: Check Configuration
// Read .utcp_config.json to see configured Code Mode MCP servers
// Look for "manual_call_templates" array
// Each object has a "name" field (this is the manual name)
// Check "disabled" field - if true, server is not active
// NOTE: Sequential Thinking is NOT in this file
// Sequential Thinking is in .mcp.json and called directly
Step 2: Use Progressive Discovery
// Search for Code Mode tools by description
const tools = await search_tools({
task_description: "browser automation",
limit: 10
});
// List all available Code Mode tools
const allTools = await list_tools();
// Get info about a specific Code Mode tool
const info = await tool_info({
tool_name: "server_name.server_name_tool_name"
});
// NOTE: These discovery tools are part of Code Mode
// They only show tools configured in .utcp_config.json
// Sequential Thinking will NOT appear in these results
See Section 3: Critical Naming Pattern for the complete guide.
Quick reminder: {manual_name}.{manual_name}_{tool_name} (e.g., myservice.myservice_sites_list())
Sequential Thinking Exception:
.utcp_config.json - uses native MCP toolssequential_thinking_sequentialthinking()call_tool_chain()Use .utcp_config.json with manual_call_templates[]; each entry defines the manual name, MCP server command/args/env, and disabled state. See references/configuration.md and assets/config_template.md.
⚠️ IMPORTANT: Code Mode prefixes ALL environment variables with
{manual_name}_from your configuration.
Example:
"name": "clickup" and env section references ${CLICKUP_API_KEY}.env file MUST use: clickup_CLICKUP_API_KEY=pk_xxxCLICKUP_API_KEY=pk_xxx will cause: Error: Variable 'clickup_CLICKUP_API_KEY' not foundQuick Reference:
| Manual Name | Config Reference | .env Variable |
|---|---|---|
clickup | ${CLICKUP_API_KEY} | clickup_CLICKUP_API_KEY |
figma | ${FIGMA_API_KEY} | figma_FIGMA_API_KEY |
notion | ${NOTION_TOKEN} | notion_NOTION_TOKEN |
See env_template.md for complete examples.
IMPORTANT: This only shows Code Mode servers in .utcp_config.json, NOT Sequential Thinking
Run list_tools() through Code Mode and group returned names by the prefix before the first dot. Sequential Thinking is native MCP and will not appear.
{manual_name}.{manual_name}_{tool_name} (see naming_convention.md)search_tools() before calling unknown tools{ success, data, errors, timestamp }myservice.sites_list instead of myservice.myservice_sites_listsearch_tools() to discover correct nameslist_tools() firstCode Mode implementation complete when:
call_tool_chain (no direct tool calls){manual_name}.{manual_name}_{tool_name} patternsearch_tools before calling).utcp_config.json and .env correct)This skill operates within the behavioral framework defined in AGENTS.md.
Key integrations:
skill_advisor.pyExternal Tool Integration:
Workflow: discover tools, call them inside one call_tool_chain() execution, return state for the caller, and surface errors explicitly.
Automatic activation when:
What Code Mode produces:
Use search_tools(), tool_info(), list_tools(), and call_tool_chain() as the core command set. For parallel execution, use Promise.all() when all calls must succeed and Promise.allSettled() when partial success is acceptable. Full examples live in references/workflows.md.
See Section 3: Critical Naming Pattern for the complete guide with examples.
Pattern: {manual_name}.{manual_name}_{tool_name}
The router discovers reference, asset, and script docs dynamically. Start with references/naming_convention.md, references/configuration.md, references/tool_catalog.md, references/workflows.md, references/architecture.md, assets/config_template.md, assets/env_template.md, then load task-specific resources from references/, templates from assets/, and automation from scripts/ when present.
Scripts: scripts/install.sh, scripts/update.sh, scripts/validate_config.py.
Related skills: mcp-chrome-devtools for browser debugging routes that can fall back to Code Mode.
Install guide: INSTALL_GUIDE.md.