You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
MCP tool descriptions are authored in isolation — each server writes descriptions for its own tools without awareness of what other tools exist in the ecosystem. This creates several problems for MCP-based agents:
Ambiguity between similar tools: "search", "query", "lookup", and "find" appear across different servers with overlapping semantics but no disambiguation.
Inconsistent granularity: Some tools have 3-word descriptions, others have 3-paragraph essays — the LLM wastes context window on verbose descriptions while missing important distinctions.
Token inefficiency: Descriptions optimized for humans are not optimized for LLM token budgets. An LLM needs just enough to pick the right tool — not a full user guide.
No ecosystem awareness: A tool description for "search" is written without knowing that 4 other tools also do "search" variants. The LLM has no disambiguation signal.
An offline service with visibility across all registered tools can rewrite descriptions to be maximally discriminative, concise, and LLM-friendly — something no individual tool author can do.
Proposal
1. ToolDescriptionOptimizer
Create chainweaver/optimizer.py (or extend chainweaver/compiler_llm.py from #28):
defoptimize_tool_descriptions(
tools: list[Tool],
*,
llm_fn: Callable[[str], str],
strategy: OptimizationStrategy=OptimizationStrategy.DISCRIMINATIVE,
) ->list[ToolDescriptionProposal]:
""" Use an LLM (offline, at build time) to rewrite tool descriptions for maximum discriminability within the known tool ecosystem. Never called at runtime. """
2. Optimization strategies
classOptimizationStrategy(str, Enum):
DISCRIMINATIVE="discriminative"# Maximize distinction between similar toolsCONCISE="concise"# Minimize token count while preserving semanticsSTRUCTURED="structured"# Enforce consistent format across all tools
3. Output: rewrite proposals
@dataclassclassToolDescriptionProposal:
tool_name: stroriginal_description: strproposed_description: strrationale: str# Why this change improves discriminabilitysimilarity_group: list[str] # Other tools this was disambiguated againsttoken_delta: int# Negative = fewer tokens (improvement)source: str="description-optimizer"
4. LLM prompt design
The optimizer builds a prompt containing:
All tool names and descriptions in the ecosystem
Input/output schema summaries per tool
Explicit instruction: "Rewrite descriptions to help an LLM agent choose the correct tool with minimal ambiguity. Focus on what makes each tool different from similar tools."
Optional: Example of a good vs bad description from the same ecosystem
5. Batch vs incremental
Full batch: optimize_tool_descriptions(all_tools) — rewrite all descriptions together for maximum global coherence.
Incremental: optimize_new_tool_description(new_tool, existing_tools) — optimize only the new tool's description given the existing ecosystem, and flag existing tools whose descriptions should be updated.
6. Safety guardrails
Banned from runtime: Like compiler_llm.py, this module MUST NOT be imported by executor.py. Enforce via test.
No auto-application: Proposals are returned as data objects for human review, never applied automatically.
Abstracted LLM call: llm_fn: Callable[[str], str] — no dependency on any LLM provider.
Original descriptions preserved: Proposals always include the original description for comparison.
Feeds into MCP Flow Server — expose compiled flows as MCP tools #72 (MCP Flow Server): Optimized descriptions for virtual tools (compiled flows exposed as MCP tools) are even more valuable — the flow description must clearly convey what the collapsed N-step chain does.
Notes
This is a novel differentiator: no other orchestration framework optimizes tool descriptions across the ecosystem.
The key insight is that discrimination is a property of the set, not the individual tool. You can't write a good "search" description without knowing all the other "search" tools.
Consider outputting a "confusion matrix" — pairs of tools most likely to be confused by an LLM based on description similarity.
The optimizer could also detect and flag duplicate tools (same capability offered by multiple MCP servers) and suggest consolidation.
Context / Problem
MCP tool descriptions are authored in isolation — each server writes descriptions for its own tools without awareness of what other tools exist in the ecosystem. This creates several problems for MCP-based agents:
An offline service with visibility across all registered tools can rewrite descriptions to be maximally discriminative, concise, and LLM-friendly — something no individual tool author can do.
Proposal
1.
ToolDescriptionOptimizerCreate
chainweaver/optimizer.py(or extendchainweaver/compiler_llm.pyfrom #28):2. Optimization strategies
3. Output: rewrite proposals
4. LLM prompt design
The optimizer builds a prompt containing:
5. Batch vs incremental
optimize_tool_descriptions(all_tools)— rewrite all descriptions together for maximum global coherence.optimize_new_tool_description(new_tool, existing_tools)— optimize only the new tool's description given the existing ecosystem, and flag existing tools whose descriptions should be updated.6. Safety guardrails
compiler_llm.py, this module MUST NOT be imported byexecutor.py. Enforce via test.llm_fn: Callable[[str], str]— no dependency on any LLM provider.Relevant Code Locations
compiler_llm.py(Add optional offline LLM-assisted flow compiler (build-time only) #28) — both are offline LLM-assisted build-time servicesTool.description→chainweaver/tools.py(the field being optimized)ChainAnalyzer→ from Offline computation of valid tool combinations from schemas #77 (shares tool ecosystem awareness)Acceptance Criteria
optimize_tool_descriptions()accepts a list of tools and anllm_fncallableToolDescriptionProposalobjects with original, proposed, rationale, and similarity groupoptimize_new_tool_description()for single-tool optimization against existing ecosystemchainweaver/executor.pydoes NOT importoptimizerllm_fnis a plainCallable[[str], str]— no dependency on any LLM providertoken_deltais computed (approximate, e.g., word count × 1.3)Out of Scope
Relationship to Existing Issues
llm_fnabstraction and safety guardrails.Notes