Menu

Integrations / Frameworks & SDKs

Genkit

MillionShort search as tools for a Genkit generate call, in TypeScript.

Copy as MarkdownOpen in ChatGPT (opens in a new tab)Open in Claude (opens in a new tab)

MCPTypeScriptNothing of ours to installWorks with no keyChecked 2026-11-19

Genkit's MCP plugin connects to the MillionShort MCP server by URL and turns its tools into Genkit tools, so any model Genkit runs can call search, get_domain_info, list_sources and the tools of the other endpoints, such as extract, places, map and crawl (the MCP page lists them all). Without MCP, a tool defined with ai.defineTool that calls the API does the same job.

Remote MCP servers are a feature of the TypeScript plugin. Genkit's Python MCP plugin is in preview and its docs describe only servers it starts as a local process, so this page is TypeScript only.

1Install

TypeScript
npm install genkit @genkit-ai/mcp @genkit-ai/google-genai
export MILLIONSHORT_API_KEY=ms-YOUR_API_KEY

The examples use the Google AI plugin, which reads your Gemini key from GEMINI_API_KEY; any model plugin works. Get a MillionShort key in the dashboard; an agent can ask for a trial key by itself.

2Connect the server

createMcpHost manages one or more MCP servers. The key under mcpServers names the server, and the key goes in requestInit.headers. Without a key, leave requestInit out.

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

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

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

3Give the tools to a generate call

getActiveTools returns the server's tools as Genkit tools; pass them to ai.generate, a prompt or a chat.

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

const mcpHost = createMcpHost({
  name: 'myMcpClients',
  mcpServers: {
    millionshort: {
      url: 'https://mcp.millionshort.com/mcp',
      requestInit: { headers: { Authorization: `Bearer ${process.env.MILLIONSHORT_API_KEY}` } },
    },
  },
});
const ai = genkit({ plugins: [googleAI()] });

try {
  const { text } = await ai.generate({
    model: googleAI.model('gemini-flash-latest'),
    system: 'Use the millionshort search tool for anything recent or niche, and cite the URLs.',
    prompt: 'Find independent blogs about home espresso, without the 1,000 most popular sites.',
    tools: await mcpHost.getActiveTools(ai),
  });
  console.log(text);
} finally {
  await mcpHost.close();
}

For one server you can use createMcpClient instead. Its name becomes the namespace of the tools:

TypeScript
import { createMcpClient } from '@genkit-ai/mcp';

export const millionshort = createMcpClient({
  name: 'millionshort',
  mcpServer: {
    url: 'https://mcp.millionshort.com/mcp',
    requestInit: { headers: { Authorization: `Bearer ${process.env.MILLIONSHORT_API_KEY}` } },
  },
});
// await millionshort.ready(); then pass await millionshort.getActiveTools(ai) as tools

4Check it works

Run the example: the answer should cite pages. To see the tools without a model, list their names. Genkit namespaces them by the server's key, so expect millionshort/search, millionshort/get_domain_info, millionshort/list_sources and the rest of the server's tools under the same prefix:

TypeScript
import { createMcpHost } from '@genkit-ai/mcp';
import { genkit } from 'genkit';

const mcpHost = createMcpHost({
  name: 'myMcpClients',
  mcpServers: {
    millionshort: {
      url: 'https://mcp.millionshort.com/mcp',
      requestInit: { headers: { Authorization: `Bearer ${process.env.MILLIONSHORT_API_KEY}` } },
    },
  },
});
const ai = genkit({});

const tools = await mcpHost.getActiveTools(ai);
console.log(tools.map((tool) => tool.__action.name));
await mcpHost.close();

The Genkit Developer UI also lists the tools once the host is set up. If the model answers from memory, say when to search in its instructions:

Use the MillionShort search tool for anything recent, niche, or that needs a source. To reach lesser-known sites, set remove_top_sites (for example 1000). Cite the URLs it returns.

Without MCP: a function tool

A tool defined with ai.defineTool that calls POST /v1/search works with any model Genkit runs:

TypeScript
import { googleAI } from '@genkit-ai/google-genai';
import { genkit, z } from 'genkit';

const ai = genkit({ plugins: [googleAI()], model: googleAI.model('gemini-flash-latest') });

const millionshortSearch = ai.defineTool(
  {
    name: 'millionshortSearch',
    description: 'Search the web with MillionShort. remove_top_sites leaves out the N most popular sites.',
    inputSchema: z.object({ query: z.string(), remove_top_sites: z.number().int().default(1000) }),
    outputSchema: z.array(z.object({ title: z.string(), url: z.string(), snippet: z.string().optional() })),
  },
  async ({ query, remove_top_sites }) => {
    const res = await fetch('https://api.millionshort.com/v1/search', {
      method: 'POST',
      headers: { Authorization: `Bearer ${process.env.MILLIONSHORT_API_KEY}`, 'Content-Type': 'application/json' },
      body: JSON.stringify({ query, remove_top_sites, num_results: 5 }),
    });
    if (!res.ok) throw new Error(`search failed: ${res.status}`);
    const { data } = (await res.json()) as { data: { results: { title: string; url: string; snippet?: string }[] } };
    return data.results.map(({ title, url, snippet }) => ({ title, url, snippet }));
  },
);

const { text } = await ai.generate({ prompt: 'Find independent blogs about home espresso.', tools: [millionshortSearch] });
console.log(text);

MCP configuration

The same address for every client: https://mcp.millionshort.com/mcp, streamable HTTP.

ModeHowWhat the agent gets
API keySend Authorization: Bearer ms-YOUR_API_KEYEvery tool, at your plan's limits; calls use your credits
No keySend no Authorization headersearch, list_sources and a few more; one source and up to 5 results a search, 10 free searches a day

Tools

ToolWhat it doesWithout a keyCost
searchSearches the web and the specialist sources, with the popularity, domain, page-type, topic, site and date filtersYes: one source, up to 5 results1 credit per source searched, first 10 results
get_domain_infoPopularity and risk for up to 25 sitesNo1 credit
list_sourcesThe sources, page types and topics search acceptsYes: source namesFree
The tools of the other endpointsextract, map, crawl, places and more: the MCP page lists themA few, such as placesWhat the API call behind each costs

Settings

VariableMeaning
MILLIONSHORT_API_KEYYour key, read by the examples above. Leave the header out for the no-key mode

Costs and limits

A tool call costs what the API call behind it costs: 1 credit per source searched for the first 10 results, 1 credit for a domain lookup, nothing for the list of sources, the price of the endpoint for the other tools, and nothing at all in the no-key mode. An agent that loops can make many calls: give it a step limit, and ask for fewer results when a few will do. Credits and limits has the numbers.

When it fails

What you seeWhyFix
The server does not connect, or no tools are listedThe address or the transport is not the one the server speaksUse exactly https://mcp.millionshort.com/mcp and the streamable HTTP transport (often called http), not SSE
401 or "unauthorized"The key is wrong, or it was sent without Bearer Send Authorization: Bearer ms-..., or leave the header out to use the no-key mode
"10 free searches a day without a key"The no-key mode's daily searches are used upAdd a key: it is free in the dashboard
INSUFFICIENT_CREDITSThe plan's credits are used upStop and add credits; retrying does not help
The agent answers from memory, or uses another searchNothing told it when to use this oneTurn off its own search where it can be (this page says how), and add the line for its instructions
getActiveTools returns no MillionShort toolsThe connection failed, or the server entry has disabled: trueCheck the URL and the header, then list the tools as in step 4

This page as Markdown ยท llms.txt