Skip to main content

How emisar can save you tokens by packing 1,918 actions into 14 MCP tools

Give each action its own tool and our catalog takes 391,423 tokens to load. We cut that to 10,572. Here’s how an agent finds the one PostgreSQL query it needs when checkout gets stuck.

November 24, 2026 · 6 min read

We want our agents to have eyes on production. If an order is stuck, we’d like to ask “what’s holding up checkout?” and let the agent look. We don’t want to copy logs into chat or guess which database query it should run.

The catch is what happens when we connect all the tools we use. Some MCP clients send the model every tool’s description and arguments before it can make its first call. Now a question about a stuck order starts with the agent reading how to check the memory usage of a Redis key. We still want Redis available for the next incident.

We built Emisar with 14 tools. One of them, find_actions, lets the agent look up what it can do on the hosts it has access to. When we added the ability to open a Sentry event by ID, it became searchable through that same tool. Nobody had to install another connector, and the tool list stayed the same size.

What goes into the first prompt?

We used the November 24, 2026 catalog to model what a client would load if each action were its own MCP tool. We counted the name, description and full argument schema for each action, then used the same tokenizer on Emisar’s actual tools/list response.

Tokens in tool definitions before the first call
Available actions One tool per action emisar
PostgreSQL 49 actions 7,158 10,572
PostgreSQL, Kubernetes, Redis, Sentry 167 actions 32,015 10,572
Full catalog 1,918 actions across 108 packs 391,423 10,572

If PostgreSQL is all you need, its 49 tools are cheaper to load directly. Emisar uses 3,414 more tokens up front. Two runbook tools alone use 4,582 tokens to explain how to create and edit a procedure. You pay that cost even if all you want is one database read.

Add Kubernetes, Redis and Sentry, and the arithmetic flips. Loading those four packs up front takes 32,015 tokens. Emisar still takes 10,572. Across the full catalog that’s 97.3% fewer tokens in the initial tool definitions. If your client already loads tools on demand, check what it actually sends the model. Anthropic shows how much that choice matters in its five-server example.

Which session is holding up order 42?

In our test, one PostgreSQL session marked order 42 as paid. Another tried to mark it sent and waited on a lock. We wanted to know how much the agent would have to read to find the session holding it. We searched a local workspace with all 108 packs across 15 test runners. You can make the same search from the CLI.

Find the lock query
emisar-mcp find_actions '{
  "query": "blocked queries waiting on locks",
  "limit": 3
}' --json > matches.json
jq -r '.candidates[].action_id' matches.json

postgres.lock_blocking_chains
gcp.sql_query_insights
mysql.lock_waits

Another search, “which postgres session is holding up an update,” missed the right action in the top three. “Blocked queries waiting on locks” found it. It also found a MySQL action. If you already know which database you’re looking at, narrow the search with pack_id set to postgres.

Each match includes a next call with the action ID and the exact pack hash. Pass those arguments to get_action to see what the action needs and which host can run it.

Check the arguments and host
jq '.candidates[] | select(.action_id == "postgres.lock_blocking_chains")
    | .next.arguments' matches.json |
  emisar-mcp get_action - --json > action.json
jq '{risk: .action.risk, args: .action.args_schema.properties,
    targets: [.compatible_runners[].name]}' action.json

{
  "risk": "medium",
  "args": {},
  "targets": ["pg-primary"]
}
12,145 tokens before the first database read
Fixed tool list
10,572
Search result
1,242
Action detail
331

We counted the full search result and action details once each, before trimming them for display. A client that sends both the structured result and its text copy spends more. Tool-call inputs, conversation history and the eventual database output cost tokens too.

The agent now has enough to request postgres.lock_blocking_chains on pg-primary. It supplies the pack and runner references, an empty argument object and a reason. Even this read is rated medium risk because SQL text can contain customer data. The control plane applies the team’s approval policy, and the runner checks the action and its arguments on the host.

What would that tell us during an incident? In a separate PostgreSQL 17.12 test, we ran the pack’s queries with a monitoring role. The first read identified both sessions. A second, postgres.activity_detail, told us what the one holding the lock was doing.

Order 42 · selected fields
Waiting   198   UPDATE orders SET state = 'sent' WHERE id = 42;
Holding   186   UPDATE orders SET state = 'paid' WHERE id = 42;
State     186   idle in transaction

Session 186 had finished the update and left its transaction open. There was no running query to cancel. We rolled back the transaction from session 186 in the test. The waiting update finished, order 42 was marked sent and the lock query came back empty. You can try this in three psql sessions.

Who gets to end the database session?

Cloudflare took another approach to a large catalog. Its agent writes JavaScript to search an API specification and call the API in a sandbox. That’s useful when a question needs several requests and you only want a few fields back. Cloudflare’s ruleset example shows how it works.

On our database, we want the agent to find out who holds a lock without asking us. If it wants to terminate that session, we want to hear why. An approval for “run SQL” is too broad to express that. Emisar gives those jobs separate action IDs. The pack defines the query and which arguments the agent can supply. We can approve the read in advance and have the control plane hold the termination for review, whether the request comes from a teammate’s terminal or our Slack bot.

The cost of that choice is that someone has to define each action. If the one you need is missing, add it to a pack, install it on the relevant hosts and trust that version. The agent can then find it with the tools it already has.

Measure your own MCP setup

Save the tools arrays from every page of your servers’ tools/list responses and combine them into one JSON array. For Emisar, sign in and run emisar-mcp list_tools --json to get the array. The script below counts tokens with o200k_base. If your client rewrites tool descriptions or loads them on demand, also count the definitions in the first request it sends the model.

count_tools.py
import json
import sys
import tiktoken

with open(sys.argv[1], encoding="utf-8") as source:
    tools = json.load(source)
text = json.dumps(tools, ensure_ascii=False,
                  sort_keys=True, separators=(",", ":"))
tokens = tiktoken.get_encoding("o200k_base").encode_ordinary(text)
print(f"{len(tools):,} tools, {len(tokens):,} tokens")
Reproduce the three catalog comparisons

We used the November 24 source snapshot and Python’s tiktoken 0.14.0. In a configured checkout of that revision, save this file in portal/ and run mix run --no-start snapshot.exs there. It writes one JSON array per row and the fixed MCP list. Pass each file to the counter above. Running python count_tools.py stack.json prints 167 tools, 32,015 tokens.

snapshot.exs
alias EmisarWeb.MCP.{SchemaRegistry, ToolSchema}

packs = Jason.decode!(File.read!("apps/emisar/priv/packs/catalog.json"))["packs"]
for {file, ids} <- [{"postgres", ["postgres"]},
                    {"stack", ~w(postgres kubernetes redis sentry)},
                    {"catalog", :all}] do
  tools = for pack <- packs, ids == :all or pack["id"] in ids,
              action <- pack["actions"] do
    schema = ToolSchema.action_args_schema(%{args_schema: %{"args" => action["args"] || []}})
    %{name: action["id"], description: action["description"], inputSchema: schema}
  end
  File.write!(file <> ".json", Jason.encode!(tools))
end
File.write!("emisar.json", Jason.encode!(SchemaRegistry.tools()))

For a question you ask regularly, try both setups in fresh sessions with the same model. Compare the first request, then add up the input tokens through the answer. If the agent needs three searches or returns a whole table, you’ll see what that cost too.

The best way to give your AI agents access to production.

Connect your agent to the tools you run. Set the policy; emisar checks each request before it runs.

Three runners. Seven-day audit. No credit card.