Menu

Integrations / Frameworks & SDKs

LangChain

MillionShort search for LangChain agents, through LangChain's own MCP adapter, 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

LangChain connects to the MillionShort MCP server with its own MCPAdapter: it opens the connection, finds the server's tools, search, get_domain_info, list_sources and the tools of the other endpoints (the MCP page lists them all), and turns them into LangChain tools you pass to create_agent (createAgent in TypeScript). With no MCP at all, a function tool that calls the API does the same job. MillionShort's own LangChain packages are coming soon.

1Install

Choose one
Shell
pip install "langchain[mcp]" langchain-anthropic
export MILLIONSHORT_API_KEY=ms-YOUR_API_KEY

In Python, MCP ships inside LangChain from version 1.4 as langchain.mcp, through the mcp extra. It is in beta: importing it prints a beta warning once, and the API may change. Before 1.4 the same job was done by the standalone langchain-mcp-adapters package and its MultiServerMCPClient; that package still exists, but LangChain's docs now point to langchain.mcp. In TypeScript, the examples need @langchain/mcp-adapters 2.0 or later.

The examples use an Anthropic model, as LangChain's MCP docs do, so they read ANTHROPIC_API_KEY; any chat model that supports tools works. Get a MillionShort key in the dashboard; an agent can ask for a trial key by itself.

2Connect the server

In Python, the key goes on a FastMCP Client as auth, which sends it as a bearer token; in TypeScript, it goes in the server's headers. Without a key, leave auth or the headers out.

Choose one
Python
import asyncio
import os

from fastmcp.client import Client
from langchain.mcp import MCPAdapter


async def main():
    client = Client("https://mcp.millionshort.com/mcp", auth=os.environ["MILLIONSHORT_API_KEY"])
    async with MCPAdapter(client) as adapter:
        tools = await adapter.list_tools()
        print([tool.name for tool in tools])  # search, get_domain_info, list_sources, ...


asyncio.run(main())

The TypeScript adapter puts the server's name in front of each tool's name.

3Give the tools to an agent

Pass the tools to create_agent with a system prompt that says when to search. LangChain agents have no web search of their own, so there is nothing to turn off.

Choose one
Python
import asyncio
import os

from fastmcp.client import Client
from langchain.agents import create_agent
from langchain.mcp import MCPAdapter


async def main():
    async with MCPAdapter(Client("https://mcp.millionshort.com/mcp", auth=os.environ["MILLIONSHORT_API_KEY"])) as adapter:
        tools = await adapter.list_tools()
        agent = create_agent(
            "claude-sonnet-5",
            tools,
            system_prompt="Use the MillionShort search tool for anything recent or niche, and cite the URLs.",
        )
        question = "Find independent blogs about home espresso, without the 1,000 most popular sites."
        result = await agent.ainvoke({"messages": [{"role": "user", "content": question}]}, {"recursion_limit": 10})
        print(result["messages"][-1].content)


asyncio.run(main())

The recursion limit caps the agent's steps. 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

Step 2 lists the tools with no model involved: you should see every tool of the server (fewer without a key). After a run of step 3, result["messages"] (result.messages) holds the model's tool calls; one of them should be to search, and the answer should cite pages.

Without MCP: a function tool

A function with LangChain's tool decorator (or tool() in TypeScript) calls POST /v1/search.

Choose one
Python
import json
import os
import urllib.request

from langchain.agents import create_agent
from langchain.tools import tool


@tool
def millionshort_search(query: str, remove_top_sites: int = 1000, num_results: int = 5) -> str:
    """Search the web with MillionShort. remove_top_sites leaves out the N most popular sites."""
    request = urllib.request.Request(
        "https://api.millionshort.com/v1/search",
        data=json.dumps({"query": query, "remove_top_sites": remove_top_sites, "num_results": num_results}).encode(),
        headers={"Authorization": "Bearer " + os.environ["MILLIONSHORT_API_KEY"], "Content-Type": "application/json"},
    )
    with urllib.request.urlopen(request, timeout=30) as response:
        results = json.load(response)["data"]["results"]
    return json.dumps([{"title": r["title"], "url": r["url"], "snippet": r.get("snippet")} for r in results])


agent = create_agent("claude-sonnet-5", [millionshort_search])
result = agent.invoke({"messages": [{"role": "user", "content": "Find independent blogs about home espresso."}]})
print(result["messages"][-1].content)

