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

  1. Install the packages: npm install @mastra/core @mastra/mcp @ai-sdk/openai.
  2. Set ORCAROUTER_API_KEY to an API key from your OrcaRouter console; Node.js 18 or later runs the MCP server through npx.
  3. Register the server with MCPClient and give its tools (listTools()) to your agent.

Code

An agent with the OrcaRouter MCP server
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(),
});
Ask it something
const answer = await researcher.generate("How many followers does @nasa have on TikTok?");
console.log(answer.text);

Recipes to try with Mastra

© 2026 OrcaRouter

For Providers

Run an inference platform? Get your models on OrcaRouter.

providers@orcarouter.ai

Join our community

Discordsupport@orcarouter.aiXLinkedInGitHubYouTube