6 min read

MCP API Key Header: Move Your Key Out of the URL by November 30

Illustration of a robotic hand lifting a brass key out of a glowing web address bar and placing it into a sealed blue envelope with a padlock, beside a cargo ship, shipping containers and a laptop linked by data lines
Moving your MCP API key from the URL into a header keeps it out of the request line that logs record.

Written for developers who connect AI assistants, agents, and checkout or landed-cost tools to the Tariffs API MCP server.

Short answer: if your MCP client sends its key in the URL as ?api_key=, move it to an Authorization: Bearer header (or an X-API-Key header) now. The query parameter is deprecated and its sunset date is Monday, November 30, 2026. After the sunset, a request that carries its key only in the URL is set to get a 401 instead of tariff data.

Header keys already work today on every MCP endpoint, so the switch is a one-line config change with no downtime and nothing to migrate on your account.

What changes on November 30, 2026

On October 31, 2026 we deprecated the api_key query parameter on all three MCP endpoints:

  • https://tariffsapi.com/api/v1/mcp: Streamable HTTP, the recommended transport
  • https://tariffsapi.com/api/v1/mcp/sse: legacy SSE stream
  • https://tariffsapi.com/api/v1/mcp/messages: legacy SSE messages

Until the sunset, a key in the URL still authenticates. To make sure nobody is caught out, every response to such a request, errors included, now carries four extra headers:

Header What it says Deprecation true Sunset Mon, 30 Nov 2026 00:00:00 GMT Link the changelog entry that announced the change, with rel="deprecation" Warning 299 - "api_key query parameter is deprecated; use Authorization: Bearer"

The Sunset header gives the exact moment: the start of November 30 in GMT. For teams in the Americas that is still the evening of Sunday, November 29, local time, so the safe plan is to ship the change before the weekend. You can read the original notice on our changelog.

Why an API key in the URL is a security risk

A URL is not a good place for a secret. It is copied into places you do not control:

  • Access and proxy logs. Common access log formats, including the defaults for nginx and Apache, record the full request line, query string and all. Every proxy, load balancer and logging pipeline between your client and us can end up storing the key.
  • Browser history and Referer headers. If a URL with a key is ever opened in a browser, it lands in history and can leak to other sites through the Referer header.
  • Config files, screenshots and chat messages. A server URL gets pasted far more freely than something labelled as a secret.

A header is not magic, but it keeps the key out of the request line, which is the part almost everything logs by default. That is the core of good API key security for MCP clients: treat the key as a credential, not as part of an address.

Illustration of a long ribbon passing through a server rack and a proxy box into a pile of open log books, each page stamped with copies of the small brass key tied to the ribbon
A key in the URL travels with the address, so every server, proxy and log along the way can keep a copy.

How to send your API key in a header

Both of these work on all three endpoints today.

POST /api/v1/mcp HTTP/1.1
Host: tariffsapi.com
Authorization: Bearer YOUR_API_KEY
Content-Type: application/json

X-API-Key header

If your client or gateway already reserves the Authorization header for something else, use the X-API-Key header instead:

X-API-Key: YOUR_API_KEY

A header always wins over the query string. If a request sends both a header and ?api_key=, we use the header and ignore the URL key, so you can add the header first and remove the query parameter afterwards without a gap.

MCP server authentication in Claude Desktop, Cursor and Windsurf

These are the same configs as in the MCP setup guide. Replace YOUR_API_KEY with a key from your API keys dashboard, and delete any ?api_key= you had on the end of the URL.

Claude Desktop (claude_desktop_config.json):

{
  "mcpServers": {
    "tariffs-api": {
      "url": "https://tariffsapi.com/api/v1/mcp",
      "headers": {
        "Authorization": "Bearer YOUR_API_KEY"
      }
    }
  }
}

Cursor (.cursor/mcp.json in the project root, or global settings) uses the same shape: a url plus a headers object with Authorization.

Windsurf (~/.codeium/windsurf/mcp_config.json) uses serverUrl instead of url, with the same headers object.

MCP Inspector, for a quick test from the terminal:

npx @modelcontextprotocol/inspector \
  --url "https://tariffsapi.com/api/v1/mcp" \
  --header "Authorization: Bearer YOUR_API_KEY"

If you built your own agent or checkout integration, look for wherever the MCP server URL is assembled and move the key from the URL into the request headers of your HTTP client.

Illustration of a developer at a laptop with a friendly AI assistant beside the screen, connected by a padlocked cable to a customs building with shipping containers and a cargo crane
With the key in a header, your AI assistant keeps a secure connection to live tariff data.

How to check you are done

  1. Search your code, config and environment variables for api_key= next to tariffsapi.com/api/v1/mcp.
  2. Send one request with the key in a header and look at the response headers:
curl -i -X POST "https://tariffsapi.com/api/v1/mcp" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"capabilities":{}}}'

If the response has no Deprecation or Sunset header, that client is already on a header key. If you still see them, some part of your setup is still sending the key in the URL.

Other MCP changes that shipped with the header switch

The same release tightened how the MCP tools answer, so results match the REST API more closely:

  • GetByHtsTool now lists the same additional duties as resolve. When you pass an origin, its additional measures come from the same calculation the resolve endpoint uses, so duties that stack, such as Section 232 alongside Section 301, all appear. You may see more duties listed for a line than before, and a total built from them may be higher. Our Section 301 and Section 232 stacking guide walks through a real case.
  • Unknown HTS codes now fail clearly. ResolveTariffTool and GetByHtsTool return an error with the code HTS_NOT_FOUND for a code we cannot identify, instead of a result. In BatchResolveTariffsTool a failing item returns its own error and the rest of the batch still resolves.
  • Dates must be YYYY-MM-DD. The as_of parameter on the MCP tools accepts only that format; anything else fails with INVALID_DATE rather than being guessed at.
  • Tool results are JSON. Every tool result is JSON text, and a failed call sets isError: true, so your agent can tell a failure from an answer without reading the text.

Using the tariff API and HTS API after the switch

Nothing else about the integration changes. The same five read-only tools answer on the same endpoints, and they return the same data as the REST tariff API. If you are building an AI assistant or agent on top of them, these guides go deeper:

You can also browse the HTS schedule and the Chapter 99 headings that the tools draw on, or read the full API documentation.

Frequently asked questions

Do I need a new API key?

No. Your existing key works in a header exactly as it did in the URL. If a key has ever been shared in a URL that may have been logged, it is still good practice to create a new one in your dashboard and revoke the old one.

What happens if I do nothing?

Until the sunset your client keeps working and every response carries the deprecation headers. After November 30, 2026, a request that sends its key only in the URL is set to be refused with a 401, so your assistant or integration would stop getting tariff answers.

Does the legacy SSE transport need the header too?

Yes. The deprecation covers the SSE stream and its messages endpoint as well. If you are touching the config anyway, it is a good moment to move to Streamable HTTP at https://tariffsapi.com/api/v1/mcp, which is the recommended transport for new integrations.

Explore the data

Related news