Consolidate 31 legacy tools into 4 namespace-scoped gateway tools for an 83% reduction in tools/list token overhead — from ~4,250 tokens to ~725 tokens per conversation.
When an MCP client connects, it calls tools/list to discover available tools. The response includes tool names, descriptions, and full JSON schemas. With 31 legacy action tools registered separately, that overhead adds up fast.
The repoId field is hoisted to the envelope level (shared across all actions in a namespace), and the action field selects which handler processes the call.
Gateway requests also accept common field aliases. For example, repo_id, repo, root_path, task_text, edited_files, symbol_id, and slice_handle all normalize to their canonical names before strict validation.
Safety is preserved through two validation passes:
Agent Call │ ▼┌─────────────────────┐│ Gateway Schema │ Discriminated union on `action`│ (cheap first-pass) │ Catches wrong action names, type errors└──────────┬──────────┘ │ ▼┌─────────────────────┐│ Router │ Extracts action, merges repoId│ │ Looks up handler from ActionMap└──────────┬──────────┘ │ ▼┌─────────────────────┐│ Original Zod Schema │ Strict second-pass validation│ (per-handler) │ Identical to flat-mode validation└──────────┬──────────┘ │ ▼┌─────────────────────┐│ Handler Function │ Same handler as flat mode│ │ Zero behavioral difference└─────────────────────┘
The thin wire schema catches obvious errors (wrong action name, wrong field type) cheaply. The full per-handler Zod schema then applies the same strict validation as flat mode. Handlers are identical — gateway mode changes only the registration surface, not behavior.
Gateway mode optimizes tool registration overhead. Code Mode goes further by eliminating per-operation round-trip overhead — batching entire context retrieval pipelines into a single tool call.sdl.chain accepts a steps array where each step can reference results from previous steps using $N.path notation:
This search → card → skeleton pipeline runs in a single MCP call instead of three. Budget tracking, ETag caching, and context ladder validation all still apply inside sdl.chain — Code Mode does not bypass SDL-MCP’s governance layer.