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

# Connect Copilot

> Add the hosted MCP server for Semgrep AppSec Platform to GitHub Copilot or Microsoft Copilot Studio.

Add the hosted MCP server to GitHub Copilot or to an agent in Microsoft Copilot Studio. Choose your Copilot experience, then follow its setup instructions:

| Copilot experience | Where you use Semgrep | Authentication |
| :- | :- | :- |
| [GitHub Copilot CLI](#connect-github-copilot-cli) | Your terminal | API token |
| [Copilot cloud agent](#connect-copilot-cloud-agent) | Issues and pull requests on GitHub.com | API token |
| [Copilot Chat in an IDE](#connect-copilot-chat-in-an-ide) | VS Code, JetBrains IDEs, Visual Studio, or Eclipse | OAuth or API token, depending on the IDE |
| [Microsoft Copilot Studio agent](#connect-a-microsoft-copilot-studio-agent) | An agent that you build in Copilot Studio | OAuth or API token |

## Server URL and authentication

Every Copilot experience on this page uses the same server URLs and credentials:

* **Server URL:** `https://semgrep.dev/api/mcp`. To give Copilot only tools that read data, use the [read-only URL](https://docs.semgrep.dev/mcp/authentication.md#read-only-url), `https://semgrep.dev/api/mcp/read-only`.
* **API token:** A **Web API** or **Read-only** [API token](https://docs.semgrep.dev/mcp/authentication.md#token-scopes), sent in an `Authorization` header as `Bearer YOUR_SEMGREP_APP_TOKEN`. Replace `YOUR_SEMGREP_APP_TOKEN` with your API token.
* **OAuth:** Where the Copilot experience supports it, you sign in to Semgrep and select an organization in your browser.

For help choosing an authentication method, see [Authentication and access](https://docs.semgrep.dev/mcp/authentication.md).

> [!NOTE]
>
> **Single-tenant URL**
>
> The steps on this page use `https://semgrep.dev/api/mcp`. On a single-tenant deployment, replace that URL with `https://YOUR_TENANT.semgrep.dev/api/mcp`. Use your subdomain for `YOUR_TENANT`. To connect to the read-only URL instead, see [Read-only URL](https://docs.semgrep.dev/mcp/authentication.md#read-only-url).

## Connect GitHub Copilot CLI

Add the hosted MCP server to GitHub Copilot CLI so you can use Semgrep tools from your terminal. If you installed the [Semgrep Guardian plugin for GitHub Copilot](https://docs.semgrep.dev/semgrep-guardian/ide-setup/github-copilot.md), it already includes the Semgrep MCP tools, so you don't need to add the hosted MCP server separately.

### Prerequisites

* The [prerequisites for the hosted MCP server](https://docs.semgrep.dev/mcp/overview.md#prerequisites).
* A **Web API** or **Read-only** [API token](https://docs.semgrep.dev/mcp/authentication.md#token-scopes).
* On a Copilot Business or Copilot Enterprise plan, an organization or enterprise owner must enable the **MCP servers in Copilot** policy. The policy is off by default. For more information, see [GitHub documentation on Copilot policies](https://docs.github.com/en/copilot/how-tos/administer-copilot/manage-for-organization/manage-policies).

### Add the server

To add the server, follow these steps:

1. Start a Copilot CLI session:

   ```bash theme={null}
   copilot
   ```

2. Run `/mcp add`. A form opens. Press <kbd>Tab</kbd> to move between fields.

   If `semgrep` is already configured, run `/mcp edit semgrep` instead to update the existing entry.

3. Fill in the form:

   * **Server Name:** `semgrep`
   * **Server Type:** **HTTP**
   * **URL:** `https://semgrep.dev/api/mcp`
   * **HTTP Headers:** `{"Authorization": "Bearer YOUR_SEMGREP_APP_TOKEN"}`

4. Press <kbd>Ctrl</kbd>+<kbd>S</kbd> to save. The server is available right away, without restarting the session.

   GitHub Copilot CLI saves the server to `~/.copilot/mcp-config.json`, including the token. Keep that file out of version control.

### Verify the connection

Run `/mcp show semgrep` and confirm that `semgrep` is connected and lists its tools.

### Add the server from your terminal

You can also add the server without starting a session:

```bash theme={null}
copilot mcp add --transport http --header "Authorization: Bearer YOUR_SEMGREP_APP_TOKEN" semgrep https://semgrep.dev/api/mcp
```

This command includes the token, so your shell can save it to its history file.

For more information, see [GitHub documentation on adding MCP servers to Copilot CLI](https://docs.github.com/en/copilot/how-tos/copilot-cli/customize-copilot/add-mcp-servers).

## Connect Copilot cloud agent

Copilot cloud agent works on GitHub.com, for example on issues that you assign to Copilot. It reads its MCP configuration from a repository's settings.

### Security considerations

Copilot cloud agent doesn't support remote MCP servers that use OAuth, so connect with an API token stored as a secret. Copilot cloud agent uses MCP tools without asking for your approval. To limit what it can change, connect to the [read-only URL](https://docs.semgrep.dev/mcp/authentication.md#read-only-url) with a **Read-only** API token.

> [!WARNING]
>
> Everyone who can assign work to Copilot in the repository uses the same API token, with the Semgrep access of the token's owner. Through Copilot, they can read findings and code snippets from any project that the token can access. Copilot can also include that data in pull requests. The read-only URL limits what Copilot can change, not what it can read. Create the token as a user whose Semgrep access fits everyone who works in the repository.

### Prerequisites

* The [prerequisites for the hosted MCP server](https://docs.semgrep.dev/mcp/overview.md#prerequisites).
* A **Web API** or **Read-only** [API token](https://docs.semgrep.dev/mcp/authentication.md#token-scopes).
* Admin access to the repository.
* On a Copilot Business or Copilot Enterprise plan, the **MCP servers in Copilot** policy turned on. For more information, see [GitHub documentation on Copilot policies](https://docs.github.com/en/copilot/how-tos/administer-copilot/manage-for-organization/manage-policies).

### Add the server

To add the server, follow these steps:

1. In the repository, go to **Settings > Secrets and variables > Agents**, click the **Secrets** tab, then click **New repository secret**.

2. Name the secret `COPILOT_MCP_SEMGREP_AUTH`. Set its value to `Bearer` followed by a space and your API token, for example `Bearer YOUR_SEMGREP_APP_TOKEN`.

   Copilot cloud agent passes only secrets whose names start with `COPILOT_MCP_` to MCP servers. For more information, see [GitHub documentation on secrets and variables for Copilot cloud agent](https://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-cloud-agent/configure-secrets-and-variables).

3. In the repository, go to **Settings > Copilot > MCP servers**.

4. Under **MCP configuration**, add the following configuration, or add the `semgrep` entry to your existing `mcpServers` object:

   ```json theme={null}
   {
     "mcpServers": {
       "semgrep": {
         "type": "http",
         "url": "https://semgrep.dev/api/mcp/read-only",
         "headers": {
           "Authorization": "$COPILOT_MCP_SEMGREP_AUTH"
         },
         "tools": ["*"]
       }
     }
   }
   ```

   To let Copilot cloud agent make changes, such as triaging findings or starting scans, use `https://semgrep.dev/api/mcp` and a **Web API** token instead. To allow only specific tools, replace `"*"` in `tools` with a list of tool names. For tool names, see [Tools and capabilities](https://docs.semgrep.dev/mcp/tools.md).

5. Click **Save MCP configuration**.

For more information, see [GitHub documentation on configuring MCP servers for a repository](https://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/configure-mcp-servers).

### Verify the connection

To confirm that the server starts, follow these steps:

1. Assign an issue to Copilot.
2. In the pull request that Copilot opens, click **View session**.
3. Click the three-dot menu at the top right of the log viewer, then click **Copilot**.
4. Expand the **Start MCP Servers** step. If `semgrep` started, its tools are listed at the end of the step.

The repository's MCP configuration also applies to Copilot code review.

## Connect Copilot Chat in an IDE

Setup for Copilot Chat depends on your IDE. Find your IDE in the following list:

* **VS Code:** See [Connect VS Code](https://docs.semgrep.dev/mcp/connect/vs-code.md). Semgrep tools are available in Copilot Chat **Agent** mode.
* **Visual Studio:** In Copilot Chat **Agent** mode, add an HTTP server with the server URL. Visual Studio saves it to an `mcp.json` file. To sign in with OAuth, open that file and click the **Auth** CodeLens for the server.
* **JetBrains IDEs or Eclipse:** Add a remote server to the `mcp.json` file in JetBrains IDEs, or under **Server Configurations** in Eclipse. These IDEs take an API token in a `requestInit` object:

  ```json theme={null}
  {
    "servers": {
      "semgrep": {
        "url": "https://semgrep.dev/api/mcp",
        "requestInit": {
          "headers": {
            "Authorization": "Bearer YOUR_SEMGREP_APP_TOKEN"
          }
        }
      }
    }
  }
  ```

For where to find these settings in each IDE, see [GitHub documentation on extending Copilot Chat with MCP](https://docs.github.com/en/copilot/how-tos/copilot-in-your-ide/customize-copilot/extend-copilot-with-tools-and-context/extend-copilot-chat-with-mcp).

## Connect a Microsoft Copilot Studio agent

Add the hosted MCP server as a tool on an agent in Copilot Studio. With generative orchestration, the agent calls Semgrep tools when they're relevant to a request.

### Prerequisites

* The [prerequisites for the hosted MCP server](https://docs.semgrep.dev/mcp/overview.md#prerequisites).
* A Copilot Studio agent with generative orchestration turned on.
* If your Power Platform environment has data policies, they must allow the connector that Copilot Studio creates for the server. Copilot Studio connects to MCP servers through Power Platform connectors, so connector data policies also apply to the hosted MCP server.
* To connect with an API token, a **Web API** or **Read-only** [API token](https://docs.semgrep.dev/mcp/authentication.md#token-scopes).

### Add the server

To add the server, follow these steps:

1. Open your agent in Copilot Studio, then go to its **Tools** page.

2. Select **Add a tool > New tool > Model Context Protocol**.

3. Enter the server details:

   * **Server name:** `Semgrep`
   * **Server description:** A description that tells the agent when to use the server, for example `Search, triage, and fix Semgrep security findings, and run Semgrep scans.`
   * **Server URL:** `https://semgrep.dev/api/mcp`, or the [read-only URL](https://docs.semgrep.dev/mcp/authentication.md#read-only-url) to give the agent only tools that read data

4. Choose an authentication method:

   * **OAuth (recommended):** Select **OAuth 2.0**, then set **Type** to **Dynamic discovery**.
   * **API token:** Select **API key**, set **Type** to **Header**, and enter `Authorization` as the header name.

5. Click **Create**.

6. In the **Add tool** dialog, click **Create a new connection**:

   * With OAuth, sign in to Semgrep and select an organization in your browser.
   * With an API token, enter `Bearer` followed by a space and your API token, for example `Bearer YOUR_SEMGREP_APP_TOKEN`.

7. Click **Add to agent**.

8. Optional: To allow only specific tools, select the Semgrep server on the **Tools** page. Turn off **Allow all**, turn on the tools you want, and click **Save**. All tools are on by default. For tool names, see [Tools and capabilities](https://docs.semgrep.dev/mcp/tools.md).

9. Publish the agent.

### Verify the connection

On the agent's **Tools** page, select the Semgrep server and confirm that its settings page lists the Semgrep tools.

If Semgrep adds, removes, or renames tools, Copilot Studio can take up to 24 hours to show the change. For more information, see [Microsoft documentation on troubleshooting MCP integration](https://learn.microsoft.com/en-us/microsoft-copilot-studio/mcp-troubleshooting).

For the full procedure, see [Microsoft documentation on adding an MCP server to a Copilot Studio agent](https://learn.microsoft.com/en-us/microsoft-copilot-studio/mcp-add-existing-server-to-agent).
