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

# MCP server usage

> Returns one JSON row per merged, reviewed pull request that used MCP, with MCP servers and tools nested under servers. Join to GET /v1/metrics/reviews on pr_url. Counts are best-effort usage telemetry. Access is controlled by an organization-scoped feature flag.

export const EnterprisePlanBadge = ({tip = "This feature is available exclusively as part of the Enterprise plan. Please refer to our pricing page for more information about our plans and features.", title = "Enterprise Plan", cta = "Read more", href = "https://coderabbit.ai/pricing", disabled = false}) => {
  return <Tooltip tip={tip} cta={cta} href={href}>
        <Badge icon="building-2" disabled={disabled || undefined}>
            {title}
        </Badge>
    </Tooltip>;
};

<EnterprisePlanBadge />

Use a non-agentic API key to measure which MCP servers and tools contributed context to merged pull requests. Join results to the [Metrics Data API](/api-reference/metrics-data-api) using `pr_url`; usage counts are best-effort telemetry.

For MCP setup and review behavior, see the [MCP Servers documentation](/knowledge-base/mcp-context).


## OpenAPI

````yaml get /v1/metrics/mcp
openapi: 3.0.3
info:
  title: CodeRabbit API spec
  version: 1.0.0
servers:
  - url: https://api.coderabbit.ai
security:
  - ApiKeyAuth: []
paths:
  /v1/metrics/mcp:
    get:
      tags:
        - Metrics
      summary: Get MCP server usage by pull request
      description: >-
        Returns one JSON row per merged, reviewed pull request that used MCP,
        with MCP servers and tools nested under servers. Join to GET
        /v1/metrics/reviews on pr_url. Counts are best-effort usage telemetry.
        Access is controlled by an organization-scoped feature flag.
      operationId: mcp-metrics
      parameters:
        - in: header
          name: x-coderabbitai-api-key
          required: true
          schema:
            type: string
        - in: query
          name: org_id
          required: false
          schema:
            type: string
          description: >-
            Workspace API keys only; scopes the request to one provider
            organization.
        - in: query
          name: start_date
          required: true
          schema:
            type: string
            format: date
        - in: query
          name: end_date
          required: true
          schema:
            type: string
            format: date
        - in: query
          name: organization_ids
          schema:
            type: string
          description: >-
            Comma-separated provider organization IDs. Self-hosted only; maximum
            10.
        - in: query
          name: repository_ids
          schema:
            type: string
          description: Comma-separated provider repository IDs; maximum 10.
        - in: query
          name: user_ids
          schema:
            type: string
          description: Comma-separated provider PR-author IDs; maximum 10.
        - in: query
          name: limit
          schema:
            type: integer
            minimum: 1
            maximum: 1000
            default: 1000
        - in: query
          name: cursor
          schema:
            type: string
          description: Opaque next_cursor from the previous response.
      responses:
        '200':
          description: MCP server usage for merged pull requests
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                  - next_cursor
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      required:
                        - pr_url
                        - organization_id
                        - repository_id
                        - author_id
                        - merged_at
                        - servers
                      properties:
                        pr_url:
                          type: string
                        organization_id:
                          type: string
                        repository_id:
                          type: string
                        author_id:
                          type: string
                          nullable: true
                        merged_at:
                          type: string
                          format: date-time
                        servers:
                          type: array
                          description: MCP servers used during the review.
                          items:
                            type: object
                            required:
                              - server_name
                              - insight_count
                              - tools
                            properties:
                              server_name:
                                type: string
                                description: >-
                                  Most recently recorded MCP server name for
                                  this PR, or the current connection
                                  name/internal ID for historical rows without a
                                  snapshot.
                              insight_count:
                                type: integer
                                description: >-
                                  Best-effort count of review insights that
                                  cited this server as a source.
                              tools:
                                type: array
                                items:
                                  type: object
                                  required:
                                    - tool_name
                                    - call_count
                                  properties:
                                    tool_name:
                                      type: string
                                      description: >-
                                        Original MCP tool name when recorded;
                                        historical rows may contain the
                                        previously stored agent-facing name.
                                    call_count:
                                      type: integer
                                      description: Recorded calls for this tool.
                  next_cursor:
                    type: string
                    nullable: true
        '400':
          description: >-
            Invalid query parameters, or the response exceeds 16 MB
            (RESPONSE_TOO_LARGE). Add filters or reduce the limit.
        '401':
          description: Unauthorized - invalid or missing API key
        '403':
          description: Forbidden - Enterprise plan required or agentic key not allowed
        '404':
          description: No matching organization exists
        '429':
          description: Rate limit exceeded
        '500':
          description: Internal server error
      security:
        - ApiKeyAuth: []
components:
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: x-coderabbitai-api-key
      description: >-
        API key for authentication. You can create an API key from the
        CodeRabbit dashboard.

````