Adding Free Web Search to a Mastra AI Agent Without an API Key
Mastra, a TypeScript framework for AI agents, has no built-in web search tool, so agents struggle with questions about current information. This guide shows how to add search in about 20 lines using Mastra's MCPClient and the AgentSearch MCP server. Basic search requires no API key, signup, or wallet, and reading full pages returns clean markdown with a small free daily trial followed by pay-per-call pricing. The walkthrough covers setting up the project, connecting the MCP client, listing available tools, and restricting which tools the model can see. The setup was tested with specific versions of Mastra, the MCP package, and the AgentSearch server on Node 24, though the model call itself was left for the reader to run with their own API key.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)
Log in to join the discussion and vote.
Log in