Skip to main content

Overview

RunTools supports Model Context Protocol (MCP) - an open standard for connecting AI models to data sources and tools.

Adding MCP Tools

Include MCP servers in your agent runtime:
const runtime = await rt.runtimes.create({
  slug: 'mcp-agent',
  tools: [
    // Core tools
    'bash',
    'read_file',
    'edit_file',
    
    // MCP servers
    {
      type: 'mcp',
      command: 'npx @anthropic/mcp-server-filesystem',
      args: ['/workspace'],
    },
    {
      type: 'mcp',
      command: 'npx @anthropic/mcp-server-github',
      env: { GITHUB_TOKEN: '<secret:github_token>' },
    },
  ],
});

MCP Server Types

NPX Servers

Run MCP servers via npx:
{
  type: 'mcp',
  command: 'npx @anthropic/mcp-server-filesystem',
  args: ['/workspace'],
}

Docker Servers

Run MCP servers in Docker:
{
  type: 'mcp',
  docker: 'myorg/mcp-server:latest',
  env: { API_KEY: '<secret:api_key>' },
}

Remote Servers

Connect to remote MCP servers:
{
  type: 'mcp',
  url: 'https://mcp.example.com/v1',
  headers: { Authorization: 'Bearer <secret:mcp_token>' },
}

Available MCP Servers

Official (Anthropic)

ServerDescription
@anthropic/mcp-server-filesystemFile system access
@anthropic/mcp-server-githubGitHub integration
@anthropic/mcp-server-slackSlack integration
@anthropic/mcp-server-postgresPostgreSQL queries

Community

Many community MCP servers are available on npm and GitHub.

Configuration

Environment Variables

Inject secrets into MCP servers:
{
  type: 'mcp',
  command: 'npx @anthropic/mcp-server-github',
  env: {
    GITHUB_TOKEN: '<secret:github_token>',
  },
}

Arguments

Pass arguments to MCP servers:
{
  type: 'mcp',
  command: 'npx @anthropic/mcp-server-filesystem',
  args: ['/workspace', '--readonly'],
}

Tool Discovery

MCP servers expose their tools automatically. The agent discovers available tools at runtime.
// Agent can use any tools exposed by the MCP server
// Example: mcp-server-filesystem exposes:
// - read_file
// - write_file
// - list_directory
// - etc.

Best Practices

Official Anthropic servers are well-maintained and secure.
Use specific versions: @anthropic/[email protected]
Use RunTools secrets for MCP server credentials.
Give MCP servers only the access they need.

Creating MCP Servers

Build your own MCP servers:
// my-mcp-server.ts
import { Server } from '@modelcontextprotocol/server';

const server = new Server({
  name: 'my-server',
  version: '1.0.0',
});

server.addTool({
  name: 'my_tool',
  description: 'Does something useful',
  inputSchema: {
    type: 'object',
    properties: {
      input: { type: 'string' },
    },
  },
  handler: async ({ input }) => {
    return { result: `Processed: ${input}` };
  },
});

server.listen();

MCP Documentation

Learn more about Model Context Protocol