{"id":3900,"date":"2026-10-11T08:23:41","date_gmt":"2026-10-11T08:23:41","guid":{"rendered":"https:\/\/www.exam-topics.com\/blog\/?p=3900"},"modified":"2026-10-19T10:13:21","modified_gmt":"2026-10-19T10:13:21","slug":"claude-mcp-tool-selection-and-structured-errors","status":"publish","type":"post","link":"https:\/\/www.exam-topics.com\/blog\/claude-mcp-tool-selection-and-structured-errors\/","title":{"rendered":"Anthropic CCAR-F: Claude MCP Tool Selection and Structured Errors"},"content":{"rendered":"<p>Many agent failures are not failures of language understanding. They are failures of tool selection and error handling. A model chooses a plausible capability whose contract is ambiguous, an MCP server returns an unstructured exception, or the application interprets a retryable outage as permission to try another tool with broader access.<\/p>\n<p>Such systems may appear flexible until one unclear tool request causes an unintended change. For Claude integrations, tool discovery, selection, validation, execution, and failure reporting should be independent and inspectable parts of the workflow.<\/p>\n<p>Model Context Protocol standardizes connections to external capabilities, but standardization does not decide which operations an agent should be allowed to use. An application still controls visible tools, scope and user authority. A safe <a href=\"https:\/\/www.exam-topics.com\/blog\/mcp-tool-design-for-secure-claude-integrations\/\">MCP tool contract<\/a> separates discoverability from permission and represents denied or failed calls explicitly. The following selection patterns keep ambiguity from turning a tool failure into an unauthorized new action.<\/p>\n<h2>Begin with an accurate inventory of callable capabilities<\/h2>\n<p>A tool name and description are not cosmetic metadata. They help the model decide whether a capability is relevant to the task. If five tools all claim to \u201csearch customer data,\u201d the agent has little information for choosing correctly. Describe the data source, allowed operation, expected output, constraints, and conditions under which each tool is inappropriate. Prefer a narrow <code>get_order_status<\/code> to a generic <code>customer_ops<\/code> tool with loosely interpreted text arguments.<\/p>\n<p>Group tools by trust boundary. A read-only order lookup may be broadly available; a refund tool should have stronger identity, monetary, and approval constraints. Tools for searching an internal knowledge base should not accept arbitrary requests to export the entire repository. Curate the visible catalog for each workflow instead of presenting every company integration to every model session.<\/p>\n<p>Discovery and authorization are separate. An MCP server can advertise a tool without granting the caller permission to invoke it. The target service must verify permissions each time, because catalog visibility can change, user roles can expire, and requests can be replayed. A model&#8217;s decision to call a tool is an instruction to the client runtime to consider a request, not proof that it is safe.<\/p>\n<h2>Use descriptions to disambiguate similar tools<\/h2>\n<p>Consider two ticketing tools: one searches historical tickets and another creates a new escalation. Both might seem relevant to \u201cfind the customer issue.\u201d A precise description explains that the search tool is for diagnosis and returns existing records, while escalation requires a validated issue summary and approval. This helps Claude propose a read-only action first and keeps the application able to reject an inappropriate write.<\/p>\n<p>Descriptions should state important exclusions. If a tool only reads sanitized records from one business unit, say so. If an action cannot be undone or can contact a customer externally, declare that behavior. Tool names should not conceal irreversible side effects behind vague verbs such as \u201cresolve.\u201d Examples in a description can clarify parameter expectations, but avoid packing entire policy manuals into every tool definition. Too many repetitive details can increase context cost and reduce clarity.<\/p>\n<p>After modifying a tool catalog, run tests where the correct response is to choose no tool, request clarification, or report that a capability is unavailable. Selection accuracy cannot be measured only by whether the model picked a valid tool name. It matters whether the selected capability is justified by user intent and policy.<\/p>\n<h2>Keep tool-choice controls subordinate to application policy<\/h2>\n<p>The <a href=\"https:\/\/platform.claude.com\/docs\/en\/agents-and-tools\/tool-use\/how-tool-use-works\" rel=\"nofollow\">Claude tool-use interface<\/a> lets applications offer or direct tool calls, but it does not override the application&#8217;s allowlist or the user&#8217;s permissions. Exposing a tool is a policy decision; model selection merely proposes an action. The application must authorize and validate every request before execution.<\/p>\n<p>Prefer selection constraints that follow the stage of work. During evidence gathering, expose only read operations. When a change has been proposed and reviewed, the application can make a specific mutation capability available to a narrowly authorized execution step. Avoid a single session in which the model has both unrestricted browsing and privileged write access by default. That architecture makes prompt injection far more dangerous because untrusted source text can influence side-effecting actions.<\/p>\n<p>When a task can be answered without a tool call, allowing the model to abstain can reduce cost and unnecessary data access. When the user requests a real external fact, the application should require suitable evidence rather than accept a confident response from memory. The distinction is task-specific, so evaluate both false tool use and failures to use a needed tool.<\/p>\n<h2>Design errors as stable outcomes, not reassuring prose<\/h2>\n<p>A tool can fail because its input is invalid, the requested resource is absent, the caller lacks permission, an upstream service is unavailable, or a deadline was exceeded. Returning only \u201cSomething went wrong, try again\u201d hides the action needed to recover. A structured response should identify an error category, provide safe diagnostic context, indicate whether retrying is appropriate, and distinguish unknown outcome from confirmed failure. For MCP integrations, error signaling must match the current specification, including the relevant tool-result error indicator.<\/p>\n<p>For instance, a lookup might report <code>NOT_FOUND<\/code> when an account ID does not exist, <code>FORBIDDEN<\/code> when access is denied, or <code>RETRYABLE_UPSTREAM<\/code> when a temporary dependency is unavailable. These are illustrative application-level categories, not universal MCP protocol constants. Each should have a documented behavior: ask for a corrected identifier, deny and escalate, or retry with limits. Do not encourage the model to seek a different privileged integration after a permission denial.<\/p>\n<p>Never expose raw stack traces, secrets, connection strings, or entire database rows in tool errors merely because the model might find them informative. Log sensitive diagnostic detail under approved application controls, then return only what the agent needs to decide safely. A useful model-facing error might say that a lookup failed because the service was temporarily unavailable and that no account update was attempted. It should not reveal implementation secrets.<\/p>\n<h2>Separate protocol errors from business rejections<\/h2>\n<p>A failed MCP <em>tool execution<\/em> may be returned inside a tool result with <code>isError: true<\/code>. For example, an internal lookup could return <code>{\"content\":[{\"type\":\"text\",\"text\":\"temporarily_unavailable\"}],\"isError\":true}<\/code> instead of an apparently successful empty result. That differs from a JSON-RPC protocol error for a malformed request or an unknown tool. The <a href=\"https:\/\/modelcontextprotocol.io\/specification\/2025-11-25\/server\/tools\" rel=\"nofollow\">MCP tool specification<\/a> distinguishes these outcomes; an outage must not become fabricated evidence that no account exists.<\/p>\n<p>A business rejection such as <code>status: denied<\/code> can also be a deliberately handled domain outcome: valid transport does not grant permission to modify data. Declare whether that condition is a successful tool result containing a denial status or a tool-level execution error, and keep the implementation consistent.<\/p>\n<p>Both should cause the coordinator to stop or request legitimate approval rather than repeatedly trying broader tools. Log the operation identifier, authorization scope and retryability without exposing secrets, and recheck target-state before replaying a mutating request.<\/p>\n<p>A malformed protocol message or unavailable MCP connection is different from a valid tool invocation that was rejected by business policy. The latter should be reported as a normal application outcome with an explicit denial reason. Treating every denied action as a transport failure may cause the agent runtime to retry, potentially invoking the same prohibited operation repeatedly. Conversely, hiding a true tool failure as a successful empty result may make Claude conclude that no data exists.<\/p>\n<p>Record whether the tool request was never sent, reached the application and was rejected, completed successfully, or reached an unknown result state. This distinction is essential for writes. If a billing operation timed out after a downstream service received it, the correct next step is to check the existing operation ID, not construct a second request with new arguments. Use idempotency keys and durable transaction state rather than hoping the model remembers what it already tried.<\/p>\n<p>Structured failures support better review. A human should be able to see which condition blocked an action without reading a large model transcript. They should also be able to revoke a pending authorization. The system&#8217;s credibility comes from being able to say exactly what was and was not done.<\/p>\n<h2>Use failure categories to drive bounded recovery<\/h2>\n<p>Retrying a transient network timeout may be appropriate for a read-only lookup, but use exponential backoff or another bounded policy and stop after a reasonable limit. Validation errors usually need corrected input, not automated repetition. Permission errors need authorization or a different approved route. Ambiguous tool discovery should trigger a clearer request or a deterministic routing rule, not simultaneous calls to all plausible tools.<\/p>\n<p>An agent should never use error recovery as a reason to expand its tool permissions automatically. If an approved read API is unavailable, a privileged database-export tool should not become the fallback without a separate policy decision. If the correct service is unavailable, report the limitation and preserve the task state. Recovery procedures should be part of the task contract, with a maximum step budget and a clear escalation point.<\/p>\n<p>The <a href=\"https:\/\/www.exam-topics.com\/blog\/context-management-for-claude-agents\/\">workflow state<\/a> design should preserve retry decisions as durable facts. A summarization pass can accidentally omit the detail that a prior write returned an unknown result. Store tool outcomes in structured application state so later turns can recover safely even after the model&#8217;s working context has been compacted or reset.<\/p>\n<h2>Test tool selection with adversarial and ambiguous cases<\/h2>\n<p>A useful evaluation suite includes near-duplicate tool names, a missing required parameter, a non-existent record, cross-tenant access attempts, untrusted instructions inside a search result, tool timeout after a possible commit, and a request whose outcome requires clarification. Record the expected selection, parameter validation outcome, authorization decision, and retry behavior. A test should fail if the model picks a valid but unnecessarily privileged tool.<\/p>\n<p>Test catalog changes as carefully as model changes. Adding a new tool can alter selection among existing tools even when old tool definitions remain untouched. A broadened description may attract unrelated calls, and a relocated MCP server may change identity or network assumptions. Run regression tests that focus on tool choice, denied-action paths, user authority, error classification, and correct state preservation.<\/p>\n<p>Measure the proportion of tasks completed with the intended tools, unauthorized attempts stopped, pointless calls avoided, retries correctly bounded, and results traceable to evidence. A system with more successful tool invocations is not necessarily a better system if it also increases risky side effects. The desired outcome is fewer unjustified actions while maintaining useful task completion.<\/p>\n<h2>Walk through an account investigation end to end<\/h2>\n<p>An agent receives a request to explain a missing refund. It first uses a read-only order lookup and a policy search. The policy result contains an untrusted sentence telling the agent to bypass approval; the runtime treats that as source data, not authority. The agent then proposes a refund and returns the relevant evidence. A supervisor approves a specific amount under a specific account. Only at that point is a narrowly scoped refund tool made available to an execution step.<\/p>\n<p>If the target service denies the request because the account is inactive, the result should carry a business rejection, not a generic error. The agent can explain the denial and suggest a legitimate resolution. If the service times out after accepting the operation, the runtime checks the stable transaction identifier before any retry. If the tool&#8217;s schema has changed, the integration returns a validation failure for maintainers instead of quietly sending unknown fields.<\/p>\n<p>If an account lookup fails, the orchestration layer should be able to identify whether no authorized tool matched the request, the chosen tool rejected invalid parameters, the service was temporarily unavailable or the customer record was absent. Each outcome requires a different next action. Typed errors, bounded retries and an auditable authorization decision prevent the agent from improvising a more privileged route simply because the first call did not work.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Improve Claude MCP tool choice, descriptions and structured error recovery with bounded permissions.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[339,2],"tags":[],"et_vendor":[],"et_program":[],"et_certification":[],"et_exam":[],"et_topic":[],"class_list":["post-3900","post","type-post","status-publish","format-standard","hentry","category-claude-anthropic","category-post"],"_links":{"self":[{"href":"https:\/\/www.exam-topics.com\/blog\/wp-json\/wp\/v2\/posts\/3900","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.exam-topics.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.exam-topics.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.exam-topics.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.exam-topics.com\/blog\/wp-json\/wp\/v2\/comments?post=3900"}],"version-history":[{"count":6,"href":"https:\/\/www.exam-topics.com\/blog\/wp-json\/wp\/v2\/posts\/3900\/revisions"}],"predecessor-version":[{"id":4944,"href":"https:\/\/www.exam-topics.com\/blog\/wp-json\/wp\/v2\/posts\/3900\/revisions\/4944"}],"wp:attachment":[{"href":"https:\/\/www.exam-topics.com\/blog\/wp-json\/wp\/v2\/media?parent=3900"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.exam-topics.com\/blog\/wp-json\/wp\/v2\/categories?post=3900"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.exam-topics.com\/blog\/wp-json\/wp\/v2\/tags?post=3900"},{"taxonomy":"et_vendor","embeddable":true,"href":"https:\/\/www.exam-topics.com\/blog\/wp-json\/wp\/v2\/et_vendor?post=3900"},{"taxonomy":"et_program","embeddable":true,"href":"https:\/\/www.exam-topics.com\/blog\/wp-json\/wp\/v2\/et_program?post=3900"},{"taxonomy":"et_certification","embeddable":true,"href":"https:\/\/www.exam-topics.com\/blog\/wp-json\/wp\/v2\/et_certification?post=3900"},{"taxonomy":"et_exam","embeddable":true,"href":"https:\/\/www.exam-topics.com\/blog\/wp-json\/wp\/v2\/et_exam?post=3900"},{"taxonomy":"et_topic","embeddable":true,"href":"https:\/\/www.exam-topics.com\/blog\/wp-json\/wp\/v2\/et_topic?post=3900"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}