> ## 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.

# Get MCP server usage by pull request

> 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. Pagination is in write order rather than by merge date, so a pull request written after your cursor already passed its merge date (a backfill) still appears on a later page instead of being silently skipped. Each page request consumes one token when admitted by the request rate limiter. Reviews, review comments, and MCP share the Metrics quota for the configured quota owner. With verified owner scope, coordinate calls across API keys for the same organization, workspace, or Git-provider instance; changing an organization selector does not add quota.



## OpenAPI

````yaml /openapi.json 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. Pagination
        is in write order rather than by merge date, so a pull request written
        after your cursor already passed its merge date (a backfill) still
        appears on a later page instead of being silently skipped. Each page
        request consumes one token when admitted by the request rate limiter.
        Reviews, review comments, and MCP share the Metrics quota for the
        configured quota owner. With verified owner scope, coordinate calls
        across API keys for the same organization, workspace, or Git-provider
        instance; changing an organization selector does not add quota.
      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: >-
            Request rate limit exceeded (RATE_LIMIT_EXCEEDED), active metrics
            query capacity reached (METRICS_BUSY), or an identical authorized
            query is still running (METRICS_QUERY_IN_PROGRESS). Wait at least
            the full Retry-After interval after receiving the response, then
            retry the same cursor and query parameters. Do not advance the
            cursor on an error. Other calls sharing the quota can cause another
            rejection after the wait. X-RateLimit headers are present only for
            RATE_LIMIT_EXCEEDED, not for the other 429 errors.
          headers:
            Retry-After:
              schema:
                type: integer
              description: >-
                Seconds to wait before retrying; dynamic for request rate
                limits, 5 for METRICS_BUSY or METRICS_QUERY_IN_PROGRESS
            X-RateLimit-Limit:
              required: false
              schema:
                type: integer
              description: >-
                Token bucket burst capacity, not the number of requests allowed
                per minute
            X-RateLimit-Remaining:
              required: false
              schema:
                type: integer
              description: Whole tokens remaining; 0 on request rate rejection
            X-RateLimit-Reset:
              required: false
              schema:
                type: integer
              description: >-
                Estimated Unix timestamp in seconds when the bucket will be full
                if no more tokens are consumed, or when a temporary local rate
                block ends. Use Retry-After to schedule the next retry.
          content:
            application/json:
              schema:
                type: object
                properties:
                  errors:
                    type: array
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                        code:
                          type: string
                          enum:
                            - RATE_LIMIT_EXCEEDED
                            - METRICS_BUSY
                            - METRICS_QUERY_IN_PROGRESS
        '500':
          description: Internal server error
        '503':
          description: >-
            Metrics are preparing (METRICS_PREPARING), active-query admission
            cannot safely proceed (METRICS_UNAVAILABLE), or API quota custody
            cannot be proved (POLICY_SCOPE_UNAVAILABLE). Retry the same request
            after Retry-After when present; otherwise retry later.
          headers:
            Retry-After:
              required: false
              schema:
                type: integer
              description: >-
                Seconds to wait for METRICS_PREPARING, or 5 for
                METRICS_UNAVAILABLE; absent for POLICY_SCOPE_UNAVAILABLE
          content:
            application/json:
              schema:
                type: object
                properties:
                  errors:
                    type: array
                    items:
                      type: object
                      properties:
                        code:
                          type: string
                          enum:
                            - METRICS_PREPARING
                            - METRICS_UNAVAILABLE
                            - POLICY_SCOPE_UNAVAILABLE
                        message:
                          type: string
      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.

````

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