> ## Documentation index
> Fetch the complete documentation index at: https://upstash-context7-git-ctx7-4291-onprem-key-rotation-ecs-d-dae4a0.docs7.io/llms.txt
> Ask it with GET https://upstash-context7-git-ctx7-4291-onprem-key-rotation-ecs-d-dae4a0.docs7.io/ask?q=<keywords or question>. Short keywords rank best.
> Use these to discover all available pages before exploring further.
> Feature requests: https://upstash-context7-git-ctx7-4291-onprem-key-rotation-ecs-d-dae4a0.docs7.io/resources/feature-requests.md lists what users asked for and how to vote for a request or add one.
> Page rating: `GET https://upstash-context7-git-ctx7-4291-onprem-key-rotation-ecs-d-dae4a0.docs7.io/feedback?path=/enterprise/api/context/get-documentation-context&helpful={true|false}&comment={comment}` records whether this page helped. The `comment` (URL-encoded, at most 500 characters) says what helped, or what was missing or wrong; a `helpful=false` rating needs it. It is anonymous and needs no key. Comments hold no code, secrets or personal data.

# Get documentation context

> Retrieve documentation snippets for a library ranked by relevance to your query

`GET /v2/context`

## OpenAPI

````yaml openapi-enterprise.json get /v2/context
openapi: 3.0.0
info:
  title: Context7 On-Premise API
  description: REST API for the Context7 On-Premise server. Covers library parsing
    and documentation search.
  version: 1.0.0
servers:
  - url: https://your-instance.example.com/api
    description: Your on-premise deployment (replace with your actual host)
  - url: http://localhost:3000/api
    description: Local development
tags:
  - name: Search
    description: Search indexed libraries
  - name: Context
    description: Retrieve documentation context for queries
  - name: Parse
    description: Parse and index new libraries
paths:
  /v2/context:
    get:
      summary: Get documentation context
      description: >-
        Retrieve documentation snippets for a library ranked by relevance to
        your query, formatted as plain text ready to inject into an LLM prompt.
        This is the endpoint MCP tools call internally.


        Each snippet that has a source URL has a `Source:` line with that link.
        When an admin has assigned [authority
        labels](/enterprise/authority-labels), a labeled snippet also has an
        `Authority:` line, and the response starts with a legend that defines
        each class that appears. Excluded content never appears.
      operationId: getContext
      tags:
        - Context
      parameters:
        - name: libraryId
          in: query
          description: Library ID returned by `GET /v2/libs/search` (e.g.,
            `/your-org/your-repo`)
          required: true
          schema:
            type: string
            minLength: 1
            maxLength: 500
          example: /vercel/next.js
        - name: query
          in: query
          description: Natural language question or topic to retrieve context for
          required: true
          schema:
            type: string
            minLength: 1
            maxLength: 500
          example: How do I use the app router?
      responses:
        "200":
          description: Relevant documentation snippets as plain text. When the library is
            not found, the response is still `200` with a plain-text message
            that starts with `Library not found`
          content:
            text/plain:
              schema:
                type: string
              example: >-
                Authority classes in these results:

                - standard: An approved standard or requirement. Follow it
                unless a newer standard replaces it.


                --------------------------------


                ### useRouter()


                Authority: standard

                Source: https://github.com/vercel/next.js/...


                The `useRouter` hook allows you to programmatically change
                routes inside Client Components.


                --------------------------------


                ### app/layout.tsx


                ```tsx

                export default function Layout({ children }) {
                  return <html><body>{children}</body></html>
                }

                ```
        "400":
          description: Bad Request - `libraryId` or `query` is missing
          content:
            text/plain:
              schema:
                type: string
              example: query and libraryId are required
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "500":
          description: Internal Server Error
          content:
            text/plain:
              schema:
                type: string
              example: Context query failed
      security:
        - {}
        - bearerAuth: []
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: API key generated from Personal Settings. See
        [Authentication](/enterprise/api/authentication#creating-an-api-key).
  schemas:
    Error:
      type: object
      properties:
        error:
          type: string
          description: Human-readable error description
      required:
        - error
  responses:
    UnauthorizedError:
      description: Unauthorized - authentication required
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/Error"
          example:
            error: Authentication required
````
