Skip to content
news / mcp-per-caller-billing · raw .md
AgentsUpdated 7 min readMapMap engineering
Several request lines entering one gateway aperture, each carrying a distinct keyed tag, with separate columns of tally marks of differing heights accumulating beside each tag.

Bring your own key, and the MCP endpoint bills you

For its first months, every call an agent made to our MCP server ran on one shared key. The server held a single GATEWAY_API_KEY, spent it on every metered request, and had no way to tell one caller's traffic from another's. That was acceptable for a demo and no use for a business: we could not meter, attribute or invoice anyone who built on the MCP surface. In August 2026 we rebuilt the MCP server so that a caller presents their own gateway key on the streamable-HTTP transport; the server forwards that key to the gateway, and the metered calls they make are billed to it instead of ours. We checked the change on the live endpoint: a request bearing a snk_ key is accepted and answers 200.

This is a piece the rest of our agent story rested on. An agent can already discover our tools by asking the server, and call them unattended. What it could not do was have those calls attributed to it, because there was only ever one bill and it was addressed to us. Now the metered calls a caller makes are billed to the caller's own key. And funding that key no longer needs a person in the middle: a caller can top up its own balance and carry on, which closes the loop we describe below.

How an agent presents its key

On the streamable-HTTP transport, the key travels as an ordinary bearer header, the same one the REST API already takes:

makefile
Authorization: Bearer snk_your_key

The server reads that header on each request and routes every metered call in the tool invocation through the gateway on the caller's key, so the usage meters and bills to them. In a typical client you set it beside the URL. Claude Code:

sh
claude mcp add --transport http mapmap https://mcp.mapmap.ai/mcp \
  --header "Authorization: Bearer snk_your_key"

Any streamable-HTTP client that lets you set request headers works the same way, by adding an Authorization header to the server entry.

The mechanism is deliberately narrow. Only a bearer token that begins snk_ (a gateway key) or sno_ (an OAuth access token MapMap issued, for a client that signs in rather than pasting a key) is treated as a billing credential. An operator's own server-access token, or any other string, is not mistaken for one: the call simply runs as an anonymous caller instead. So if you mean to be billed, check that the token you send actually starts snk_ or sno_.

What gets billed, and what stays free

The tools that reach the MapMap gateway are the ones that meter to your key: route, geocode, reverse_geocode, matrix, reachable_area, optimise_routes, order_stops, search_along_route, cheapest_fuel_along_route, cheapest_charging_along_route, plan_ev_route, nearby_places, plan_day, elevation, match_trace, and the itinerary feasibility pass inside verify_places. The list grows with the tool surface, so read it from llms.txt rather than from here. Each draws down that key's allowance and is priced exactly as the same capability over REST, so nothing costs more or less for having arrived through MCP. The pricing page has the schedules, and x402 payments covers what happens once a key is past its allowance, which is the same 402-versus-429 behaviour the gateway serves everywhere else.

The style publishes are metered too, and here the change opens a door that was shut. create_style, set_palette and set_layer_paint were refused on the open hosted endpoint, because publishing has to be signed with a gateway key and an open endpoint would otherwise sign it with ours. A caller presenting their own snk_ key is spending their own credential, not the operator's, so that objection does not apply to them. With your key on the header you can now publish styles over the hosted transport as well as read them.

A good part of the surface bills nothing and needs no key at all. The local-geometry tools, the geo_* family, run as pure computation on the coordinates you supply. So do validate_geodata, check_adr_tunnel, list_place_categories, list_style_layers and check_style_contrast. Style reads through get_style are public. None of those touch the gateway, so they answer on any transport, metered or not, keyed or not.

What happens with no key

Nothing breaks when a caller sends no key. An anonymous HTTP request dispatches on the operator's server exactly as before: on the hosted endpoint that is the fair-use evaluation lane, rate limited per client IP, with a 429 and a Retry-After when the bucket empties. Style publishes stay refused on that path, for the reason above. The endpoint is still open to connect and try, and connecting without a key is the right way to evaluate it.

Over stdio there is no per-request header to read, because there is no HTTP request. A caller on stdio owns the process and its environment, so calls use whatever key the process was started with. Per-caller billing is a property of the HTTP transport, where many callers share one server, which is exactly where telling them apart matters.

Why this was a missing piece

We describe MapMap as built for agents, and part of that is an agent being charged for exactly what it uses. Three things have to line up: the agent can find the tools, it can call them unattended, and its usage can be attributed and billed to it rather than to whoever runs the server. The first two were already true. The third was not, because a shared operator key cannot be metered per caller. Threading the caller's own key through to the gateway is the plumbing that fixes it, and it turns the MCP surface from a demonstration into something a build can run on and be invoiced for.

This closes the loop end to end: an agent can obtain a key, call metered tools, and when it runs past its allowance, top up and carry on, without a person in the middle. The one thing worth knowing is that paying happens on the HTTP API rather than inside MCP, because the MCP protocol has no payment channel of its own. A caller that hits a paid MCP call tops up over the same gateway endpoint and resumes.

What this does not do

  • Paying happens over HTTP, not inside MCP. The MCP protocol has no payment channel, so a caller that exhausts its allowance tops up through the gateway's HTTP endpoint and resumes. The loop can run without a person; the pay step just lives on the API side rather than in the tool call.
  • It does not change what anything costs. A metered call bills at the same price whether it arrives over MCP or REST. MCP is another way to reach the gateway, not a separate tariff.
  • It is an HTTP feature. A stdio caller keeps spending the process key, by design. If you want per-caller billing, connect over streamable HTTP and send the header.
  • Any other token is ignored as a billing key, not rejected. The call still runs, anonymously, on the operator key. That keeps the keyless evaluation lane working, but it means a mistyped key bills nobody rather than erroring, so verify the prefix if you expect a charge.
  • It does not remove the fair-use lane, and that lane can be closed. Keyless hosted access is for evaluation and remains an operator choice, not a promise to build against.

Try it

Add the endpoint with your key on the header, then ask your agent for something that runs on it: geocode a place and route to it, or plan a day from a list of stops. The MCP connection guide has the per-client configuration and the full authentication-and-billing rules, and the agents page collects what we host for machine callers.

Routing and map data derive from OpenStreetMap. Credit "© OpenStreetMap contributors" when you render or republish it.