返回文档

MCP Integration

2026-04-14

MCP Integration

Doforu supports the Model Context Protocol (MCP), allowing you to plug external tools and services into your local AI coding assistant seamlessly. Through MCP, the Agent can invoke external capabilities such as database queries, web searches, and browser automation.

What Is MCP

MCP is an open protocol that standardizes communication between AI assistants and external tools. Any server that implements MCP can be discovered and used by Doforu, while your sensitive data and credentials stay local.

Configuration File

MCP is configured via mcp.json:

{
  "mcpServers": {
    "time": {
      "transport": "stdio",
      "command": "node",
      "args": ["./mcp-servers/time-server/index.js"]
    },
    "similarweb": {
      "transport": "stdio",
      "command": "node",
      "args": ["mcp-servers/similarweb-server.js"],
      "env": {
        "API_KEY": "your-api-key"
      },
      "disabled": false,
      "timeout": 5000
    }
  }
}

Field Reference

| Field | Type | Description | |-------|------|-------------| | transport | string | Communication type: stdio, http, or sse | | command | string | stdio only, the executable command | | args | string[] | stdio only, command arguments | | env | object | stdio only, environment variables | | cwd | string | stdio optional, working directory | | url | string | http/sse only, server URL | | headers | object | http/sse only, custom request headers | | disabled | boolean | Whether to disable the server (default false) | | timeout | number | Connection and call timeout in ms (default 2000) |

Configuration File Locations

Doforu searches for mcp.json in the following priority (first existing file wins):

  1. CLI flag: --mcp-config /path/to/mcp.json
  2. Environment variable: MCP_CONFIG_PATH=/path/to/mcp.json
  3. User config: ~/.doforu/mcp.json (recommended for desktop app users)
  4. Project config: mcp.json in the current working directory

Tip: Desktop users should place mcp.json in ~/.doforu/mcp.json so it won't be overwritten accidentally by project code.

Multi-Client Compatibility

In addition to its own configuration, Doforu can detect and import settings from other popular MCP clients:

| Client | Config File Path | |--------|------------------| | Cursor (project) | .cursor/mcp.json | | Cursor (global) | ~/.cursor/mcp.json | | Claude Desktop | ~/Library/Application Support/Claude/claude_desktop_config.json (macOS)%APPDATA%\Claude\claude_desktop_config.json (Windows) |

In the Settings page, you can switch the configuration source with one click and import MCP servers from Cursor or Claude Desktop into Doforu.

Environment Variable Interpolation

mcp.json supports the ${ENV_VAR} syntax to reference environment variables:

{
  "mcpServers": {
    "github": {
      "transport": "stdio",
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-github"],
      "env": {
        "GITHUB_PERSONAL_ACCESS_TOKEN": "${GITHUB_TOKEN}"
      }
    }
  }
}

Special variables ${HOME} and ${USERPROFILE} are automatically mapped to the current user's home directory for cross-platform compatibility.

stdio Path Resolution

For stdio servers, Doforu automatically resolves paths inside args:

  • Absolute paths: normalized and used directly
  • Relative paths: resolved against the backend directory (or the BACKEND_DIR environment variable when running inside Electron)
  • If the resolved path does not exist, the original value is passed through unchanged

Disabling and Enabling Servers

You can temporarily disable an MCP server by setting disabled: true without removing its configuration:

{
  "mcpServers": {
    "experimental-server": {
      "transport": "stdio",
      "command": "node",
      "args": ["./experimental.js"],
      "disabled": true
    }
  }
}

Disabled servers are skipped during startup and consume no resources.

Reloading MCP Configuration

After modifying mcp.json, you can apply the changes via:

  • Settings page: Settings → MCP → saving the config triggers an automatic reload
  • API endpoint: POST /api/mcp/reload

During reload, Doforu will:

  1. Close existing MCP connections
  2. Read the latest configuration
  3. Reconnect all enabled servers
  4. Fetch the available tool list and register it with the Agent

Troubleshooting

If an MCP server fails to connect, check the logs for the specific cause:

  • ENOENT / not found: the command or script path does not exist
  • timeout / ETIMEDOUT: connection timed out; try increasing the timeout value
  • Other errors: look for connect_failed events from the MCP module in Doforu logs

A server that fails to connect is skipped and does not affect other servers or the Agent's normal operation.