# Source: https://docs.snyk.io/integrations/snyk-studio-agentic-integrations/quickstart-guides-for-snyk-studio/windsurf-guide.md

# Windsurf guide

Access [Snyk Studio](https://docs.snyk.io/discover-snyk/getting-started/glossary#snyk-studio), including Snyk's MCP server, in Windsurf to secure code generated with agentic workflows through an LLM. This can be achieved by using the Snyk Security plugin or installing Snyk Studio directly. For most users, we recommend accessing Snyk Studio using the Snyk Security plugin.

## Recommended: Access Snyk Studio using the Snyk Security Plugin

1. Open the Snyk Security plugin in Windsurf
2. Click `Install`

<figure><img src="https://2533899886-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MdwVZ6HOZriajCf5nXH%2Fuploads%2Fgit-blob-a5f5fce274efabcf816a4ba4fe2826e67935e64e%2FScreenshot%202025-10-13%20at%202.19.30%E2%80%AFPM.png?alt=media" alt="Install the Snyk Security plugin in Visual Studio Code"><figcaption><p>Install the Snyk Security plugin in Visual Studio Code</p></figcaption></figure>

### Enable "Secure At Inception"

Once installation completes, a modal will appear prompting you to opt-in to Snyk Studio's "[Secure at Inception](https://docs.snyk.io/discover-snyk/getting-started/glossary#secure-at-inception)." This will automatically configure the necessary rules to scan any new AI generated code. Additional variations are available within the plugin's **Settings** page.

<figure><img src="https://2533899886-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MdwVZ6HOZriajCf5nXH%2Fuploads%2Fgit-blob-b85571b98c97d6dcd5a22ebdbde6c603ac490608%2Fimage%20(41).png?alt=media" alt=""><figcaption></figcaption></figure>

Choosing yes will activate `Auto Configure Snyk Mcp Server` and set the `Secure at Inception: Execution Frequency` to "On Code Generation." These settings willl handle the configuration of the Snyk MCP and the creation of the snyk\_rules.mdc file within the directory.

#### Updating Secure at Inception settings

Users who previously installed the VS Code IDE extensions and did not enable Secure at Inception via the modal window can enable them after the fact via the IDE extension settings. Users can also update Secure at Inception settings or disable them by setting the `Execution Frequency` to "Manual."

<figure><img src="https://2533899886-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MdwVZ6HOZriajCf5nXH%2Fuploads%2Fgit-blob-d73228dcb6c70f102025e04d7ec3171b5b4031a4%2Fimage.png?alt=media" alt=""><figcaption></figcaption></figure>

### Authenticate

{% hint style="warning" %}
If you are enabling Snyk Code for the first time, you must import existing projects in order to properly scan them.
{% endhint %}

Once you've made a selection regarding "Secure at Inception", you need to authenticate. You can authenticate at two points in this process:

* Immediately after plugin install
* Prior to your first Snyk code scan

As part of the authentication flow, you'll be asked to either sign up or sign in on the Snyk website. A browser window will open.

*For new users*, select the preferred sign up method and agree to the terms on the next screen. Once you've successfully authenticated, you'll be instructed to return to your IDE.

{% hint style="info" %}
In order to use Snyk Studio, specifically Snyk's SAST scanning capabilities, you'll need to enable [Snyk Code](https://docs.snyk.io/scan-with-snyk/snyk-code). Snyk Code analyzes your code for vulnerabilities and temporarily clones the repository and/or uploads your code. Cloned or uploaded code is cached according to our [data retention policy](https://docs.snyk.io/snyk-data-and-governance/how-snyk-handles-your-data). With the Snyk Free Plan, Snyk Code offers unlimited scans for open source projects, and limited tests for 1st-party code. [More details on plans](https://snyk.io/plans/)
{% endhint %}

For existing user&#x73;*,* select the log-in method associated with your account. If you don't already have access to Snyk Code, your LLM will prompt you to enable it prior to your first scan. You can also [enable it directly in Snyk's Settings](https://docs.snyk.io/implementation-and-setup/enterprise-implementation-guide/phase-2-configure-account/set-visibility-and-configure-an-organization-template/enable-snyk-code).

### Run Snyk Studio

Once authenticated, Snyk Studio should be triggered whenever new code is generated by the LLM. If Snyk Studio is not enabled, restart your IDE and try generating code again.

**Please note:** Free users are limited to a set number of scans. If you reach the allotment, we recommend [reaching out to sales](https://snyk.io/contact-us/) to unlock additional thresholds.

## Alternate: Install Snyk Studio Directly

## Prerequisites

* [Install Windsurf](#install-windsurf)
* [Install the Snyk CLI](https://docs.snyk.io/developer-tools/snyk-cli/install-or-update-the-snyk-cli)
* [Install the Snyk MCP](#install-the-snyk-mcp-server-in-windsurf)

### Install Windsurf

Install Windsurf to your local machine from the [Windsurf website](https://windsurf.com/).

### Install the Snyk MCP Server in Windsurf

Install the official Snyk MCP Server using the Windsurf MCP Marketplace.

<figure><img src="https://2533899886-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MdwVZ6HOZriajCf5nXH%2Fuploads%2Fgit-blob-a615afa05455ba9308a72cfdb0dea47c02f055e5%2Fimage.png?alt=media" alt=""><figcaption></figcaption></figure>

## Setting up the Snyk MCP Server

As a one-time setup, you may need to authenticate and trust the current Project directory. If required, the agentic workflow will manage this automatically.

These workflows are automatically executed by the underlying model and the agentic code assistant, and you will need to approve them in the Windsurf chat window.

## Examples

### Scanning for security vulnerabilities

In the chat, you can tag specific files or functions and ask Windsurf to scan your code for safely deploying to production:

{% code title="prompt" overflow="wrap" %}

```
Scan this directory for code security & dependency vulnerabilities and security issues
```

{% endcode %}

Windsurf indicates that this request is related to security vulnerability scanning and calls the Snyk MCP Server for various scans.

<figure><img src="https://2533899886-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MdwVZ6HOZriajCf5nXH%2Fuploads%2Fgit-blob-8fc5268f45f91e3b7c982dfdd27300222553c0d9%2Fimage%20(394).png?alt=media" alt=""><figcaption></figcaption></figure>

Windsurf is then able to gather all the security scanning results, both code (SAST) and dependencies (SCA), and based on recommendations and contextual information provided by the Snyk MCP Server, it is now able to provide code changes that address some or all of the security vulnerabilities that were found.

### "Secure at inception" rules

To practice [Secure at Inception](https://docs.snyk.io/discover-snyk/getting-started/glossary#secure-at-inception), Snyk recommends adopting rules that align the LLM for secure code generation and workflows.

The following is a suggested instruction for [Windsurf rules](https://docs.windsurf.com/windsurf/cascade/memories#rules). Append the following contents to the rules file at `global_rules.md`:

{% code title="global\_rules.md" overflow="wrap" %}

```
---
alwaysApply: true
always_on: true
trigger: always_on
applyTo: "**"
description: Snyk Security At Inception
---

# Project security best practices

- Always run **snyk_code_scan** tool for new first party code that is generated in a Snyk-supported language.
- If any security issues are found based on newly introduced or modified code or dependencies, attempt to fix the issues using the results context from **Snyk**.
- Rescan the code after fixing the issues to ensure that the issues were fixed and that there are no newly introduced issues.
- Repeat this process until no new issues are found.
```

{% endcode %}

#### Troubleshooting - Install Snyk MCP Server

The Snyk MCP Server should be installed using the IDE Extension or Windsurf MCP Marketplace. If you need to install the Snyk MCP Server manually then follow one of the options below.

#### Install with Node.js and `npx`

Create or edit the MCP configuration file `mcp_config.json` . This file can be accessed by navigating to the Windsurf Settings > Manage MCPs > View raw config.

If you have the Node.js `npx` executable installed in your environment, add the following JSON snippet to `mcp_config.json`:

```json5
{
  "mcpServers": {
    "Snyk": {
      "command": "npx",
      "args": ["-y", "snyk@latest", "mcp", "-t", "stdio"],
      "env": {}
    }
  }
}
```

<figure><img src="https://2533899886-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MdwVZ6HOZriajCf5nXH%2Fuploads%2Fgit-blob-33f702a8c46aadecf4b97b6ee6c8ebe1dbe3325e%2Fimage%20(407).png?alt=media" alt=""><figcaption></figcaption></figure>

#### Install with pre-installed Snyk CLI

If you have the Snyk CLI installed and accessible on your system path, include the following JSON snippet in `mcp_config.json`. Specify the full path to the Snyk executable CLI:

```json5
{
  "mcpServers": {
    "Snyk": {
      "command": "/absolute/path/to/snyk",
      "args": ["mcp", "-t", "stdio"],
      "env": {}
    }
  }
}
```

If the `snyk` command is not available, add it by following the instructions on the [Installing or updating the Snyk CLI](https://docs.snyk.io/developer-tools/snyk-cli/install-or-update-the-snyk-cli) page.