Cloudflare Agents addMcpServer for Sume: streamable-http and headers
Connect a Cloudflare Agent to Sume's hosted MCP server with addMcpServer, an explicit streamable-http transport and a bearer header, and keep jobs resumable.

Cloudflare's Agents SDK can hold MCP connections inside an agent. The MCP client API page documents addMcpServer(name, url, options) with a callbackHost and a transport of type streamable-http, sse or auto (the default) plus headers, read 2026-10-03. The call returns either {state: "authenticating", authUrl} or "ready". Sume's hosted MCP server is Streamable HTTP at https://mcp.sume.com/mcp, so an explicit streamable-http removes the guesswork.
Connecting with a key
Sume accepts an API key as Authorization: Bearer or x-api-key, per the Sume MCP overview. Send one. The snippet reads the key from a Worker secret. With a valid key the call should return a ready state; the Cloudflare page does not say what your result looks like for a key that Sume rejects, so log it.
async onStart() {
const res = await this.addMcpServer(
"sume",
"https://mcp.sume.com/mcp",
{
transport: {
type: "streamable-http",
headers: { Authorization: `Bearer ${this.env.SUME_API_KEY}` },
},
}
);
if (res.state === "authenticating") console.log(res.authUrl);
}What persists
The page says connections persist in the agent's SQL storage and survive hibernation, and that removeMcpServer(serverId) drops one. That matters for long jobs: an agent can hibernate while a Sume job runs. Store the job id in the agent's state the moment a create tool returns it, then call jobs_wait after wake-up. Do not re-run the create; paid and write tools need an idempotency_key and a retry without the same key is a new charge.
| Choice | Option | Note |
|---|---|---|
| Transport | streamable-http | Matches Sume's server |
| Transport | auto (default) | Detects the transport; explicit is clearer |
| Credential | Bearer header with a key | One credential only |
| Credential | OAuth with authUrl | mcp:read required, mcp:write opt-in |
| Cleanup | removeMcpServer(serverId) | Drop a server you no longer use |
Keep the waits honest
jobs_waitholds 50 seconds by default and 55 at most; values above are clamped withwait_slice_clamped.- On
wait_slice_expired, ask again with the same ids. - A 524, 522, 523 or 525 is transport, not a job result.
- Use
jobs_resultwithjob_idsto read several finished jobs at once.
Sources
Related posts
More in Developers
- Cloudflare portal Code Mode policy vs Sume script_run
Both shrink tool-call overhead, in different places. What Cloudflare's portal Code Mode policy controls and when Sume script_run is the other half.
- Cloudflare MCP portal logs: telling Sume read and paid calls apart
Portal logs record tool activity and Logpush exports it. Which Sume tool names mean spend, so a SIEM rule can flag them without reading arguments.
- How to compare AI video models fairly: one prompt, three models, 480p
Submit one prompt to Seedance 2.0 Mini, Wan 3.0 and MiniMax H3 at 480p and 5 seconds on Sume, then judge the clips blind. A runnable Python test harness.
- Join more than 20 voiceover lines: two-level timeline audio concat
Timeline audio concat takes 1 to 20 parts. A 120-line script needs six group joins and one final join, seven jobs, $0.07. A Python planner and offset math.
Written by Sume