Menu

Guides

Agent tool use

Give an agent search as a tool, over MCP or as a function, and teach it when to use the parts that matter.

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

There are two ways to hand an agent MillionShort search. Use MCP when the agent runs in a client that speaks it. Use a function tool when you run the model loop yourself.

MCP serverFunction tool
You writeNothing: one address in the client's settingsA tool definition and a small handler
Works inClaude, Claude Code, Cursor, ChatGPT, VS Code and other MCP clientsAny model API that supports tools
KeyYour API key in a header, or no key at smaller limitsYour API key, on your server
Toolssearch, get_domain_info, list_sourcesWhatever you define

MCP

The hosted server is at one address, and needs nothing installed:

Text
https://mcp.millionshort.com/mcp

Claude Code

Shell
claude mcp add --transport http millionshort https://mcp.millionshort.com/mcp \
  --header "Authorization: Bearer $MILLIONSHORT_API_KEY"

Cursor

In .cursor/mcp.json:

JSON
{
  "mcpServers": {
    "millionshort": {
      "url": "https://mcp.millionshort.com/mcp",
      "headers": { "Authorization": "Bearer ms-YOUR_API_KEY" }
    }
  }
}

Claude apps and ChatGPT

Both add the server as a custom connector by its address. Neither can send an API key, so they connect in the server's no-key mode: search and list_sources, one source and up to 5 results per search, 10 free searches a day and at most 5 in a minute. Each answer says how many are left today.

The MCP page has the exact steps for each client, the tools' arguments, and a way to check the connection with curl.

What the agent sees

Three search tools, all read-only and marked so, which lets a client run them without asking each time. The tools of the other endpoints are on the MCP page.

ToolWhat it doesWithout a key
searchSearches MillionShort's own independent index: the web, plus news, discussions, podcasts, academic and other specialist sources. Returns ranked results with title, URL, site, date, snippet, a popularity band, how visits to the site are moving, where it is popular and what it is built with. What sets it apart is control over which sites and pages come back: - Popularity: remove the N most popular sites to reach lesser-known ones (remove_top_sites), keep only them (only_top_sites), or pick popularity bands (popularity_buckets). - Domains: only (include_domains), block (exclude_domains), boost or bury. - Page types (formats such as tutorials, documentation, forums, listicles) and topics: keep only, exclude, boost or bury. - Site signals: sites with rising or falling visits (traffic_trend), sites popular in a country (popular_in), sites built with a given technology (site_tech), no risky sites (exclude_risky). - Date (start_date, end_date, time_range), language and country. - More text per result: highlights, the passages that answer the query (max_highlights), and the text of the page itself (include_content). A filter that a source cannot apply is reported in a note, never dropped silently; list_sources says which filters each source applies.Yes, with smaller limits
get_domain_infoReturns the popularity rank and band, and the risk level and categories, for up to 25 domains.No
list_sourcesLists the sources the search tool accepts, with a one-line description of each, how often new material arrives in it and which search filters it applies. Also lists the page types, topics, traffic trends and popularity bands.Yes, with smaller limits

A search result arrives as short numbered text for the model, and as structured content for the client: title, URL, site, date, snippet and a popularity band.

A function tool

When you run the loop yourself, define one tool and call the API in its handler. This definition is plain JSON Schema, which every major model API accepts in some wrapper:

JSON
{
  "name": "web_search",
  "description": "Search the web and specialist sources. Returns ranked results with title, URL, site, date and a snippet. Set remove_top_sites to leave out the most popular sites.",
  "input_schema": {
    "type": "object",
    "properties": {
      "query": { "type": "string", "description": "What to search for, in the words a page would use." },
      "sources": {
        "type": "array",
        "items": {
          "type": "string",
          "enum": ["web", "news", "smallweb", "discussions", "hn", "social", "communities", "podcasts", "academic", "medical", "law", "finance", "contracts"]
        },
        "maxItems": 5,
        "description": "Which sources to ask. Default: web."
      },
      "remove_top_sites": {
        "type": "integer",
        "minimum": 0,
        "maximum": 1000000,
        "description": "Leave out results from the N most popular sites, for example 1000 or 100000."
      },
      "num_results": { "type": "integer", "minimum": 1, "maximum": 20 }
    },
    "required": ["query"]
  }
}

The handler turns the model's arguments into a search and returns compact text. Keep what you return short: the model pays for every character.

Example
Python
import os

from millionshort import MillionShort, MillionShortError

client = MillionShort(api_key=os.environ["MILLIONSHORT_API_KEY"])

ALLOWED = {"sources", "remove_top_sites", "num_results"}


def web_search(arguments):
    """The tool handler: the model's arguments in, text for the model out."""
    options = {k: v for k, v in arguments.items() if k in ALLOWED}
    try:
        r = client.search(arguments["query"], max_chars_per_result=500, **options)
    except MillionShortError as error:
        return f"Search failed ({error.code}): {error.message}"
    if not r.results:
        return "No results. Try other words, or another source."
    lines = []
    for hit in r.results:
        date = hit["published_date"] or "undated"
        lines.append(
            f'{hit["position"]}. {hit["title"]}\n   {hit["url"]}\n'
            f'   {hit["source"]} | {date} | {hit["popularity"]["bucket"]}\n   {hit["snippet"]}'
        )
    return "\n\n".join(lines)


print(web_search({"query": "sourdough starter hydration", "remove_top_sites": 1000, "num_results": 3}))

Return errors to the model as text, as above: a model that reads "Search failed (RATE_LIMITED)" can wait or tell the person, and a model that gets an exception cannot.

If you use LangChain or the Vercel AI SDK, the tool is already written: see LangChain and Vercel AI SDK.

Teach the agent to search well

A tool description says what a tool does. It does not say when your agent should reach for it. Put that in the system prompt or the project's rules. Lines that earn their place:

Text
Searching:
- Search before answering anything about current events, prices, versions, or facts you are not sure of.
- Ask the right source: news for this week, academic or medical for research, law for United States
  law, finance for company filings, discussions for opinions. Default to web.
- When results are all from very popular sites and you need first-hand or specialist material,
  search again with remove_top_sites set to 1000 or 10000.
- Web results have no date. For anything recent, include news or social and check the dates.
- Cite the URL of every result you rely on. Say when a source is a small or little-known site.
- Do not open or cite a result that carries a risk label without saying so.
- One search usually costs one credit per source. Do not repeat a search that returned what you need.

For a coding agent, the same guidance ships as a block for AGENTS.md and as a Cursor rule: see Set up for agents.

Keys and limits for agents

Check that it works

Ask the agent: "Use MillionShort to find three small-site write-ups about restoring a cast iron skillet, and tell me how popular each site is." A working set-up calls search with remove_top_sites, and the answer names a popularity band for each result.

This page as Markdown ยท llms.txt