Model Context Protocol

Multiple Servers

Configure a Daydreams agent to connect to and use tools from multiple Model Context Protocol (MCP) servers simultaneously.

This tutorial shows how to configure an agent to connect to two separate MCP servers: one for web scraping (firecrawl-mcp) and another for 3D rendering (blender-mcp).

Configuration

The agent is configured by passing an array of server configurations to createMcpExtension. Each server has a unique id which is used to direct tool calls to the correct server.

multi-mcp-agent.ts
import { createDreams, Logger, LogLevel } from "@daydreamsai/core";
import { createMcpExtension } from "@daydreamsai/mcp";
import { cliExtension } from "@daydreamsai/cli";
import { dreamsrouter } from "@daydreamsai/ai-sdk-provider";

createDreams({
  model: dreamsrouter("google/gemini-2.5-pro"),
  logger: new Logger({
    level: LogLevel.INFO,
  }),
  extensions: [
    cliExtension,
    createMcpExtension([
      {
        id: "firecrawl-mcp",
        name: "Firecrawl MCP Server",
        transport: {
          type: "stdio",
          command: "npx",
          args: ["-y", "firecrawl-mcp"],
        },
      },
      {
        id: "blender-mcp",
        name: "Blender MCP Server",
        transport: {
          type: "stdio",
          command: "uvx",
          args: ["blender-mcp"],
        },
      },
    ]),
  ],
}).start();

Key Concepts

  • The createMcpExtension function takes an array of server configuration objects.
  • Each server requires a unique id which the agent uses to target tool calls (e.g., firecrawl-mcp).
  • The transport object defines the connection method. For local executables, stdio is used with a command and an args array.