Agent framework
OrcaRouter tools in Mastra
Connect a Mastra agent to the OrcaRouter MCP server with MCPClient, so it can search the tool catalog and run what it finds.
Details
- Kind
- Agent framework
- Connects through
- MCP server
Set it up
- Install the packages:
npm install @mastra/core @mastra/mcp @ai-sdk/openai. - Set
ORCAROUTER_API_KEYto an API key from your OrcaRouter console; Node.js 18 or later runs the MCP server throughnpx. - Register the server with
MCPClientand give its tools (listTools()) to your agent.
Code
import { createOpenAI } from "@ai-sdk/openai";
import { Agent } from "@mastra/core/agent";
import { MCPClient } from "@mastra/mcp";
const mcp = new MCPClient({
servers: {
orcarouter: {
command: "npx",
args: ["-y", "@orcarouter/mcp"],
env: { ORCAROUTER_API_KEY: process.env.ORCAROUTER_API_KEY ?? "" },
},
},
});
const orcarouter = createOpenAI({
baseURL: "https://api.orcarouter.ai/v1",
apiKey: process.env.ORCAROUTER_API_KEY,
});
export const researcher = new Agent({
id: "researcher",
name: "Researcher",
instructions: "Find a tool in the OrcaRouter catalog for each question, then run it.",
model: orcarouter.chat("openai/gpt-5-mini"),
tools: await mcp.listTools(),
});const answer = await researcher.generate("How many followers does @nasa have on TikTok?");
console.log(answer.text);Recipes to try with Mastra
- Track competitor TikTok accountsPull each competitor's TikTok profile, find its latest videos and read what viewers say, in three tool calls an agent can repeat every week.
- Monitor brand mentions on the web and TikTokSearch the web and TikTok for your brand, then read the comments under the posts that mention it: a daily brand check an agent can run on its own.
- Enrich a lead listTurn a list of company domains into firmographics, a contact's work email and a recent news hook, with one API key.
Other integrations
- Vercel AI SDKTurn OrcaRouter tools into AI SDK tools with jsonSchema() and let generateText call them over several steps.
- Claude CodeAdd the OrcaRouter MCP server to Claude Code with one command; Claude can then search the tool catalog and run tools while it works.
- LangChainLoad OrcaRouter tools as LangChain tools from the functions export and give them to any LangChain agent; each call runs the tool through OrcaRouter.
