> ## Documentation Index
> Fetch the complete documentation index at: https://docs.devic.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Connect an MCP server

> Either `templateId` (the url comes from the developer’s configuration and any url in the body is ignored) or `url` for a server of your own. Returns `status: "active"` when the server needed no authorization, or `authorizationUrl` to open in a popup. If the server requires a pre-registered OAuth client, `requiresClientCredentials` comes back with the `callbackUrl` to authorize on it — send them in `auth.upstreamOAuth` and try again.



## OpenAPI

````yaml POST /v1/tenant-mcp
openapi: 3.0.0
info:
  title: Devic.ai Public API
  description: >-
    Devic.ai is an AI platform that allows you to create, manage, and use AI
    agents for various tasks.
  version: 1.0.0
  contact:
    name: Devic.ai Support
    url: https://devic.ai
  x-logo:
    url: https://devic.ai/logo.png
    altText: Devic.ai Logo
  x-summary: Public API for interacting with Devic.ai platform
servers:
  - url: https://api.devic.ai
    description: Production server
  - url: https://staging-api.devic.ai
    description: Staging server
security:
  - bearerAuth: []
tags:
  - name: Environments
    description: >-
      The machine an agent works on and everything it may reach: sandbox,
      snapshot, knowledge, tools and encrypted variables
  - name: Sandboxes
    description: >-
      Start a real Linux machine on an environment, run commands and files on
      it, and save its snapshot
  - name: Projects
    description: Group agents, assistants, documents and costs into projects
  - name: Documents
    description: >-
      Knowledge base documents: create, version, attach and index markdown
      content for RAG
  - name: Document Folders
    description: Organise knowledge base documents into folders and attach them in bulk
  - name: Files
    description: Upload files and obtain shareable download URLs to attach to messages
  - name: Agents
    description: Endpoints related to AI agents and their operations
  - name: Assistants
    description: Endpoints for interacting with assistants and their specializations
  - name: Tool Servers
    description: Endpoints for managing tool servers and their tool definitions
  - name: Health
    description: API health check endpoints
  - name: Documentation
    description: Endpoints for retrieving markdown documentation
  - name: Integrations
    description: Connect third-party apps and turn them into tools
  - name: Triggers
    description: Start an agent or an assistant from an app event
  - name: Tenant Integrations
    description: Apps that each end user connects for themselves
  - name: Memory
    description: What an assistant remembers between conversations
  - name: Skills
    description: Reusable instruction packs for agents and assistants
  - name: Speech to Text
    description: Audio transcription
  - name: Tenants
    description: Tenants, subtenants and their usage
  - name: MCP Gateway
    description: One MCP endpoint over many servers, with visibility per user
  - name: Tenant Sessions
    description: Tokens that prove which end user is calling
paths:
  /v1/tenant-mcp:
    post:
      tags:
        - Tenant MCP servers
      summary: Connect an MCP server
      description: >-
        Either `templateId` (the url comes from the developer’s configuration
        and any url in the body is ignored) or `url` for a server of your own.
        Returns `status: "active"` when the server needed no authorization, or
        `authorizationUrl` to open in a popup. If the server requires a
        pre-registered OAuth client, `requiresClientCredentials` comes back with
        the `callbackUrl` to authorize on it — send them in `auth.upstreamOAuth`
        and try again.
      operationId: connect
      parameters:
        - name: assistantId
          required: true
          in: query
          schema:
            type: string
        - name: origin
          required: true
          in: header
          schema:
            type: string
        - name: agentId
          required: true
          in: query
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ConnectTenantMcpDto'
      responses:
        '201':
          description: Registered
        '400':
          description: The url was rejected
        '401':
          description: Unauthorized — missing or invalid API key
        '403':
          description: Forbidden — not reachable with this credential
        '404':
          description: Not found
        '409':
          description: The limit of servers was reached
      security:
        - bearerAuth: []
components:
  schemas:
    ConnectTenantMcpDto:
      type: object
      properties:
        templateId:
          type: string
          description: >-
            Id of an MCP server the developer offers pre-filled. Its url is
            used; any url in this body is ignored.
        url:
          type: string
          description: >-
            https url of a server the end user brings. Only when the assistant
            allows custom servers, and only without templateId.
        name:
          type: string
          description: Display name. Defaults to the template’s.
        auth:
          $ref: '#/components/schemas/TenantMcpAuthDto'
        returnTo:
          type: string
          description: >-
            Absolute URL of the page starting the flow. Must match this
            request’s Origin or one of the assistant’s allowed widget sources.
            The popup is returned there once the authorization completes.
        tenantId:
          type: string
          description: Tenant, when not using a signed session.
        subtenantId:
          type: string
          description: >-
            End user inside the tenant. Omit to connect a server the whole
            tenant shares.
    TenantMcpAuthDto:
      type: object
      properties:
        mode:
          type: string
          enum:
            - oauth
            - header
            - none
        headerName:
          type: string
          description: >-
            Header the credential travels in. Defaults to the template’s, then
            Authorization.
        headerValue:
          type: string
          description: API key or token. Stored encrypted.
        upstreamOAuth:
          $ref: '#/components/schemas/TenantMcpUpstreamOAuthDto'
    TenantMcpUpstreamOAuthDto:
      type: object
      properties:
        clientId:
          type: string
          description: client_id registered with the MCP server
        clientSecret:
          type: string
          description: client_secret, stored encrypted
        scopes:
          type: array
          items:
            type: string
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: Use JWT token for authentication

````