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

# Authentication and access

> Find the hosted MCP server URL for your deployment, choose between OAuth and an API token, and limit access with token scopes and the read-only URL.

The hosted MCP server uses your existing AppSec Platform permissions. Choose a server URL, an authentication method, and, if you use an API token, a token scope.

## Server URLs

Use the URL for your deployment type:

| Deployment | MCP server URL | Read-only URL |
| :- | :- | :- |
| Multi-tenant | `https://semgrep.dev/api/mcp` | `https://semgrep.dev/api/mcp/read-only` |
| Single-tenant | `https://YOUR_TENANT.semgrep.dev/api/mcp` | `https://YOUR_TENANT.semgrep.dev/api/mcp/read-only` |

Replace `YOUR_TENANT` with your single-tenant subdomain. The examples in these pages use the multi-tenant MCP server URL.

If you open either URL in a browser, Semgrep shows a page with setup instructions.

### Read-only URL

The read-only URL provides only the tools that read data, plus the `discover`, `semgrep_account`, and `semgrep_app_link` tools. It doesn't provide tools that make changes, such as triaging findings, generating fixes, applying policies, configuring rules, creating tickets, or starting scans and workflows. The `semgrep_run_job` tool isn't available, and the `discover` tool suggests only read tools.

To connect to the read-only URL, follow the steps for your client in [Connect an MCP client](https://docs.semgrep.dev/mcp/connect/claude-code.md), and replace `/api/mcp` with `/api/mcp/read-only`. If you also connect to the full MCP server URL, give each server a different name. For example, in Claude Code:

```bash theme={null}
claude mcp add --transport http --scope user semgrep-read-only https://semgrep.dev/api/mcp/read-only
```

> [!NOTE]
>
> The read-only URL limits which tools your client sees and can call. It doesn't limit your credentials: both URLs accept the same OAuth sign-in and API tokens. To also limit what the credential can do, connect with a **Read-only** API token. See [Token scopes](#token-scopes).

## How authentication works

Each tool call uses the same API route as AppSec Platform. Semgrep checks your permissions on that route, as it does for any other request.

You can authenticate with OAuth or with an API token:

| | OAuth (recommended) | API token |
| :- | :- | :- |
| How you sign in | Sign in through your browser, then select an organization. | Add an `Authorization: Bearer YOUR_SEMGREP_APP_TOKEN` header to your client configuration. |
| Permissions | Your role in the organization you selected. | The token's scope, capped by the role of the token's owner. |
| Organization | The organization you selected when you signed in. | The organization the token was created in. |
| Switch organizations | Reconnect and select another organization. | Use a token from the other organization. |

OAuth is the recommended way to connect. Use an API token if you prefer to manage the credential yourself, or if your client doesn't support OAuth.

## Token scopes

Create a token in [**Settings > Tokens > API tokens**](https://semgrep.dev/orgs/-/settings/tokens/api). The token's scope determines which tools work:

| Token scope | What the hosted MCP server can do |
| :- | :- |
| Web API | All read and write operations. |
| Read-only | Read operations only. |
| Agent (CI) | Read and write operations on scans. |
| Member | Not supported. |
| CLI token from `semgrep login` | Policy, rule scope, and workflow schedule tools; source code manager (SCM), Slack, and ticketing settings; and scan reads. |

For more information, see [Access tokens](https://docs.semgrep.dev/deployment/tokens.md).

For the examples in [Connect an MCP client](https://docs.semgrep.dev/mcp/connect/claude-code.md), use a **Web API** or **Read-only** token. Where the client supports it, these examples read the token from the `SEMGREP_APP_TOKEN` environment variable, so the token stays out of the configuration file.

> [!WARNING]
>
> Treat the token like a password. Don't commit configuration files that contain it to version control.
