Integrations / Frameworks & SDKs
Langroid
MillionShort search for Langroid agents, as MCP tools over streamable HTTP.
Copy as MarkdownOpen in ChatGPT (opens in a new tab)Open in Claude (opens in a new tab)
MCPPythonNothing of ours to installWorks with no keyChecked 2026-11-19
Langroid turns each tool of an MCP server into a ToolMessage class, which you enable on a ChatAgent like any other Langroid tool. It connects through a FastMCP transport; for the MillionShort MCP server that is StreamableHttpTransport, with the key in its headers. The agent gets the server's tools (the MCP page lists them). Without MCP, a ToolMessage of your own that calls the API does the same job.
1Install
pip install langroid
export MILLIONSHORT_API_KEY=ms-YOUR_API_KEYfastmcp comes with langroid. Langroid's default model is an OpenAI model, which reads your key from OPENAI_API_KEY; any model you configure through OpenAIGPTConfig that can call tools works. Get a MillionShort key in the dashboard; an agent can ask for a trial key by itself.
2Connect the server
get_tools_async lists the server's tools and returns one ToolMessage class per tool. Pass it a function that makes a fresh transport, as Langroid recommends, or a transport itself. Without a key, leave headers out.
import os
from fastmcp.client.transports import StreamableHttpTransport
from langroid.agent.tools.mcp import get_tools_async
def millionshort():
return StreamableHttpTransport(
url="https://mcp.millionshort.com/mcp",
headers={"Authorization": f"Bearer {os.environ['MILLIONSHORT_API_KEY']}"},
)
# inside an async function:
# tools = await get_tools_async(millionshort)Langroid's docs show this pattern with SSETransport and say other FastMCP transports work the same way; StreamableHttpTransport is FastMCP's streamable HTTP transport, and we checked the pair against our server with langroid 0.70 and fastmcp 4.2.
3Give the tools to an agent
Enable the tool classes on the agent and run a task. With handle_llm_no_tool=NonToolAction.DONE, the task ends when the model answers without calling a tool:
import asyncio
import os
import langroid as lr
from fastmcp.client.transports import StreamableHttpTransport
from langroid.agent.tools.mcp import get_tools_async
from langroid.mytypes import NonToolAction
def millionshort():
return StreamableHttpTransport(
url="https://mcp.millionshort.com/mcp",
headers={"Authorization": f"Bearer {os.environ['MILLIONSHORT_API_KEY']}"},
)
async def main():
tools = await get_tools_async(millionshort)
agent = lr.ChatAgent(
lr.ChatAgentConfig(
name="Researcher",
system_message="Use the millionshort search tool for anything recent or niche, and cite the URLs.",
handle_llm_no_tool=NonToolAction.DONE,
)
)
agent.enable_message(tools)
task = lr.Task(agent, interactive=False)
result = await task.run_async("Find independent blogs about home espresso, without the 1,000 most popular sites.")
print(result.content if result else "")
asyncio.run(main())With several MCP servers, get_tools_async(millionshort, tool_name_prefix="ms") names the tools ms__search and so on, so they cannot clash. To change what the model sees from one tool, decorate a class with @mcp_tool(millionshort, "search") and override handle_async, as Langroid's MCP page shows.
4Check it works
List the tools without a model:
import asyncio
import os
from fastmcp.client.transports import StreamableHttpTransport
from langroid.agent.tools.mcp import get_tools_async
async def main():
transport = StreamableHttpTransport(
url="https://mcp.millionshort.com/mcp", headers={"Authorization": f"Bearer {os.environ['MILLIONSHORT_API_KEY']}"}
)
tools = await get_tools_async(transport)
print([tool.default_value("request") for tool in tools]) # search, get_domain_info, list_sources, ...
asyncio.run(main())With no key you see search and list_sources. Then run step 3: the answer should cite pages. If the agent answers from memory, say when to search in its system message:
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 tool message
A ToolMessage of your own: request is the tool's name, purpose tells the model when to use it, and handle runs it. This one calls POST /v1/search:
import json
import os
import urllib.request
import langroid as lr
class MillionShortSearch(lr.ToolMessage):
request: str = "millionshort_search"
purpose: str = "Search the web for <query>, leaving out the <remove_top_sites> most popular sites."
query: str
remove_top_sites: int = 1000
def handle(self) -> str:
request = urllib.request.Request(
"https://api.millionshort.com/v1/search",
data=json.dumps({"query": self.query, "remove_top_sites": self.remove_top_sites, "num_results": 5}).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 = lr.ChatAgent(lr.ChatAgentConfig(system_message="Search before you answer, and cite the URLs."))
agent.enable_message(MillionShortSearch)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 headers 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 |
enable_message refuses a tool name that is taken | Another server's tool has the same name, such as search | Pass tool_name_prefix to get_tools_async |
Related
- Agent tool use: when to give a model tools, and what to tell it.
- CAMEL-AI and PraisonAI: the same server in other Python agent frameworks.
- MCP server and Filters for agents.
- Langroid's own documentation, read on 2026-11-19: MCP tools.