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

# Connect an MCP server

> Connects an MCP server so GraphAI and workflows can call its tools. With auth_type none or bearer, CostGraph lists the server's tools before saving and returns the connection; the token is sent as Authorization: Bearer, or in header_name when set. When the server asks for sign-in instead, the response has sign_in_required and nothing is saved. With auth_type oauth the response has an authorize_url to open; CostGraph registers itself with the server when it allows that, otherwise client_id (and client_secret for a confidential client) are required. Tools the server marks read-only start read-only; every other tool needs approval in workflows. Tokens are never returned.



## OpenAPI

````yaml /api-reference/costgraph/openapi.json post /api/v1/integrations/mcp-server/connect
openapi: 3.0.0
info:
  description: Read and manage your CostGraph organization, spend, alerts, and settings.
  title: CostGraph API
  contact: {}
  version: '1.0'
servers:
  - url: https://api.costgraph.ai
security: []
tags:
  - name: ai
    x-group: AI
  - name: ai-serving
    x-group: AI serving
  - name: anomalies
    x-group: Anomalies
  - name: auth
    x-group: Auth
  - name: billing
    x-group: Billing
  - name: billing-export
    x-group: Billing export
  - name: budgets
    x-group: Budgets
  - name: ci
    x-group: CI
  - name: compute-recommendations
    x-group: Compute recommendations
  - name: config
    x-group: Config
  - name: context-graph
    x-group: Context graph
  - name: cost
    x-group: Cost
  - name: gpus
    x-group: GPUs
  - name: graphai
    x-group: Graph AI
  - name: integrations
    x-group: Integrations
  - name: invitations
    x-group: Invitations
  - name: kubernetes-clusters
    x-group: Kubernetes clusters
  - name: marketplace
    x-group: Marketplace
  - name: network-requests
    x-group: Network requests
  - name: notifications
    x-group: Notifications
  - name: oauth
    x-group: OAuth
  - name: oauth-clients
    x-group: OAuth clients
  - name: opencost
    x-group: OpenCost
  - name: organization
    x-group: Audit log
  - name: organizations
    x-group: Organizations
  - name: placement-alternatives
    x-group: Placement alternatives
  - name: reports
    x-group: Reports
  - name: service-map
    x-group: Service map
  - name: settings
    x-group: Settings
  - name: sso
    x-group: Single sign-on
  - name: tenants
    x-group: Tenants
  - name: ticketing
    x-group: Ticketing
  - name: user
    x-group: Users
  - name: virtual-machines
    x-group: Virtual machines
  - name: virtual-tags
    x-group: Virtual tags
  - name: workflows
    x-group: Workflows
paths:
  /api/v1/integrations/mcp-server/connect:
    post:
      tags:
        - integrations
      summary: Connect an MCP server
      description: >-
        Connects an MCP server so GraphAI and workflows can call its tools. With
        auth_type none or bearer, CostGraph lists the server's tools before
        saving and returns the connection; the token is sent as Authorization:
        Bearer, or in header_name when set. When the server asks for sign-in
        instead, the response has sign_in_required and nothing is saved. With
        auth_type oauth the response has an authorize_url to open; CostGraph
        registers itself with the server when it allows that, otherwise
        client_id (and client_secret for a confidential client) are required.
        Tools the server marks read-only start read-only; every other tool needs
        approval in workflows. Tokens are never returned.
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/integrations.mcpServerConnectRequest'
        description: MCP server
        required: true
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/responses.SuccessResponse'
                  - type: object
                    properties:
                      data:
                        $ref: '#/components/schemas/integrations.mcpConnectResponse'
        '201':
          description: Created
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/responses.SuccessResponse'
                  - type: object
                    properties:
                      data:
                        $ref: '#/components/schemas/integrations.mcpConnectResponse'
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/responses.ErrorResponse'
        '403':
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/responses.ErrorResponse'
        '422':
          description: Unprocessable Entity
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/responses.ErrorResponse'
        '503':
          description: Service Unavailable
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/responses.ErrorResponse'
      security:
        - BearerAuth: []
components:
  schemas:
    integrations.mcpServerConnectRequest:
      type: object
      required:
        - auth_type
        - name
        - tenant_id
        - url
      properties:
        auth_type:
          type: string
          enum:
            - none
            - bearer
            - oauth
        client_id:
          type: string
        client_secret:
          type: string
        header_name:
          type: string
        name:
          type: string
        tenant_id:
          type: string
        token:
          type: string
        url:
          type: string
    responses.SuccessResponse:
      type: object
      required:
        - message
        - status
      properties:
        data: {}
        message:
          type: string
          example: some message
        status:
          type: string
          example: success
    integrations.mcpConnectResponse:
      type: object
      properties:
        authorize_url:
          type: string
        server:
          $ref: '#/components/schemas/integrations.mcpServerResponse'
        sign_in_required:
          type: boolean
    responses.ErrorResponse:
      type: object
      required:
        - message
        - status
      properties:
        message:
          type: string
          example: some message
        status:
          type: string
          example: error
    integrations.mcpServerResponse:
      type: object
      properties:
        auth_type:
          type: string
          enum:
            - none
            - bearer
            - oauth
        connection_id:
          type: string
        created_at:
          type: string
        header_name:
          type: string
        id:
          type: string
        last_error:
          type: string
        name:
          type: string
        slug:
          type: string
        status:
          type: string
        tools:
          type: array
          items:
            $ref: '#/components/schemas/integrations.mcpServerToolResponse'
        updated_at:
          type: string
        url:
          type: string
        workflows_enabled:
          type: boolean
    integrations.mcpServerToolResponse:
      type: object
      properties:
        description:
          type: string
        enabled:
          type: boolean
        name:
          type: string
        read_only:
          type: boolean
        read_only_hint:
          type: boolean
  securitySchemes:
    BearerAuth:
      description: Enter "Bearer {token}"
      type: apiKey
      name: Authorization
      in: header

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.