- Claude Code: hooks and plugins
- Codex: MCP
- Cursor: hooks and MCP
- GitHub Copilot (Visual Studio, JetBrains, Xcode, Eclipse): MCP
- Kiro: MCP
- VS Code: MCP
- Devin (Windsurf): Cascade hooks
Prerequisites
- A Semgrep account
Authentication
How you sign in depends on which IDE you use. Claude Code (remote scans): The plugin handles authentication through OAuth. Each developer completes a one-time browser login when they first use the plugin. Semgrep refreshes access tokens automatically, so developers rarely need to sign in again. Other IDEs: These integrations run Semgrep through a locally installed CLI. Each developer signs in withsemgrep login, which opens a browser-based login flow. See Install the Semgrep CLI.
CLI and OAuth credentials
Guardian stores credentials in two local files under~/.semgrep/:
settings.yml: written when you sign in throughsemgrep loginor set an API token manually. This is the same file the Semgrep CLI uses.guardian.yml: written when you sign in through OAuth in the remote Claude Code plugin.
semgrep login, Guardian can use the credentials from settings.yml. For the remote Claude Code plugin, Guardian checks for OAuth credentials in guardian.yml first. If OAuth credentials are present, Guardian uses them instead of any API token in settings.yml.
At startup, Guardian fetches its default authentication method from Semgrep’s remote server. OAuth is currently the default for users who are not yet signed in. This setting is global and not configurable per user.
If you are switching from a local CLI setup to the remote Claude Code plugin, keep in mind that an existing OAuth session in guardian.yml takes precedence over CLI credentials in settings.yml. If scans run under a different account than you expect, check which file contains active credentials. Use semgrep logout to remove CLI credentials from settings.yml.
To sign in with the legacy API-token method in Claude Code, ask the Guardian MCP to log in to Semgrep using the legacy method.
Semgrep may disable API-token login for Guardian in the future, but there are no definite plans as of now.
Enterprise rollout
Shared API tokens and service accounts are not recommended for Guardian. Each developer should authenticate individually through OAuth for Claude Code orsemgrep login for local CLI integrations.
For Claude Code with remote scans, OAuth helps Semgrep associate activity with the correct user and avoids the risks of shared credentials.
Semgrep discourages sharing app or API tokens across a team because:
- Revoking a shared token affects every user who depends on it.
- Shared credentials are rate-limited as a single user, which can throttle scans when many developers run Guardian concurrently.
If you set an API token in
~/.semgrep/settings.yml, Guardian can use it when no OAuth session exists in guardian.yml. Semgrep does not recommend this pattern for enterprise rollouts.Connect to your IDE
- Claude Code
- Codex
- Cursor
- GitHub Copilot
- VS Code
- Devin (Windsurf)
- Kiro
- Other IDEs
Claude Code uses Semgrep’s hosted remote server by default, so you do not need to install the Semgrep CLI locally.The plugin registers a post-tool hook so Claude Code scans every file it writes. Learn more about Claude Code plugins and hooks.
1
Start a Claude Code instance:
2
Open the plugin manager:
3
Go to Discover, search for Semgrep, and click Install.
4
Tell Claude to load the plugin:
5
Start a new session in Claude to begin the OAuth login flow:
Run Semgrep Guardian locally
Run Semgrep Guardian locally
The remote server is the recommended default. If you need to run Semgrep locally instead, you can install the local plugin from the
semgrep/guardian-local repo.2
Start a Claude Code instance:
3
Add the Semgrep marketplace:
4
Install the plugin from the marketplace:
5
Tell Claude to load the plugin:
6
Set up the plugin:
Install the Semgrep CLI
This section applies only if you use an IDE other than Claude Code, or if you run the local Claude Code plugin. Claude Code’s default remote plugin handles authentication through OAuth and does not require a local CLI.1
Install the Semgrep CLI using Homebrew, pipx, or uv. This requires Python 3.10 or later (the Semgrep CLI needs it at runtime regardless of how it was installed):
2
Verify that you’ve installed the latest version of Semgrep:
3
Sign in to your Semgrep account and install the Semgrep Pro engine:
semgrep login launches a browser window. You can also use the activation link printed in the terminal.Enterprise deployment guide
To roll out Semgrep Guardian across an organization, standardize the install so every developer’s agent picks up the plugin automatically instead of relying on each developer to install it by hand.Use your agent’s built-in enterprise controls
Most coding agents let you pin an approved marketplace or plugin for your whole team. This is the simplest way to make Guardian available (or required) everywhere:- Claude Code: Require marketplaces for your team
- Cursor: Team marketplaces
Deploy through a mobile device management (MDM) platform for more granularity
Deploy through your MDM platform to scope rollout by device group, or to combine Guardian with other managed configuration deployed via your MDM. Anthropic maintains a set of MDM deployment examples and best practices that cover managed settings for macOS (.plist and .mobileconfig profiles via Jamf, Kandji, and similar) and Windows (PowerShell file deployment or ADMX/registry policy via Intune and Group Policy), along with how to verify that managed settings are applied.
Get help with a custom rollout
Reach out if you want help building something custom for your MDM or agent fleet. You can find us in Semgrep’s#mcp Slack community or check out our support options.
Additional resources
- Semgrep’s
#mcpSlack community - The Semgrep MCP server repo on GitHub