> ## 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/security/library-access&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.

# Library Access Control

> Restrict which libraries each user can query over the MCP and API, based on their SSO groups or individual grants.

By default, every signed-in user can query every library indexed on your instance. Library access control lets you lock specific libraries down so only the right people can reach them. This is useful when you index a repository that only one team has access to in your source control, and you want that boundary to carry over to Context7.

Access is decided per library. A library is either open to everyone or restricted to a set of principals: SSO groups, individual users, or both. Admins always have access to every library.

<Note>
Group-based access relies on the group claim from your identity provider, so it works when your users sign in through SSO. See [OIDC SSO](/enterprise/security/oidc-sso), [SAML SSO](/enterprise/security/saml-sso) or [Microsoft Entra SSO](/enterprise/security/entra-sso) for setup. Microsoft Entra ID does not send a groups claim by default: add one to the application and grant access by group Object ID, as described in [Microsoft Entra SSO](/enterprise/security/entra-sso). For password users, grant access to individual users instead.
</Note>

## Manage access in one place

Open **Workspace Settings › Library access**. The **Library access** card has a table of every indexed library, its current access, and who can reach it. The **Default access** card above it holds the workspace default. Search by name, filter to restricted libraries only, and edit any library from its row.

<Frame>
  <img src="/images/enterprise/library-access/04-access-overview.png" alt="The library access table showing each library's access, the groups and users who can reach it, and inline edit" />
</Frame>

The table tells you three things at a glance:

- **Access**: whether the library is open to **Everyone** or **Restricted**. Libraries you have not configured follow the longest matching namespace rule and show `via <namespace>/*`. Without a matching namespace rule, they follow the workspace default and show **Default**.
- **Granted to**: the groups and users on a restricted library, `All members` when it is open, or `Admins only` when it is restricted but no one has been added yet.
- **Edit** (pencil icon): opens the access editor for that library.

## Restrict a library

You can edit a library from the **Edit** button in the table, or from the **Access** field on the library's settings page. Both use the same controls.

<Steps>
  <Step title="Switch to Restricted">
    Select **Restricted**, then add the SSO groups that should have access and any individual users you want to grant directly. Click **Save changes**.

    <Frame>
      <img src="/images/enterprise/library-access/01-restricted-access.png" alt="The access editor set to Restricted, showing group and user grants" />
    </Frame>

    Anyone in a listed group, plus the users you added, can now query this library. Everyone else stops seeing it.
  </Step>
  <Step title="Reopen it when needed">
    To open a library back up to the whole workspace, set its access to **Everyone**.

    <Frame>
      <img src="/images/enterprise/library-access/02-everyone-access.png" alt="The access editor set to Everyone" />
    </Frame>
  </Step>
</Steps>

## Set the default for new libraries

New repositories and websites are open to everyone unless you change the workspace default. Use the **Restrict libraries by default** toggle in the **Default access** card.

New **Google Drive**, **Notion**, **Confluence** and **Azure DevOps** libraries start restricted to admins, because they can hold private company documents. Grant access to the groups or users who need them from the library's row. A connector library you add later is restricted the same way, unless the workspace default is already **Restricted** or a namespace rule covers it. Re-syncing a connector library never changes access you have set.

Turn the toggle on to flip your instance to deny by default. Members then see only the libraries they have been explicitly granted, and each new library stays private until you grant access to it.

<Frame>
  <img src="/images/enterprise/library-access/03-default-posture.png" alt="The restrict libraries by default toggle" />
</Frame>

## Restrict a namespace

A namespace rule covers every library under a path. Use it to control a whole organization in one step:

1. In the **Library Access** section, switch to **Namespaces**.
2. Choose **Add rule**.
3. Enter a prefix, such as `/acme` or `/acme/backend`.
4. Choose **Everyone** or **Restricted**, and add groups and users as for a library.

<Frame>
  <img src="/images/enterprise/library-access/05-namespace-rules.png" alt="The Namespaces view listing the /acme and /acme-internal rules with their access and granted groups" />
</Frame>

A prefix matches whole path segments: `/acme` covers `/acme/payments`, but not `/acme-labs/payments`.

Context7 decides each library in this order:

1. The library's own rule, if it has one.
2. The namespace rule with the longest matching prefix.
3. The workspace default.

In the **Libraries** view, a library that takes its access from a namespace rule shows the rule under its access, for example `via /acme/*`.

<Frame>
  <img src="/images/enterprise/library-access/06-namespace-inherited.png" alt="The Libraries view showing libraries restricted through the /acme and /acme-internal namespace rules" />
</Frame>

## How it applies

Access is enforced everywhere a user reaches a library:

- **MCP**: restricted libraries are hidden from library search results, and a documentation request for a library the user cannot access returns the same "not found" response as a library that isn't indexed. Restricted libraries can't be told apart from ones that don't exist.
- **API**: the same filtering applies to library search and documentation requests made with a personal API key.
- **OAuth**: an MCP client that signed in with [OAuth](/enterprise/security/mcp-oauth) acts as the user who approved it. It gets exactly that user's library access, the same as the user's personal API key. OAuth scopes do not widen or narrow it.
- **Dashboard**: members only see the libraries they can access in their library list.

Admins are never restricted. They see and can query every library, which is also how they manage access in the first place.

<Note>
With **Require MCP authentication** on, these endpoints also need a session or a personal API key: library list, library details, library search, library logs, parse queue, and parse status.

With it off, they answer anonymous callers, but access rules still hide restricted libraries. A caller that sends a valid personal API key is still treated as its owner, so it sees the libraries that user can access.
</Note>

## Audit log

Open **Workspace Settings** and go to **Audit log** to review library access activity. The log records:

- Changes to the workspace default, library rules, and namespace rules, with the admin who made them.
- Access denials: a documentation request over MCP, or a dashboard or `/api/projects/...` request, for a library the caller cannot access. Each entry shows the user (or `anonymous`) and the library.

<Frame>
  <img src="/images/enterprise/library-access/07-audit-log.png" alt="The audit log listing access denials and namespace and library rule changes" />
</Frame>

Successful queries are not logged.

- **Access denials:** Context7 keeps the latest 2,000 and deletes older ones.
- **Rule changes:** kept forever.
- **The page** shows the latest 200 entries.
