Skip to content

Add MCP server instructions to reduce LLM parameter name hallucination #50

@cryptiklemur

Description

@cryptiklemur

Problem

LLMs frequently hallucinate parameter names when calling DecompilerServer tools, leading to repeated failures. For example, Claude consistently uses:

  • pattern instead of query for search_types / search_members
  • query instead of memberId for resolve_member_id
  • namespace instead of ns for get_types_in_namespace
  • memberId instead of methodId for find_callers / find_callees

These are plausible-sounding names that LLMs infer from the tool descriptions rather than reading the schema carefully. This causes cascading failures where every call in a session errors out with "An error occurred invoking X".

Suggested fix

The MCP spec supports a instructions field on the server info that gets injected into the LLM's system prompt. Adding a concise parameter cheat sheet there would ground the LLM on correct names before it makes its first call.

Example (in Program.cs or wherever McpServerInfo is configured):

Common parameter mistakes to avoid:
- search_types / search_members: the search param is `query`, not `pattern`
- resolve_member_id / find_usages / get_decompiled_source: use `memberId`
- find_callers / find_callees: use `methodId`, not `memberId`
- get_types_in_namespace: the namespace param is `ns`, not `namespace`

This is similar to how the figma and serena MCP servers use their instructions field to steer LLM behavior.

Impact

Without this, users need to add client-side workarounds (e.g., Claude Code rule files) to prevent the hallucination. A server-side fix benefits all clients.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions