Goose CLI guide
Share your experience with AI-Assisted Coding tools by filling in this survey and secure a chance to win Snyk swag!
You can add the Snyk MCP server to Goose CLI to secure code generated with agentic workflows through an LLM. This can be achieved in several ways. When you use it for the first time, the MCP server will ask for trust and trigger authentication if necessary.
Prerequisites
Install GooseCLI
Install the GooseCLI. For mode details, see the official Goose CLI installation instructions.
Install the Snyk MCP Server in Goose CLI using npx command
This installation instruction assumes you have a Node.js local development environment setup with the npx
executable.
To install the Snyk MCP Server using the Goose CLI interactive session, proceed with the following instructions:
Start an interactive Goose configuration wizard by running the
goose configure
command:From the configuration menu, chose Add Extension.
Choose Command-line extension (run a local command or script).
Name this extension Snyk Security.
Run the command by typing in:
npx -y snyk@latest mcp -t stdio
Continue with the defaults (timeout of 300 seconds), and optionally provide the Snyk API token if your Organization policy requires one.
A complete Goose configuration walkthrough should look as follows:

Start or resume your Goose session with the Snyk MCP server enabled.
Install the Snyk MCP Server in Goose CLI using Snyk CLI
This installation instruction assumes you have installed the Snyk CLI and the snyk
executable is available in your system's path.
Install the Snyk MCP Server using the Goose CLI interactive session by following these instructions:
Start an interactive Goose configuration wizard by running the
goose configure
command.Choose Add Extension from the configuration menu.
Select Command-line extension (run a local command or script).
Name this extension Snyk Security.
Run the command by typing in:
/path/to/snyk mcp -t stdio
- replacing/path/to/snyk
with the fully qualified absolute path to your Snyk CLI.Continue with the defaults (timeout of 300 seconds), and optionally provide the Snyk API token if your Organization policy requires one.
Start or resume your Goose session with the Snyk MCP server enabled.
Setting up the Snyk MCP Server
As a one-time setup, you may need to authenticate and trust the Project directory. If required, the agentic workflow will likely manage this automatically.
These workflows are mostly automatically executed by the underlying model and the agentic code assistant, and you will need to approve them using a browser confirmation dialog.
You can explicitly prompt to authenticate your account as follows:
Authenticate my Snyk account

If you are not authenticated, this prompt opens a browser for you to authenticate to the Snyk Web UI, and then you can continue with the agent.

Examples
Scanning for security vulnerabilities
In the chat, you can tag specific files or functions and ask the agent to scan your code and third-party dependencies of the Project.
Scan this directory for code security & dependency vulnerabilities and security issues
Goose CLI invokes Snyk scanning, providing output, and insights based on the results that Snyk returned:

"Secure at inception" rules
To practice Secure at Inception, Snyk recommends adopting rules that align the LLM for secure code generation and workflows.
The following is a suggested instruction to use with Goose CLI recipes or with Goose hints file
Always run Snyk Code scanning tool for new first party code generated.
Always run Snyk SCA scanning tool for new dependencies or dependency updates.
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 issues are found.
Add the following contents to the .goosehints
file in the root directory of the Project:
# Project security best practices
- Always run Snyk Code scanning tool for new first party code generated.
- Always run Snyk SCA scanning tool for new dependencies or dependency updates.
- 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 issues are found.
Last updated
Was this helpful?