Genkit createMcpHost: connect the hosted Sume MCP server

Genkit's createMcpHost takes a url and requestInit headers for remote servers. Wire https://mcp.sume.com/mcp into ai.generate and close the host after.

5 min readSume
All posts

Short answer

In @genkit-ai/mcp, declare the server under mcpServers with a url and a requestInit.headers object, pass await mcpHost.getActiveTools(ai) to ai.generate, and call await mcpHost.close() at the end. The Genkit MCP docs show url and requestInit for remote servers and name authProvider for OAuth flows.

Sume's endpoint is https://mcp.sume.com/mcp. The OAuth and API keys page says it accepts either OAuth or an API key sent as Authorization: Bearer or x-api-key. The sample below uses the key header so it needs no browser consent step.

What the Genkit docs document

The install is npm i genkit @genkit-ai/mcp; the sample below also uses the Google plugin, @genkit-ai/google-genai. The same page's complete example uses stdio servers and a Gemini model; the remote form swaps the command and args for a url.

Genkit MCP options (read 2026-10-03)
OptionPurpose
urlendpoint of a remote HTTP MCP server
requestInitcustomize the HTTP requests, such as headers
authProviderOAuth-based authentication flows
getActiveTools(ai) / close()pass tools to ai.generate; disconnect when done

The script

Save as sume.mjs, set SUME_API_KEY and the model credentials Genkit's Google plugin expects, and run it with Node. The prompt asks only for read tools, but the key itself can reach paid tools, so keep the instructions narrow.

import { googleAI } from '@genkit-ai/google-genai';
import { createMcpHost } from '@genkit-ai/mcp';
import { genkit } from 'genkit';

const mcpHost = createMcpHost({
  name: 'sumeMcp',
  mcpServers: {
    sume: {
      url: 'https://mcp.sume.com/mcp',
      requestInit: {
        headers: { Authorization: `Bearer ${process.env.SUME_API_KEY}` },
      },
    },
  },
});

const ai = genkit({ plugins: [googleAI()] });

const { text } = await ai.generate({
  model: googleAI.model('gemini-flash-latest'),
  prompt: 'Call mcp_health, then tools_list, and summarize what this session can do.',
  tools: await mcpHost.getActiveTools(ai),
});

console.log(text);
await mcpHost.close();

Closing the host is not cancelling a job

Calling close() disconnects the MCP session. A Sume job that a tool call already started keeps running and billing; closing the client does not cancel it. Keep the job id from the tool result and resume with jobs_status or jobs_wait, or cancel with jobs_cancel, which is a write tool.

Each jobs_wait call holds at most 55 seconds, so a long render needs the call repeated with the same ids.

What Sume does and does not do

Sume gates by credential: an OAuth session reads by default, an API-key session sees everything and must send an idempotency_key on writes and paid calls. It publishes mcp_health, tools_list and tools_schema as the first calls to verify a session.

Sume does not run Genkit's model for you; the orchestrating LLM and its bill belong to the Genkit side.

Sources

Related posts

More in Developers

All Developers posts

Written by Sume