Connected, listed and still unused: debugging tool selection

APIKeyAnthropicFree · Updated 2026-11-22 · 8 min read

Robotic arm reaching past a highlighted wrench on a tool pegboard
A tool can be on the wall and still be overlooked.

A frustrating pattern shows up again and again with agent setups: the MCP server reports a healthy connection, its tools appear in the client's tool panel, a skill is invoked explicitly, and yet the agent answers from memory, picks the wrong tool, or sends arguments the server rejects. A related worry from newcomers is whether every installed plugin quietly eats tokens even when it is never used.

Both questions have the same root: a model chooses tools only from the text it is shown, and that text competes for attention and context with everything else in the prompt. This guide is for developers wiring tools into an agent, whether through MCP, a framework or a hand-written loop. It explains how tool selection works, the most common reasons it fails, and a debugging order that isolates the problem quickly.

Frequently asked questions

What is tool calling in an LLM API?

The client sends tool definitions, each with a name, a description and a JSON schema for arguments. The model may reply with a structured call instead of text. Your code runs the tool and sends the result back as a new message. The model never executes anything itself.

How does an MCP tool differ from a native API tool?

MCP is a protocol for discovering and running tools from a separate server. The client lists the server's tools, converts them into the API's tool format and forwards calls. To the model, an MCP tool is just another tool definition in the prompt.

Do installed tools cost tokens when they are not used?

Usually yes. Every tool definition the client includes is part of the input on every request, used or not. Some clients load tools lazily or only for certain modes, so check how yours behaves. Unused tools also make selection harder.

Why does a listed tool not mean the model can see it?

The panel shows what the client discovered. What the model sees is what the client actually sends in the request. Filters, modes, permission settings, name collisions or size limits can drop a tool between the two.

Which matters more, the tool name or its description?

Both, but descriptions do most of the work. A model matches the user's request against the description. A vague description such as gets activity loses to the model's own belief that it can answer directly.

How many tools can an agent handle well?

There is no fixed number, and it depends on the model. Selection accuracy tends to drop as lists grow and as tools overlap in purpose. Smaller models degrade sooner. Expose only the tools a given task needs.

Does free-ai support native tool calling?

The free endpoint on this site documents chat and text completions, not a tool-calling field. You can still run agents by asking for a JSON action in the reply and parsing it yourself, a pattern shown below.

Is a smaller model worse at picking tools?

Generally, yes. Larger commercial models such as Claude are noticeably more reliable at choosing among many tools and filling complex schemas. With a smaller model, compensate with fewer tools, clearer descriptions and validation.

How a model decides to call a tool

On every request the model receives the conversation plus a list of tool definitions. It then predicts whether the best next move is plain text or a structured call, and if a call, which tool and which arguments. Nothing about this is magic: it is the same next-token prediction as any other reply, guided by training on examples of tool use.

That means the decision depends on three things you control: whether the tool is present in the request at all, whether its description clearly matches the request, and whether the rest of the prompt makes calling it seem necessary. If any of these is weak, a model will often prefer the cheaper path of answering from what it already knows.

The confident-guess failure

When a user asks about recent activity, a model that is not sure a tool is relevant may invent a plausible answer instead. This is not malice; it is the default behaviour of a text predictor. Clear system instructions such as always use the activity tool for questions about recent events reduce it.

Schema mismatch failure

Sometimes the call happens but fails: a required field is missing, a date is in the wrong format, an enum value is invented. The server returns an error and the agent gives up or loops. Tight schemas with examples in the description help more than long prose.

Connected is not the same as delivered

Clients show the tools they discovered, but many apply rules before sending them to the model: tools may be disabled per workspace, hidden in a particular mode, renamed with a server prefix, or dropped when the combined definitions exceed a size budget. The tool panel and the actual request can therefore disagree.

The fastest way to settle this is to look at the real request. Most clients and frameworks have a debug or verbose log that prints the outgoing payload. If you cannot get it, put a small logging proxy in front of the API and read the tools array for yourself.

Name collisions between servers

Two servers that both expose a tool called search or get_items may be merged, prefixed or silently shadowed depending on the client. Give tools specific, namespaced names so the model and the client can tell them apart.

Permission prompts that never appear

Some clients require a user to approve a tool before first use. In a headless run nobody approves, and the call is refused. The agent then reports that it could not retrieve the data, which looks like a server bug but is a policy setting.

Envelopes passing or being stopped at a sorting gate
What the client discovers and what it actually sends can differ.

Every extra tool has a price

A tool definition is text, and text in the request is input tokens. A server that exposes a large management API as dozens of tools adds all of those schemas to every call. Install several such servers and a simple question may carry thousands of tokens of definitions before the user's words even start.

The second price is attention. With many overlapping tools, a model must discriminate between list_identities, search_identities and get_identity, and it will sometimes pick the wrong one. Fewer, broader, well-described tools tend to beat a one-to-one mirror of an API.

