AI SDK MCP client authorization bearer header: what to send Sume

Set headers.Authorization to Bearer plus your Sume API key on the AI SDK http transport, and send only one credential header. An OAuth token is not an API key.

4 min readSume
All posts

Put the key in the transport's headers as Authorization: Bearer <key> and send nothing else. Sume accepts a Bearer header or an x-api-key header, but a request carrying both is rejected with 401 unauthorized, so choose one. That key must live on your server, and it is a different credential from an OAuth access token.

Where does the header go in the AI SDK?

Vercel's AI SDK page builds the client with createMCPClient, an http transport, a url, and an Authorization header holding the word Bearer and the token. Point url at https://mcp.sume.com/mcp and fill the header from an environment variable such as SUME_API_KEY. The full snippet is in AI SDK 7 createMCPClient with Sume.

Can I send both Authorization and x-api-key?

No. Sume's authentication page says a request with both headers gets 401 unauthorized and the message Send only one API key credential. Neither header wins. The page names gateways and fetch wrappers that add their own Authorization header on top of a client that already sends x-api-key as the usual cause, so strip one.

Is an OAuth token a valid substitute for the key?

Both are bearer credentials on the same endpoint, but Sume's docs say they are not interchangeable, and the capabilities differ.

Credentials for hosted Sume MCP, read 2026-09-29.
CredentialHow it reaches the clientSees
API keyYou set the header yourselfFull hosted tool set
OAuth tokenThe client runs the MCP OAuth flow and consentRead-only tools; write tools only if Write was granted

What should I never do with the token or key?

Sume's OAuth page says an OAuth token is not a Sume API key, and lists three things to avoid: storing OAuth tokens in CLI config, pasting them into prompts, and forwarding them to third-party providers. It also says not to mint API keys for hosted OAuth clients as a workaround. If a key shows up in logs or chat history, rotate it.

The authentication page adds that keys belong on trusted servers or CI secret stores, not in frontend JavaScript. Keep the AI SDK call in a server route, and let the browser talk to your route.

What does the key see once connected?

An API-key session sees write and paid tools. Execution still requires idempotency_key on mutating and paid calls, and max_spend_usd caps spend only when you pass it. See MCP OAuth and API keys before handing the tool list to a model.

How do I test the header safely?

Call mcp_health first. Sume's docs say it reports the auth source, and for OAuth sessions they name mcp_oauth as the value to expect. An API-key session should show a different source, which tells you which credential the server actually saw.

Then call tools_list. With a key you should see write and paid tools such as generate_image; a read-only OAuth session would not. Keep the key out of the prompt and out of any log line you print while debugging, and rotate it if it ever appears in one.

Sources

Related posts

More in Developers

All Developers posts

Written by Sume