Skip to main content
The MCP Service provides endpoints for discovering available MCP servers, managing OAuth connections, and handling MCP instances. It integrates with Composio for OAuth flows and manages the complete lifecycle of MCP server connections.

MCP System Overview

Authentication

All endpoints require a valid Bearer token in the Authorization header and appropriate RBAC permissions. Required Permissions:
  • mcp:read - Read MCP servers and instances
  • mcp:write - Connect accounts and manage instances

Base URL

MCP Server Discovery

List All MCP Servers

Retrieve all available MCP servers in the platform.
Endpoint: GET /api/mcp/list_servers Response Fields:

Get Server with Tools

Retrieve detailed information about an MCP server including all available tools.
Endpoint: GET /api/mcp/server_with_tools Query Parameters:

Connection Management

Connect Account (Start OAuth)

Initiate OAuth flow to connect an MCP server to the user’s account.
Endpoint: POST /api/mcp/connect_account Request Body: Response Fields: Flow:
  1. Call this endpoint with server_id
  2. Redirect user to redirect_url
  3. User completes OAuth on external service
  4. External service redirects back to callback
  5. System automatically creates MCP instance
  6. User redirected to frontend with success

OAuth Callback Handler

Internal endpoint that handles OAuth callbacks from external services. Endpoint: GET /api/mcp/callback Query Parameters: Behavior:
  1. Validates OAuth callback
  2. Updates session status to “active”
  3. Auto-creates MCP instance via Composio
  4. Redirects to frontend with parameters
Frontend Redirect Format:
The callback endpoint is configured in the OAuth application settings and is automatically invoked by the external service after user authorization. Clients should not call this endpoint directly.

Generate MCP URL

Generate the MCP connection URL for an active session.
Endpoint: POST /api/mcp/generate_url Request Body: Response: Usage: The generated URL is used internally by the MCP Playground to establish connections with MCP servers.

Instance Management

List User Instances

Retrieve all MCP instances (connections) for the authenticated user’s organization.
Endpoint: GET /api/mcp/list_instances Query Parameters: Response: Array of MCP instance objects with fields:

Update Instance

Update the custom name of an MCP instance.
Endpoint: PUT /api/mcp/instance Query Parameters: Request Body:

Delete Instance

Delete an MCP instance and disconnect from the external service.
Endpoint: DELETE /api/mcp/instance Query Parameters: Behavior:
  • Deletes MCP instance from Composio (if active)
  • Removes session record from database
  • Revokes OAuth access tokens
  • Cannot be undone

Error Responses

Error Response Format:
Common Error Messages:

Implementation Notes

OAuth Flow

Complete OAuth flow implementation:

Session Management

Best practices for managing MCP sessions:

Feature Flags

MCP functionality is controlled by feature flags:
  • mcp_sessions: Quota for number of MCP connections
  • Checked on POST /connect_account
  • Returns 402 Payment Required if quota exceeded

Composio Integration

The service integrates with Composio for:
  1. OAuth Management:
    • Creating connected accounts
    • Generating redirect URLs
    • Handling callbacks
  2. Instance Management:
    • Creating MCP instances
    • Generating MCP URLs
    • Deleting instances
  3. Authentication:
    • Token management
    • Automatic token refresh
    • Secure credential storage

Rate Limiting

Rate limits may apply based on:
  • Feature flag quotas (mcp_sessions)
  • Composio API limits
  • External service OAuth limits

Security Considerations

OAuth Security

  • OAuth tokens never exposed to client
  • Tokens stored securely in Composio
  • Automatic token refresh
  • Callback URL validation

Access Control

  • All endpoints require authentication
  • RBAC permissions enforced
  • Org-scoped operations
  • User isolation

Data Privacy

  • No MCP data stored permanently
  • OAuth scopes request minimal permissions
  • Users can revoke access anytime
  • Audit trail for connections

Next Steps

Explore MCP integration further: Ready to build with MCP? Check out the MCP Playground API to start using connected tools!