MCP configuration

The same address for every client: https://mcp.millionshort.com/mcp, streamable HTTP. Both adapters pick streamable HTTP for an https address, so there is no transport to set.

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 auth or 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.

The recursion limit of a run (recursion_limit, recursionLimit) is the step 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
Python cannot import langchain.mcpLangChain is older than 1.4, or was installed without the mcp extrapip install -U "langchain[mcp]"
MCPAdapter is not exported in TypeScript@langchain/mcp-adapters 1.x is installedInstall @langchain/mcp-adapters@^2.0.0
The run stops with a recursion limit messageThe agent reached its step limitRaise the limit, or ask for fewer results per search

Coming soon: the packages

Coming soon. MillionShort's own LangChain packages are built and tested, and are not on a package registry yet. Their names are placeholders until they are published, and may change. Until then, use the MCP adapter in steps 1 to 4, or the function tool above.

The packages are three LangChain tools that call the public API, with the same fields and limits as the API, returning a reduced result made for a model to read.

Tool nameWhat it doesEndpoint
millionshort_searchSearch one or more sourcesPOST /v1/search
millionshort_get_domain_infoPopularity and risk for up to 25 sitesPOST /v1/domain
millionshort_list_sourcesThe sources, page types and topics search acceptsGET /v1/sources

Python: langchain-millionshort

Package (placeholder name): langchain-millionshort. Python 3.10 or later.

Give all three tools to an agent:

Python
from langgraph.prebuilt import create_react_agent

from langchain_millionshort import millionshort_tools


def build_agent(model):
    """`model` is any LangChain chat model that supports tools."""
    return create_react_agent(model, millionshort_tools())

Or call one tool directly, which is also the quickest way to see what a model will be given:

Python
import json

from langchain_millionshort import MillionShortSearch

search = MillionShortSearch()  # reads MILLIONSHORT_API_KEY
answer = json.loads(
    search.invoke({"query": "restoring a cast iron skillet", "remove_top_sites": 1000, "num_results": 3})
)
for hit in answer["results"]:
    print(hit["position"], hit["title"], hit["url"])
NameWhat it is
millionshort_tools(client=None)All three tools, as a list
MillionShortSearch, MillionShortDomainInfo, MillionShortSourcesThe tools, one class each
MillionShortClient(api_key=..., base_url=..., timeout=...)Sets the key, the address and the timeout. Pass it as client
MillionShortErrorRaised by a failed call, with code, status, request_id and retry_after_seconds

Each tool works with invoke and ainvoke, and returns JSON text.

TypeScript: @millionshort/langchain

Package (placeholder name): @millionshort/langchain. It needs @langchain/core.

TypeScript
import type { BaseChatModel } from '@langchain/core/language_models/chat_models';

import { millionshortTools } from '@millionshort/langchain';

/** `llm` is any LangChain chat model that supports tools. */
export function withSearch(llm: BaseChatModel) {
  if (!llm.bindTools) throw new Error('this model does not take tools');
  return llm.bindTools(millionshortTools());
}

The same array goes to an agent constructor as its tools.

One tool, called directly:

TypeScript
import { millionshortSearch } from '@millionshort/langchain';

const search = millionshortSearch(); // reads MILLIONSHORT_API_KEY
const answer = JSON.parse(
  await search.invoke({ query: 'restoring a cast iron skillet', remove_top_sites: 1000, num_results: 3 }),
);
for (const hit of answer.results) {
  console.log(hit.position, hit.title, hit.url);
}
ExportWhat it is
millionshortTools(options?)All three tools, as an array
millionshortSearch(options?), millionshortDomainInfo(options?), millionshortSources(options?)One tool each
MillionShortErrorThrown by a failed call, with code, status, requestId and retryAfterSeconds

Options: apiKey, baseUrl, timeoutMs and fetch.

Settings and fields

Both packages read MILLIONSHORT_API_KEY (the api_key argument or apiKey option overrides it) and MILLIONSHORT_BASE_URL, the API address, by default https://api.millionshort.com. The search tool takes the fields of POST /v1/search under the same names. A search answer is reduced to what a model needs: for each result its position, title, URL, site, source, date, snippet, popularity band and risk level, then the counts of removed results, any warnings, the credits charged and the request id.

This page as Markdown ยท llms.txt