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
npm install genkit @genkit-ai/mcp @genkit-ai/google-genai
export MILLIONSHORT_API_KEY=ms-YOUR_API_KEYThe 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.
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.
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:
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 tools4Check 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:
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:
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.
| Mode | How | What the agent gets |
|---|---|---|
| API key | Send Authorization: Bearer ms-YOUR_API_KEY | Every tool, at your plan's limits; calls use your credits |
| No key | Send no Authorization header | search, list_sources and a few more; one source and up to 5 results a search, 10 free searches a day |
Tools
| Tool | What it does | Without a key | Cost |
|---|---|---|---|
search | Searches the web and the specialist sources, with the popularity, domain, page-type, topic, site and date filters | Yes: one source, up to 5 results | 1 credit per source searched, first 10 results |
get_domain_info | Popularity and risk for up to 25 sites | No | 1 credit |
list_sources | The sources, page types and topics search accepts | Yes: source names | Free |
| The tools of the other endpoints | extract, map, crawl, places and more: the MCP page lists them | A few, such as places | What the API call behind each costs |
Settings
| Variable | Meaning |
|---|---|
MILLIONSHORT_API_KEY | Your 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 see | Why | Fix |
|---|---|---|
| The server does not connect, or no tools are listed | The address or the transport is not the one the server speaks | Use 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 up | Add a key: it is free in the dashboard |
INSUFFICIENT_CREDITS | The plan's credits are used up | Stop and add credits; retrying does not help |
| The agent answers from memory, or uses another search | Nothing told it when to use this one | Turn off its own search where it can be (this page says how), and add the line for its instructions |
getActiveTools returns no MillionShort tools | The connection failed, or the server entry has disabled: true | Check the URL and the header, then list the tools as in step 4 |
Related
- Agent tool use: when to give a model tools, and what to tell it.
- Vercel AI SDK and OpenAI Agents SDK: the same server in other TypeScript frameworks.
- MCP server and Filters for agents.
- Genkit's own documentation, read on 2026-11-19: Model Context Protocol, Tool calling, Google Generative AI plugin.