MCP Integration

The Model Context Protocol (MCP) is an open standard for giving AI models access to external tools and data sources. Opta supports connecting to multiple MCP servers, making their tools available to the AI during sessions.

What is MCP?

MCP defines a standard interface between an AI host (the daemon) and tool providers (MCP servers). Each MCP server exposes a set of tools with typed inputs and outputs. The daemon connects to these servers, discovers their tools, and routes tool calls from the model to the appropriate server.

This means you can extend the AI's capabilities without modifying the daemon or the model. Want the AI to query a database? Write an MCP server that wraps your database. Want it to manage Kubernetes? Write an MCP server that wraps kubectl.

Open standard
MCP is an open protocol. Opta is compatible with any MCP server that implements the standard, including servers built for other AI platforms. See the MCP specification for protocol details.

Listing Servers

View all configured MCP servers and their status:

opta mcp list
MCP Servers:
  playwright    @playwright/mcp    connected    32 tools
  github        github-mcp         connected    18 tools
  filesystem    fs-mcp             stopped      --

The output shows the server name, package, connection status, and the number of available tools. Servers that are stopped need to be started before their tools are available.

Adding Servers

Add a new MCP server to the daemon's configuration:

Add a custom MCP server
opta mcp add my-server --command "npx my-mcp-server"

The --command flag specifies how to start the server. The daemon will launch this command as a subprocess and communicate with it over the MCP protocol.

MCP server configuration is stored in .mcp.json in the project root. Each server entry includes the command, arguments, environment variables, and optional authentication settings.

.mcp.json (example)
{
  "mcpServers": {
    "my-server": {
      "command": "npx",
      "args": ["my-mcp-server"],
      "env": {
        "API_KEY": "${MY_API_KEY}"
      }
    }
  }
}
API keys in .mcp.json
Use environment variable placeholders (e.g., ${MY_API_KEY}) instead of raw API keys in .mcp.json. Set the actual values in your shell environment or a .env file that is gitignored.

Testing Servers

Verify that an MCP server is working correctly:

opta mcp test my-server
Testing my-server...
  Connection:  OK
  Tools:       12 discovered
  Ping:        3ms
  Status:      Ready

The test command connects to the server, discovers its tools, and verifies that it responds to ping requests. This is useful for debugging connection issues or verifying that a server is properly configured.

Removing Servers

Remove an MCP server from the configuration:

Remove an MCP server
opta mcp remove my-server

This removes the server entry from .mcp.json and disconnects from the server if it is currently running.

Built-In MCP Tools

The daemon includes built-in tools that are always available without configuring an MCP server:

  • read_file -- read file contents
  • write_file -- create or overwrite files
  • search_files -- search for patterns in files
  • list_directory -- list directory contents
  • run_command -- execute shell commands

These built-in tools are subject to the same permission system as MCP tools. They cannot bypass permission checks.

Browser Automation via MCP

The browser automation system is implemented as an MCP server using @playwright/mcp. It provides 30+ tools for browser control, all routed through the BrowserMcpInterceptor for policy evaluation.

See the Browser Automation section for complete documentation on browser tools.