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://semgrep.dev/api/mcp/read-only. - API token: A Web API or Read-only API token, sent in an
Authorizationheader asBearer YOUR_SEMGREP_APP_TOKEN. ReplaceYOUR_SEMGREP_APP_TOKENwith your API token. - OAuth: Where the Copilot experience supports it, you sign in to Semgrep and select an organization in your browser.
Single-tenant URLThe 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.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, 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.
- A Web API or Read-only API token.
- 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.
Add the server
To add the server, follow these steps:-
Start a Copilot CLI session:
-
Run
/mcp add. A form opens. Press Tab to move between fields. Ifsemgrepis already configured, run/mcp edit semgrepinstead to update the existing entry. -
Fill in the form:
- Server Name:
semgrep - Server Type: HTTP
- URL:
https://semgrep.dev/api/mcp - HTTP Headers:
{"Authorization": "Bearer YOUR_SEMGREP_APP_TOKEN"}
- Server Name:
-
Press Ctrl+S 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: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 with a Read-only API token.Prerequisites
- The prerequisites for the hosted MCP server.
- A Web API or Read-only API token.
- 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.
Add the server
To add the server, follow these steps:- In the repository, go to Settings > Secrets and variables > Agents, click the Secrets tab, then click New repository secret.
-
Name the secret
COPILOT_MCP_SEMGREP_AUTH. Set its value toBearerfollowed by a space and your API token, for exampleBearer YOUR_SEMGREP_APP_TOKEN. Copilot cloud agent passes only secrets whose names start withCOPILOT_MCP_to MCP servers. For more information, see GitHub documentation on secrets and variables for Copilot cloud agent. - In the repository, go to Settings > Copilot > MCP servers.
-
Under MCP configuration, add the following configuration, or add the
semgrepentry to your existingmcpServersobject:To let Copilot cloud agent make changes, such as triaging findings or starting scans, usehttps://semgrep.dev/api/mcpand a Web API token instead. To allow only specific tools, replace"*"intoolswith a list of tool names. For tool names, see Tools and capabilities. - Click Save MCP configuration.
Verify the connection
To confirm that the server starts, follow these steps:- Assign an issue to Copilot.
- In the pull request that Copilot opens, click View session.
- Click the three-dot menu at the top right of the log viewer, then click Copilot.
- Expand the Start MCP Servers step. If
semgrepstarted, its tools are listed at the end of the step.
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. 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.jsonfile. 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.jsonfile in JetBrains IDEs, or under Server Configurations in Eclipse. These IDEs take an API token in arequestInitobject:
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.
- 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.
Add the server
To add the server, follow these steps:- Open your agent in Copilot Studio, then go to its Tools page.
- Select Add a tool > New tool > Model Context Protocol.
-
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 to give the agent only tools that read data
- Server name:
-
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
Authorizationas the header name.
- Click Create.
-
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
Bearerfollowed by a space and your API token, for exampleBearer YOUR_SEMGREP_APP_TOKEN.
- Click Add to agent.
- 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.
- Publish the agent.