MCP tool definitions cost 104,000 tokens a call behind our AgentCore gateway
Part 5 of 5: Behind an AgentCore gateway with three MCP servers, every Claude model call carried 104,388 tokens of tool definitions before a word of the conversation. Here's how to measure yours, where the tokens go, and the options for cutting them.

Every Claude model call carries the full definition of every tool it may use. Behind an Amazon Bedrock AgentCore gateway with three MCP servers, that came to 104,388 tokens a call before a word of the conversation. This guide shows how to measure yours, where the tokens went, and the options for cutting them.
The short version
- Tool definitions ride along on every model call, and again on every step of a multi-tool answer.
- One server can dominate. HubSpot’s 41 tools were 85% of our total.
- Most of the cost is input schemas, not descriptions, and a handful of tools carry most of it.
- Behind a gateway, Claude Code’s tool search is off, so nothing trims the list for you.
- Measure with Bedrock’s CountTokens, then cut by server, by team or by tool.
We found this the hard way. One prompt in Claude Desktop, and it told us the conversation was already 201K tokens long. This follows our AgentCore Gateway guide, with GitHub and HubSpot added as targets.
The AgentCore Gateway series, in order:
- Put Claude Code on Bedrock behind your own sign-in
- Run Claude Desktop through the same gateway
- Add GitHub’s MCP server with a read-only token
- Give each person their own HubSpot sign-in
- Count what the MCP tool definitions cost per model call (this guide)
Why does every model call carry every tool?
Claude can only call a tool it has been told about. So each request to the model includes a tools array: every tool’s name, description and input schema. MCP clients build that array from the server’s tools/list.
Claude Code can defer this, loading tool definitions only when it searches for them. It turns that off when model calls go to a non-Anthropic address, and a gateway’s /inference is one. Our Claude Desktop sessions sent the full list too.
A single prompt is rarely one model call. Claude asks for a tool, gets the result, and asks again with everything so far. Each step resends the definitions.
How do you measure what your tools cost?
Bedrock’s CountTokens API counts a request’s input tokens without running it. This script lists every tool through the gateway, then counts each target’s tools against an empty request.
# count_tools.py: python3 count_tools.py (needs GW, AWS_REGION, a fresh ~/.agentcore-id-token and bedrock:CountTokens)
import collections, json, os, urllib.request
import boto3
MODEL = os.environ.get("COUNT_MODEL", "anthropic.claude-haiku-4-5-20251001-v1:0") # a model CountTokens accepts
def rpc(body):
token = open(os.path.expanduser(os.environ.get("AGENTCORE_TOKEN_FILE", "~/.agentcore-id-token"))).read().strip()
request = urllib.request.Request(os.environ["GW"] + "/mcp", data=json.dumps(body).encode(), method="POST",
headers={"authorization": "Bearer " + token, "content-type": "application/json",
"accept": "application/json, text/event-stream"})
text = urllib.request.urlopen(request, timeout=60).read().decode()
if text.lstrip().startswith(("event:", "data:")):
text = "\n".join(line[5:].strip() for line in text.splitlines() if line.startswith("data:"))
return json.loads(text)
tools, cursor = [], None
while True:
result = rpc({"jsonrpc": "2.0", "id": 1, "method": "tools/list", "params": {"cursor": cursor} if cursor else {}})["result"]
tools += result["tools"]
cursor = result.get("nextCursor")
if not cursor:
break
bedrock = boto3.client("bedrock-runtime", region_name=os.environ["AWS_REGION"])
def count(some):
body = {"anthropic_version": "bedrock-2023-05-31", "max_tokens": 10, "messages": [{"role": "user", "content": "hi"}]}
if some: # what the model sees of a tool: its name, description and input schema
body["tools"] = [{"name": t["name"], "description": t.get("description", ""), "input_schema": t["inputSchema"]} for t in some]
return bedrock.count_tokens(modelId=MODEL, input={"invokeModel": {"body": json.dumps(body)}})["inputTokens"]
base = count([])
by_target = collections.defaultdict(list)
for t in tools:
by_target[t["name"].split("___")[0]].append(t)
for target, some in sorted(by_target.items()):
cost = count(some) - base
print(f"{target:12} {len(some):3} tools {cost:7,} tokens ({cost // len(some):,} a tool)")
print(f"{'all':12} {len(tools):3} tools {count(tools) - base:7,} tokens")
CountTokens refused the Claude 5.5 model we tried (“The provided model doesn’t support counting tokens”), so we count with Claude Haiku 4.5. Other models tokenise a little differently, so treat the numbers as close, not exact. Each target’s row is counted on its own, so the three come to a little more than the combined total: counting a set of tools together costs slightly less than counting each set and adding them up.
Check: it prints one line per target and a total. Ours, on 4 December 2026:
deepwiki 3 tools 852 tokens (284 a tool)
github 46 tools 15,177 tokens (329 a tool)
hubspot 41 tools 89,353 tokens (2,179 a tool)
all 90 tools 104,388 tokens
Where did the tokens go?
| Target | Tools | Tokens a call | Share of the three |
|---|---|---|---|
| HubSpot | 41 | 89,353 | 85% |
| GitHub | 46 | 15,177 | 14% |
| DeepWiki | 3 | 852 | 1% |
HubSpot’s tools cost almost seven times as much each as GitHub’s. Its descriptions aren’t the problem. Its input schemas are four times the length of its descriptions. Five tools for marketing emails, landing pages and segments carry the biggest:
| HubSpot tool | Input schema, characters |
|---|---|
manage_marketing_email |
42,391 |
manage_segment |
32,795 |
manage_landing_page |
31,258 |
query_segments |
18,356 |
get_marketing_email_analytics |
9,489 |
Metomic Boundary, our invented 900-person payments company, wants its sales team asking about accounts. That team never needs to build a landing page. Yet every one of their model calls would pay for those schemas.
What can you do about it?
These are the options as we see them. None is in our gateway yet, so check each against your own numbers.
| Option | What it cuts | Effort | Caveat |
|---|---|---|---|
| Drop tools nobody needs in a response interceptor | Exactly the tools you name | A small Lambda function, like our output schema fix | You maintain the list as servers add tools |
| One gateway per team, with only that team’s servers | Whole servers | More gateways and sign-ins to run | A person in two teams needs two connections |
| A narrower endpoint, where the server offers one | Server-defined groups of tools | One target setting | GitHub documents /readonly and /x/{toolset} paths. HubSpot’s server, as far as we know, has nothing similar |
| AgentCore semantic search | Depends on the client | Make a new gateway: it can only be enabled at creation | We haven’t measured what clients send with it |
The interceptor is the quickest win, because the cost is so concentrated. Removing those five HubSpot tools would take out 134,289 characters of input schema, about half of HubSpot’s.
What else should you check?
- The context window. 104,388 tokens is about half of a 200,000-token context window, used before anyone types.
- Prompt caching. Repeated tool definitions are what caching is for. We haven’t checked whether caching works through the gateway’s inference target, so measure your bill before relying on it.
- New tools. Servers add tools without telling you. Run the count again whenever you add or update a target.
What’s still hard?
- Nobody owns the list. The gateway passes on whatever each server lists, and clients send whatever the gateway lists. Trimming it is your job.
- Per-person lists. Different teams need different tools, but one gateway gives everyone the same list.
- The numbers move. Our counts are one day’s snapshot of three servers. Your servers, and their next releases, will differ.
What do you have now?
- A script that tells you what each server’s tools cost on every model call.
- Our numbers, to compare yours against.
- Four ways to cut the cost, with what each one leaves behind.
Trimming the list is one lever. Deciding which tools a given person should even be offered, by their team and by what the chat already holds, is where our governed MCP gateway does its work. We’re working with a small number of security teams on what agents should be allowed to see and do. If you’ve measured caching through a gateway, we’d like the numbers.
Frequently asked questions
- Why do MCP tools use so many tokens with Claude?
- Every tool's name, description and input schema goes with every model call, so Claude knows what it can use. A server with detailed schemas costs a lot: HubSpot's 41 tools came to 89,353 tokens in our test. A conversation with several tool calls sends them again each time, so one prompt can cost several hundred thousand input tokens.
- How do you count the tokens MCP tool definitions use on Amazon Bedrock?
- List every tool from the gateway, following nextCursor across pages. Build a Bedrock InvokeModel body with those tools and a one-word message, and pass it to Bedrock's CountTokens API. Subtract the count for the same body without tools. CountTokens refused the Claude 5.5 model we tried, so we counted with Claude Haiku 4.5. Expect small differences between models.
- Does Claude Code's MCP tool search work behind an AgentCore gateway?
- Not in our setup. Claude Code can load MCP tool definitions only when it needs them, but it turns that off when model calls go to a non-Anthropic address, as they do through a gateway's inference target. Every tool's definition then goes with every call, which is why measuring and trimming the list matters so much here.
- Can AgentCore Gateway's semantic search reduce tool tokens?
- Possibly. AWS documents a semantic search option that adds a search tool, x_amz_bedrock_agentcore_search, for finding the right tool by description. It can only be enabled when a gateway is created. Whether it cuts what Claude Code or Claude Desktop send depends on how they use it, and we haven't measured that yet.
- What's the quickest way to cut MCP tool tokens behind a gateway?
- Find the few tools that cost the most and remove the ones nobody needs. In our test, five HubSpot tools for marketing emails, landing pages and segments carried the biggest schemas, and a sales team asking about accounts rarely needs them. A response interceptor can drop tools from tools/list, or you can give each team its own gateway with only the servers it uses.