Measuring the overhead

Send the same short question with and without your tool list and compare prompt_tokens in the response usage. The difference is the standing cost of your toolset on every call. Our article on whether terse replies save tokens shows the same measuring approach for output.

  • Group rarely used operations behind one tool with an action parameter.
  • Disable servers you are not using in the current project.
  • Prefer read-only tools by default and enable write tools only when needed.
  • Keep each description under a few sentences, with one example argument set.

Writing tool descriptions a model will act on

Good descriptions say when to use the tool, not only what it does. Compare Returns activity with Use this for any question about what happened in the account in the last 30 days; returns a list of events with timestamps. The second gives the model a trigger condition it can match against the user's words.

Describe arguments with formats and an example, state what the tool returns, and mention what it cannot do. A line such as does not return deleted items stops the model from calling the same tool three times hoping for a different result.

Mirror the user's vocabulary

If users say tickets and the API says incidents, include both words in the description. Models match surface language strongly, and a tool described only in internal jargon is easy to overlook.

Return errors the model can use

When a call fails, return a short, specific message such as date must be YYYY-MM-DD. A model can repair its call from that. A bare stack trace or an empty result often leads to a guess or an abandoned task.

Overstuffed backpack next to a lightly packed bag on a trail
Every registered tool is carried on every request.

A debugging order that saves hours

Work from the outside in. Most tool problems are found in the first two checks, so do not start by rewriting prompts.

Reduce to one tool

Temporarily disable every other server and tool. If the agent now uses the tool correctly, the problem is competition or collision. If it still fails, the problem is the definition itself or the server.

Test with a stronger model once

If a capable commercial model uses the tool correctly and a smaller model does not, you have learned that the definition works and the limit is model capability. That tells you whether to simplify the tool or upgrade the model.

  • Confirm the tool is in the outgoing request payload, with the name you expect.
  • Call the tool directly, outside the agent, with known-good arguments.
  • Ask the model explicitly to use the tool by name and see what it sends.
  • Read the arguments it produced and compare them with the schema.
  • Only then refine the description and system instructions.

Tool use without native tool calling

Some endpoints, including the free one on this site, expose chat completions without a documented tools field. You can still build a small agent: describe the tools in the system prompt, ask for a JSON object naming the action and arguments, parse it, run the tool and send the result back. This is how many early agents worked, and it remains a useful fallback.

The sketch below uses free-ai through the openai SDK. It validates the reply before running anything, which matters more with a smaller model.

Why the loop is capped

A fixed number of iterations prevents a confused model from calling tools forever. Real agents should also cap total tokens and wall-clock time, and log every step so failures can be replayed.

import json
from openai import OpenAI

client = OpenAI(base_url="https://api.apikeyanthropicfree.com/v1", api_key="free")

SYSTEM = (
    "You can use one tool: get_weather(city: string). "
    "Reply ONLY with JSON: {\"action\": \"get_weather\", \"city\": \"...\"} "
    "or {\"action\": \"answer\", \"text\": \"...\"}."
)

def get_weather(city):
    return {"city": city, "forecast": "light rain", "high_c": 14}

messages = [{"role": "system", "content": SYSTEM},
            {"role": "user", "content": "Should I take an umbrella in Lisbon today?"}]

for _ in range(3):
    reply = client.chat.completions.create(model="free-ai", messages=messages, temperature=0)
    raw = reply.choices[0].message.content.strip().strip("`").removeprefix("json").strip()
    try:
        step = json.loads(raw)
    except json.JSONDecodeError:
        messages.append({"role": "user", "content": "Invalid JSON. Reply with JSON only."})
        continue
    if step.get("action") == "get_weather" and step.get("city"):
        result = get_weather(step["city"])
        messages.append({"role": "assistant", "content": raw})
        messages.append({"role": "user", "content": "Tool result: " + json.dumps(result)})
    else:
        print(step.get("text", raw))
        break
Clipboard on an engine with one part removed for testing
Isolate one tool at a time before rewriting prompts.

Where model choice really matters

Tool selection is one of the areas where large commercial models clearly lead. Claude and similar models handle long tool lists, nested schemas and multi-step plans far better than a 35B open-weight model. If your product depends on an agent juggling many tools, a free endpoint is a place to prototype the loop, not a replacement for a strong model in production.

This site is independent and not affiliated with Anthropic; free-ai is not a Claude model, and only the OpenAI-style request format is shared. A related failure mode, where an agent claims success although the tool it needed was never there, is covered in why agents report success when a tool is missing.

Prototype cheaply, then confirm

Build the loop, logging and validation on a free model, where mistakes cost nothing. Then run the same scenario set against the model you plan to pay for. The structure carries over; the accuracy numbers will not.

Try the free API

Send a test prompt from the chat box on the home page: no key, no account and no card, only the published per-IP limits.

Read also