Skip to Content
Welcome to the new DocsGPT docs!
GuidesπŸ”— IntegrationsπŸ”— MCP Tools

MCP Tool Integration

The Model Context Protocol (MCP)Β  integration lets you connect external tool servers to DocsGPT. Your agents can then discover and call tools provided by those servers during conversations β€” for example, querying a CRM, running code, or accessing a database.

Setup

Step 1: Configure Environment Variables (Optional)

Only needed if your MCP servers use OAuth authentication:

MCP_OAUTH_REDIRECT_URI=https://yourdomain.com/api/mcp_server/callback

If not set, falls back to API_URL/api/mcp_server/callback.

Step 2: Add an MCP Server

Go to Settings > Tools > Add Tool > MCP Server. Enter the server URL, select an auth type, and click Test Connection to verify, then Save.

Step 3: Enable for Your Agent

In your agent configuration, enable the MCP tools you want the agent to use.

Authentication Types

Auth TypeConfig Fields
Noneβ€”
Bearerbearer_token
API Keyapi_key, api_key_header (default: X-API-Key)
Basicusername, password
OAuthoauth_scopes (optional)

For OAuth in production, MCP_OAUTH_REDIRECT_URI must be a publicly accessible URL pointing to your DocsGPT backend.

API Endpoints

EndpointMethodDescription
/api/mcp_server/testPOSTTest a connection without saving
/api/mcp_server/savePOSTSave or update a server configuration
/api/mcp_server/callbackGETOAuth callback handler
/api/mcp_server/oauth_status/<task_id>GETPoll OAuth flow status
/api/mcp_server/auth_statusGETBatch check auth status for all MCP tools

Troubleshooting

  • Connection refused β€” Verify the URL and that the server is reachable from your backend.
  • 403 Forbidden β€” Check credentials and permissions.
  • Timed out β€” Default is 30s; increase timeout in tool config (max 300s).
  • OAuth β€œneeds_auth” persists β€” Verify MCP_OAUTH_REDIRECT_URI is correct and Redis is running.