Skip to main content

MCP Client

RadarOS includes a built-in MCP client that lets your agents connect to any Model Context Protocol server and use its tools natively — no glue code required.
MCP is an open protocol that standardizes how LLM applications integrate with external tools, resources, and prompts. RadarOS acts as an MCP client, consuming tools from external MCP servers.

Installation

The MCP SDK is an optional peer dependency:
npm install @modelcontextprotocol/sdk

Quick Start

import { Agent, openai, MCPToolProvider } from "@radaros/core";

// Connect to a GitHub MCP server via stdio
const github = new MCPToolProvider({
  name: "github",
  transport: "stdio",
  command: "npx",
  args: ["-y", "@modelcontextprotocol/server-github"],
  env: { GITHUB_TOKEN: process.env.GITHUB_TOKEN },
});

await github.connect();

const agent = new Agent({
  name: "dev-assistant",
  model: openai("gpt-4o"),
  instructions: "You are a developer assistant with GitHub access.",
  tools: [...await github.getTools()],
});

const result = await agent.run("What are the open issues in my repo?");
console.log(result.text);

await github.close();

Transports

stdio

Spawns the MCP server as a child process and communicates via stdin/stdout. Best for local MCP servers.
const tools = new MCPToolProvider({
  name: "filesystem",
  transport: "stdio",
  command: "npx",
  args: ["-y", "@modelcontextprotocol/server-filesystem", "/path/to/dir"],
});
command
string
required
The command to spawn (e.g. "npx", "node", "python").
args
string[]
Arguments for the command.
env
Record<string, string>
Environment variables passed to the spawned process.

HTTP (Streamable HTTP)

Connects to a remote MCP server over HTTP. Falls back to SSE transport if Streamable HTTP is not available.
const tools = new MCPToolProvider({
  name: "database",
  transport: "http",
  url: "http://localhost:8080/mcp",
  headers: { Authorization: "Bearer my-token" },
});
url
string
required
The MCP server URL.
headers
Record<string, string>
Custom HTTP headers (e.g. for authentication).

Mixing MCP and Local Tools

MCP tools are returned as standard ToolDef[] and can be combined with local tools:
import { defineTool } from "@radaros/core";
import { z } from "zod";

const localTool = defineTool({
  name: "current_time",
  description: "Returns the current date and time",
  parameters: z.object({}),
  execute: async () => new Date().toISOString(),
});

const agent = new Agent({
  name: "assistant",
  model: openai("gpt-4o"),
  tools: [
    ...await github.getTools(),    // MCP tools
    ...await dbTools.getTools(),    // Another MCP server
    localTool,                      // Local tool
  ],
});

Multiple MCP Servers

Connect to multiple servers simultaneously. Tool names are namespaced as {serverName}__{toolName} to avoid collisions:
const github = new MCPToolProvider({ name: "github", ... });
const slack = new MCPToolProvider({ name: "slack", ... });

await Promise.all([github.connect(), slack.connect()]);

const agent = new Agent({
  name: "assistant",
  model: openai("gpt-4o"),
  tools: [
    ...await github.getTools(),  // github__create_issue, github__list_repos, ...
    ...await slack.getTools(),   // slack__send_message, slack__list_channels, ...
  ],
});

API Reference

MCPToolProvider

name
string
required
A unique name for this MCP server connection. Used to namespace tool names.
transport
'stdio' | 'http'
required
The transport protocol to use.
MethodDescription
connect()Connect to the MCP server and discover tools.
getTools()Returns ToolDef[] — all discovered tools.
refresh()Re-discover tools from the server.
close()Disconnect from the server and clean up.

ServerInstall
GitHubnpx -y @modelcontextprotocol/server-github
Filesystemnpx -y @modelcontextprotocol/server-filesystem
PostgreSQLnpx -y @modelcontextprotocol/server-postgres
Brave Searchnpx -y @modelcontextprotocol/server-brave-search
Slacknpx -y @modelcontextprotocol/server-slack
Browse all available servers at mcp.so.