Menu

Integrations / Frameworks & SDKs

Claude Agent SDK

MillionShort search for agents built with the Claude Agent SDK, in Python and TypeScript.

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

MCPPython and TypeScriptNothing of ours to installWorks with no keyChecked 2026-11-19

The Agent SDK runs Claude Code's agent loop inside your application. You add the MillionShort MCP server to the options of query() as an HTTP server, allow its tools by name, and turn off the SDK's own web tools so the agent searches with MillionShort. The agent then has the tools you allow, named mcp__millionshort__search and so on: search, get_domain_info, list_sources and the tools of the other endpoints (the MCP page lists them all).

1Install

Choose one
Shell
pip install claude-agent-sdk
export MILLIONSHORT_API_KEY=ms-YOUR_API_KEY

The SDK needs Python 3.10 or later, or Node.js 18.14 or later, and reads your Anthropic key from ANTHROPIC_API_KEY. Get a MillionShort key in the dashboard; an agent can ask for a trial key by itself.

The SDK runs Claude Code: each query() starts a Claude Code process and talks to it. Both packages bundle a native Claude Code binary, so most installs need nothing else. Two installs come without it, according to the SDK's docs: pip installing the source distribution instead of a platform wheel (on ARM64 Windows, for example), and npm skipping optional dependencies (npm ci --omit=optional). Then install Claude Code yourself: the Python SDK finds it on your PATH, and in TypeScript you set pathToClaudeCodeExecutable to it.

2Connect the server

Pass the server in mcp_servers (mcpServers in TypeScript) with type http. MCP tools need permission before Claude can call them, so list them in allowed_tools; disallowed_tools takes the built-in WebSearch and WebFetch tools out of the agent's context. Without a key, leave the headers out.

Choose one
Python
import asyncio
import os

from claude_agent_sdk import ClaudeAgentOptions, ResultMessage, query


async def main():
    options = ClaudeAgentOptions(
        mcp_servers={
            "millionshort": {
                "type": "http",
                "url": "https://mcp.millionshort.com/mcp",
                "headers": {"Authorization": f"Bearer {os.environ['MILLIONSHORT_API_KEY']}"},
            }
        },
        allowed_tools=["mcp__millionshort__search", "mcp__millionshort__get_domain_info", "mcp__millionshort__list_sources"],
        disallowed_tools=["WebSearch", "WebFetch"],
    )
    prompt = "Find independent blogs about home espresso, without the 1,000 most popular sites."
    async for message in query(prompt=prompt, options=options):
        if isinstance(message, ResultMessage) and message.subtype == "success":
            print(message.result)


asyncio.run(main())

mcp__millionshort__* allows every tool of the server at once, crawl included, which spends credits. The middle part of each name is the key you give the server in mcp_servers.

3Give the tools to an agent

A research agent needs no files and no shell. tools=[] removes every built-in tool, web tools included, so the MillionShort tools are all the agent has; system_prompt says when to use them and max_turns caps the loop.

Choose one
Python
import asyncio
import os

from claude_agent_sdk import ClaudeAgentOptions, ResultMessage, query

options = ClaudeAgentOptions(
    mcp_servers={
        "millionshort": {
            "type": "http",
            "url": "https://mcp.millionshort.com/mcp",
            "headers": {"Authorization": f"Bearer {os.environ['MILLIONSHORT_API_KEY']}"},
        }
    },
    tools=[],
    allowed_tools=["mcp__millionshort__*"],
    system_prompt="Use the MillionShort search tool for anything recent or niche, and cite the URLs.",
    max_turns=8,
)


async def main():
    async for message in query(prompt="Find independent blogs about home espresso.", options=options):
        if isinstance(message, ResultMessage) and message.subtype == "success":
            print(message.result)


asyncio.run(main())

A line that works well in the system prompt:

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.

4Check it works

The first message of every run is a system message with subtype init. It gives each MCP server's status and the tools the agent has; millionshort should be connected, with its mcp__millionshort__ tools listed.

Choose one
Python
import asyncio
import os

from claude_agent_sdk import ClaudeAgentOptions, SystemMessage, query


async def main():
    server = {"type": "http", "url": "https://mcp.millionshort.com/mcp", "headers": {"Authorization": f"Bearer {os.environ['MILLIONSHORT_API_KEY']}"}}
    options = ClaudeAgentOptions(mcp_servers={"millionshort": server}, allowed_tools=["mcp__millionshort__*"])
    async for message in query(prompt="List the sources MillionShort can search.", options=options):
        if isinstance(message, SystemMessage) and message.subtype == "init":
            print(message.data.get("mcp_servers"))
            print([name for name in message.data.get("tools", []) if name.startswith("mcp__")])


asyncio.run(main())

A status of pending is not a failure on its own: the SDK may still be connecting, or may have the tool list cached from an earlier run and connect on the first call. failed or needs-auth means the agent runs without the tools.

Without the remote server: a custom tool

The SDK's own way to add a function is a custom tool, served from inside your process by an in-process MCP server. This one calls POST /v1/search directly. The Python version uses httpx, as the SDK's docs do:

Python
pip install claude-agent-sdk httpx
Choose one
Python
import asyncio
import json
import os
from typing import Any

import httpx
from claude_agent_sdk import ClaudeAgentOptions, ResultMessage, create_sdk_mcp_server, query, tool


@tool("millionshort_search", "Search the web with MillionShort, without the 1,000 most popular sites.", {"query": str})
async def millionshort_search(args: dict[str, Any]) -> dict[str, Any]:
    async with httpx.AsyncClient(timeout=30) as client:
        response = await client.post(
            "https://api.millionshort.com/v1/search",
            json={"query": args["query"], "remove_top_sites": 1000, "num_results": 5},
            headers={"Authorization": "Bearer " + os.environ["MILLIONSHORT_API_KEY"]},
        )
    response.raise_for_status()
    results = [{"title": r["title"], "url": r["url"], "snippet": r.get("snippet")} for r in response.json()["data"]["results"]]
    return {"content": [{"type": "text", "text": json.dumps(results)}]}


async def main():
    server = create_sdk_mcp_server(name="web", version="1.0.0", tools=[millionshort_search])
    options = ClaudeAgentOptions(mcp_servers={"web": server}, allowed_tools=["mcp__web__millionshort_search"], tools=[])
    async for message in query(prompt="Find independent blogs about home espresso.", options=options):
        if isinstance(message, ResultMessage) and message.subtype == "success":
            print(message.result)


asyncio.run(main())

MCP configuration

The same address for every client: https://mcp.millionshort.com/mcp, streamable HTTP. In the SDK that is type http; a .mcp.json file in your project takes the same fields.

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

The SDK's own options that matter here: allowed_tools (allowedTools) pre-approves the tools, disallowed_tools (disallowedTools) or tools removes the built-in ones, and max_turns (maxTurns) limits the loop.

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.

Each turn the agent takes can call search again, so max_turns is also a spending limit.

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
Claude sees the tools but does not call themMCP tools need permission, and they are not in allowed_toolsAdd mcp__millionshort__* to allowed_tools (allowedTools)
The server is failed or needs-auth in the init message, and the run goes on without itThe key is missing or wrong, or the address cannot be reachedCheck the key and the address; the SDK does not stop the run for a server that fails to connect
The agent searches with its own web toolsWebSearch and WebFetch are still in its contextAdd them to disallowed_tools, or pass tools=[]
"Claude Code not found"The install has no bundled Claude Code binaryInstall Claude Code, then set cli_path (Python) or pathToClaudeCodeExecutable (TypeScript) if it is not on your PATH

This page as Markdown ยท llms.txt