Dependency-Complete Tool Discovery for Versioned MCP Enterprise Agents

Standard lexical and history-based tool retrieval regularly pulls a target MCP operation while omitting prerequisite auth, schema, or state-mutation tools. arXiv:2612.01375 formalizes version-conditioned executable support and evaluates dependency-guided discovery with source-bound index reuse across 72 contexts and 336 enterprise lifecycles, jumping feasible support from 30/72 to 60/72 while cutting logical index input by 35.93%.
Dependency-Complete Tool Discovery for Versioned MCP Enterprise Agents: Standard lexical and history-based tool retrieval regularly pulls a target MCP operation while omitting prerequisite auth, schema, or state-mutation tools. arXiv:2612.01375 formalizes version-conditioned executable support and evaluates dependency-guided discovery with source-bound index reuse across 72 contexts and 336 enterprise lifecycles, jumping feasible support from 30/72 to 60/72 while cutting logical index input by 35.93%. Designed as a zero-dependency, open-source TypeScript architecture under the MIT License with native Model Context Protocol (MCP) support and deterministic phase state machines.
- 2x Executable Support Coverage: Dependency-guided expansion reaches 72/72 old-version and 60/72 revised-version support (100% of feasible tasks) versus 36/72 and 30/72 for lexical retrieval.
- 35.93% Lower Indexing Input: Source-bound incremental index reuse retains unchanged tool bodies across catalog revisions without sacrificing contract safety.
- Clean Separation of Infeasibility vs Search Failure: Distinguishes missing capability, exposure-cap exhaustion, and unresolved retrieval before the LLM wastes turns.
- Production-Validated on Real Domains: Tested across public ticket, trading, retail, and airline catalogs with Qwen3-32B (19/24 full, 18/24 cached) and Llama-3.1-70B-Instruct.
import { createAgent } from '@smoke-monkey/harness';// Source-bound MCP tool closure resolver before binding tools into Smoke Monkey Harnessinterface ToolNode {name: string;versionDigest: string;requires: string[];}function expandDependencyClosure(seeds: string[], catalog: Record<string, ToolNode>, cap = 24): string[] {const closure = new Set<string>();const queue = [...seeds];while (queue.length > 0 && closure.size < cap) {const id = queue.shift()!;if (closure.has(id) || !catalog[id]) continue;closure.add(id);for (const dep of catalog[id].requires) {if (!closure.has(dep)) queue.push(dep);}}return [...closure];}const agent = createAgent({agentId: 'dependency-verified-mcp-runner',provider: 'openai-compatible',model: 'Qwen/Qwen3-32B',baseUrl: process.env.VLLM_BASE_URL || 'http://127.0.0.1:8000/v1',apiKey: process.env.VLLM_API_KEY || 'local-key',workspacePath: process.cwd(),permissions: {read_file: 'allow',write_file: 'allow',run_command: 'ask',},});async function main() {const catalog: Record<string, ToolNode> = {book_flight: { name: 'book_flight', versionDigest: 'sha256:9b1a', requires: ['authenticate_session', 'lock_fare_quote'] },lock_fare_quote: { name: 'lock_fare_quote', versionDigest: 'sha256:4c2e', requires: ['authenticate_session'] },authenticate_session: { name: 'authenticate_session', versionDigest: 'sha256:1f08', requires: [] },};const exposedTools = expandDependencyClosure(['book_flight'], catalog);const result = await agent.run(`Verify exposed MCP tool closure [${exposedTools.join(', ')}] and test booking contract.`);console.log('Verified MCP closure result:', result.summary);}main().catch(console.error);
Watch: Related Video Guides
Build an MCP-Based Tool Discovery Agent (Step-by-Step)
What is MCP? Integrate AI Agents with Databases & APIs
Why Standard Top-k Tool Retrieval Breaks Multi-Step Enterprise Workflows
When enterprise Model Context Protocol (MCP) registries grow beyond 24–100 tools, injecting every schema bloats context and degrades routing accuracy. Yet naive top-k lexical or dense retrieval selects the final action tool (such as submit_order or cancel_reservation) while omitting prerequisite state-setup tools (authentication tokens, draft creation, lock acquisition, or compliance checks).
In arXiv:2612.01375, researchers evaluated six retrieval and discovery methods across 72 versioned contexts and 336 source-derived lifecycles (ticket, trading, retail, and airline APIs). Multi-round lexical retrieval (L) and history-conditioned retrieval (H) exposed executable support on only 36/72 initial versions and 30/72 revised versions—half of the feasible workload.
| Discovery Method | Old Version Support | Revised Version Support | Lifecycle Bytes (Full Exposure) | Index Input Bytes |
|---|---|---|---|---|
| Lexical Retrieval (`L`) | 36 / 72 | 30 / 72 | 7,322,718 | N/A (72 calls) |
| History-Conditioned (`H`) | 36 / 72 | 30 / 72 | 7,233,232 | N/A (72 calls) |
| State-Dependency Expansion (`S`) | 72 / 72 | 60 / 72 | 6,203,440 | 5,406,796 |
| Full Rediscovery (`F`) | 72 / 72 | 60 / 72 | 6,753,735 | 5,406,796 |
| Incremental Completion (`I`) | 72 / 72 | 60 / 72 | 5,056,531 | 3,622,020 (-33.0%) |
Versioned Contract Certification vs Simple Index Caching
Tool schemas mutate silently across deployments: an API revision can drop a required precondition or introduce a new authorization step while keeping the same tool name.
- Dependency-Guided Closure: Expand each candidate tool backward through its
requirespreconditions using a bounded planner before exposing the subset to the LLM. - Source-Bound Index Reuse: Bind cached dependency edges to cryptographic source digests of the tool body and schema. When catalogs update, re-index only modified bodies—cutting logical indexing input by 35.93% on real catalogs while retaining 18/24 vs 19/24 goal completions on Qwen3-32B.
- Explicit Stop Conditions: Separate *missing capability*, *exposure-cap overflow* (e.g., >24-tool budget), and *search truncation* so agents fail closed rather than hallucinating missing parameters.
Version Fingerprints Are Not Business Proofs
A matching tool version digest certifies schema and dependency retention—not downstream business authorization. Keep runtime RBAC and permission gates inside the execution harness.
Auditing Your MCP Server Catalog for Missing Prerequisites
Run a local topological dependency check across your mcpServers JSON manifests before deploying a new tool revision:
# Validate every tool precondition edge resolves inside the active MCP exposure budget
node -e '
const fs = require("fs");
const catalog = JSON.parse(fs.readFileSync(process.argv[1] || "mcp-catalog.json", "utf8"));
const names = new Set(catalog.tools.map(t => t.name));
const missing = [];
for (const t of catalog.tools) {
for (const dep of (t.requires || [])) {
if (!names.has(dep)) missing.push(`${t.name} -> missing ${dep}`);
}
}
console.log(missing.length ? { status: "BROKEN", missing } : { status: "COMPLETE", count: names.size });
' mcp-catalog.jsonWire validated dependency closures into Smoke Monkey Canvas so worker agents automatically mount prerequisite auth and state tools whenever they claim a downstream workflow.
Frequently Asked Questions
Q:Why does lexical or vector RAG fail for MCP tool discovery?
Top-k semantic search matches keywords in the goal operation (like refund_order) but often omits prerequisite setup tools (like verify_identity or fetch_ledger) that lack overlapping wording.
Q:How much indexing work does source-bound incremental completion save?
In arXiv:2612.01375, incremental completion reduced index input bytes by 33.0% on the finite matrix and reduced logical indexing input by 35.93% on real ticket, trading, retail, and airline catalogs.
Q:How does Qwen3-32B perform compared to Llama-3.1-70B-Instruct in the study?
Across 24 held-out roots, Qwen3-32B completed 19/24 revised goals under full rediscovery and 18/24 under cached incremental completion, whereas Llama-3.1-70B-Instruct completed 6/24 under both.
Q:Does caching dependency graphs ever hurt safety?
Only if caches ignore schema edits. Source-bound reuse ties every cached edge to the tool body digest and re-validates runtime contracts when revisions change.
Related Alternatives & Comparisons
Related Architecture Guides
View all guidesBest Open Source Coding Agents in 2026: Free, Local & Fully Hackable Harnesses
MCP Server Security Best Practices: Hardening Model Context Protocol Agents in 2026
Open Source Coding Agent Harness: Build a Forkable, Local AI Engineering Runtime
Build with Smoke Monkey Harness
Zero dependencies. 24 built-in tools. Human-in-the-loop safety. 100% open source under the MIT License.