| 1 | --- |
| 2 | title: "Automated Security Scanning with Snyk MCP and Continue" |
| 3 | description: "Set up an AI-powered security workflow that automatically scans your code, dependencies, infrastructure, and containers using natural language commands." |
| 4 | sidebarTitle: "Snyk Security Scanning with Continue" |
| 5 | --- |
| 6 | |
| 7 | <Card title="What You'll Build" icon="shield-halved"> |
| 8 | An automated security scanning system that uses Continue's AI agent with Snyk |
| 9 | MCP to identify vulnerabilities in code, dependencies, infrastructure, and |
| 10 | containers - all through simple natural language prompts |
| 11 | </Card> |
| 12 | |
| 13 | ## Prerequisites |
| 14 | |
| 15 | Before starting, ensure you have: |
| 16 | |
| 17 | - Continue account with **Hub access** |
| 18 | - Read: [Understanding Agents โ How to get started with Hub agents](/guides/understanding-agents#how-to-get-started-with-hub-agents) |
| 19 | - Node.js 18+ installed locally |
| 20 | - [Snyk account](https://snyk.io/) (free tier works) |
| 21 | - A local project to scan for vulnerabilities |
| 22 | |
| 23 | For all options, first: |
| 24 | <Steps> |
| 25 | <Step title="Install Continue CLI"> |
| 26 | ```bash |
| 27 | npm i -g @continuedev/cli |
| 28 | ``` |
| 29 | </Step> |
| 30 | |
| 31 | <Step title="Add Your Project to Snyk"> |
| 32 | |
| 33 | 1. Sign up for a Snyk account at [snyk.io](https://snyk.io/) |
| 34 | 2. Create a new project in Snyk by importing your code repository (Git |
| 35 | provider or manual upload) |
| 36 | </Step> |
| 37 | </Steps> |
| 38 | <Warning> |
| 39 | To use agents in headless mode, you need a [Continue API key](https://hub.continue.dev/settings/api-keys). |
| 40 | </Warning> |
| 41 | |
| 42 | ## Snyk Continuous AI Workflow Options |
| 43 | |
| 44 | <Card title="๐ Fastest Path to Success" icon="zap"> |
| 45 | Skip the manual setup and use our pre-built Snyk Continuous AI agent that includes |
| 46 | the Snyk MCP and optimized security scanning workflows for more consistent results. |
| 47 | </Card> |
| 48 | |
| 49 | |
| 50 | After ensuring you meet the **Prerequisites** above, you have two paths to get started: |
| 51 | |
| 52 | <Tabs> |
| 53 | <Tab title="โก Quick Start (Recommended)"> |
| 54 | <Steps> |
| 55 | <Step title="Load the Pre-Built Agent"> |
| 56 | Navigate to your project directory and run: |
| 57 | ```bash |
| 58 | cn --config continuedev/snyk-continuous-ai |
| 59 | ``` |
| 60 | |
| 61 | This agent includes: |
| 62 | - **Snyk MCP** pre-configured and ready to use |
| 63 | - **Security-focused rules** for best practices |
| 64 | </Step> |
| 65 | |
| 66 | <Step title="Run Your First Security Scan"> |
| 67 | Start with a comprehensive security scan: |
| 68 | ```bash |
| 69 | # TUI mode |
| 70 | cn -p "Run a complete security scan on this project including code vulnerabilities, dependencies, and any IaC files. Summarize findings by severity." |
| 71 | ``` |
| 72 | |
| 73 | That's it! The agent handles everything automatically. |
| 74 | </Step> |
| 75 | </Steps> |
| 76 | |
| 77 | <Info> |
| 78 | **Why Use the Agent?** The pre-built agent provides consistent security scanning workflows and handles MCP configuration automatically, making it easier to get started with AI-powered security scanning. |
| 79 | </Info> |
| 80 | |
| 81 | </Tab> |
| 82 | |
| 83 | <Tab title="๐ ๏ธ Manual Setup"> |
| 84 | <Steps> |
| 85 | <Step title="Create a New Agent via the Continue Hub"> |
| 86 | Go to the [Continue Hub](https://hub.continue.dev) and [create a new agent](https://hub.continue.dev/new?type=agent). |
| 87 | </Step> |
| 88 | |
| 89 | <Step title="Connect Snyk MCP via Continue Hub"> |
| 90 | Visit the [Snyk MCP on Continue Hub](https://hub.continue.dev/snyk/snyk-mcp) and click **Install** to add it to the agent you created in the step above. |
| 91 | |
| 92 | This will add Snyk MCP to your agent's available tools. The Hub listing automatically configures the MCP command: |
| 93 | ```bash |
| 94 | npx -y snyk@latest mcp -t stdio |
| 95 | ``` |
| 96 | |
| 97 | <Tip> |
| 98 | **Alternative installation methods:** |
| 99 | 1. **Quick CLI install**: `cn --mcp snyk/snyk-mcp` |
| 100 | 2. **Manual configuration**: Add the MCP to your `~/.continue/config.json` under the `mcpServers` section |
| 101 | |
| 102 | Once installed, Snyk MCP tools become available to your Continue agent for all prompts. |
| 103 | </Tip> |
| 104 | |
| 105 | <Info> |
| 106 | The MCP will request authentication and folder trust permissions when first used. |
| 107 | This is handled automatically by the Continue agent. |
| 108 | </Info> |
| 109 | |
| 110 | </Step> |
| 111 | |
| 112 | <Step title="Add Secure-at-Inception Rules"> |
| 113 | Install the [Snyk Secure-at-Inception rules](https://hub.continue.dev/snyk/secure-at-inception) from the Hub to enable automatic security scanning. |
| 114 | |
| 115 | **How to add rules to your agent:** |
| 116 | 1. Visit the rules link above and click **Install** |
| 117 | 2. The rules will be added to your agent configuration automatically |
| 118 | 3. Rules apply globally to all your Continue sessions |
| 119 | |
| 120 | These rules configure your agent to: |
| 121 | - **Run [SAST](https://snyk.io/learn/application-security/sast/) scans** on newly generated or modified code |
| 122 | - **Check dependencies** when adding or updating packages |
| 123 | - **Auto-fix issues** using Snyk's recommendations, then rescan |
| 124 | |
| 125 | </Step> |
| 126 | |
| 127 | <Step title="Run Your First Security Scan"> |
| 128 | Start with a comprehensive security scan: |
| 129 | ```bash |
| 130 | # TUI mode |
| 131 | cn "Run a complete security scan on this project including code vulnerabilities, dependencies, and any IaC files. Summarize findings by severity." |
| 132 | ``` |
| 133 | </Step> |
| 134 | </Steps> |
| 135 | |
| 136 | </Tab> |
| 137 | </Tabs> |
| 138 | |
| 139 | <Accordion title="Agent Requirements"> |
| 140 | To use the pre-built agent, you need either: |
| 141 | - **Continue CLI Pro Plan** with the models add-on, OR |
| 142 | - **Your own API keys** added to Continue Hub secrets (same as manual setup) |
| 143 | |
| 144 | The agent will automatically detect and use your configuration along with the pre-configured Snyk MCP for security scanning operations. |
| 145 | |
| 146 | </Accordion> |
| 147 | |
| 148 | --- |
| 149 | |
| 150 | ## Security Scanning Recipes |
| 151 | |
| 152 | Now you can use natural language prompts to run comprehensive security scans. The Continue agent automatically calls the appropriate Snyk MCP tools. |
| 153 | |
| 154 | <Info> |
| 155 | You can add prompts to your agent's configuration for easy access in future sessions. Go to your agent in the [Continue Hub](https://hub.continue.dev), click **Edit**, and add prompts under the **Prompts** section. |
| 156 | </Info> |
| 157 | |
| 158 | <Info> |
| 159 | **Where to run these workflows:** |
| 160 | - **IDE Extensions**: Use Continue in VS Code, JetBrains, or other supported IDEs |
| 161 | - **Terminal (TUI mode)**: Run `cn` to enter interactive mode, then type your prompts |
| 162 | - **CLI (headless mode)**: Use `cn -p "your prompt"` for headless commands |
| 163 | |
| 164 | **Test in Plan Mode First**: Before running security scans that might make |
| 165 | changes, test your prompts in plan mode (see the [Plan Mode |
| 166 | Guide](/guides/plan-mode-guide); press **Shift+Tab** to switch modes in TUI/IDE). This |
| 167 | shows you what the agent will do without executing it. For example: `"Run a |
| 168 | Snyk Code scan and fix the top 3 issues"` |
| 169 | </Info> |
| 170 | |
| 171 | ### Code Vulnerability Scanning ([SAST](https://snyk.io/learn/application-security/sast/)) |
| 172 | |
| 173 | <Card title="Static Application Security Testing" icon="code"> |
| 174 | Scan your source code for security vulnerabilities and code quality issues. |
| 175 | |
| 176 | **TUI Mode Prompt:** |
| 177 | ``` |
| 178 | Run a Snyk Code scan on this repo with severity threshold medium. |
| 179 | Summarize issues with file:line. Propose minimal diffs for the top 3 |
| 180 | and rerun to verify. |
| 181 | ``` |
| 182 | |
| 183 | **Headless Mode Prompt:** |
| 184 | ```bash |
| 185 | cn -p "Run a Snyk Code scan on this repo with severity threshold medium. Summarize issues with file:line. Propose minimal diffs for the top 3 and rerun to verify." |
| 186 | ``` |
| 187 | |
| 188 | </Card> |
| 189 | |
| 190 | ### Dependency Scanning ([SCA](https://snyk.io/learn/software-composition-analysis-sca/)) |
| 191 | |
| 192 | <Card title="Software Composition Analysis" icon="cube"> |
| 193 | Check open source dependencies for known vulnerabilities. |
| 194 | |
| 195 | **TUI Mode Prompt:** |
| 196 | ``` |
| 197 | Run Snyk Open Source on this repo (include dev deps). |
| 198 | Summarize vulnerable paths and propose a minimal-risk upgrade plan. |
| 199 | Re-test after the plan (dry run). |
| 200 | ``` |
| 201 | |
| 202 | **Headless Mode Prompt:** |
| 203 | ```bash |
| 204 | cn -p "Run Snyk Open Source on this repo (include dev deps). Summarize vulnerable paths and propose a minimal-risk upgrade plan. Re-test after the plan (dry run)." |
| 205 | ``` |
| 206 | |
| 207 | </Card> |
| 208 | |
| 209 | ### Infrastructure as Code ([IaC](https://snyk.io/learn/infrastructure-as-code-iac/)) |
| 210 | |
| 211 | <Card title="IaC Security" icon="cloud"> |
| 212 | Scan Terraform, CloudFormation, and Kubernetes configs for misconfigurations. |
| 213 | |
| 214 | **TUI Mode Prompt:** |
| 215 | ``` |
| 216 | Scan ./infra with Snyk IaC. Report high/critical misconfigs |
| 217 | with exact files/lines. Provide code changes and re-scan to confirm. |
| 218 | ``` |
| 219 | |
| 220 | **Headless Mode Prompt:** |
| 221 | ```bash |
| 222 | cn -p "Scan ./infra with Snyk IaC. Report high/critical misconfigs with exact files/lines. Provide code changes and re-scan to confirm." |
| 223 | ``` |
| 224 | |
| 225 | </Card> |
| 226 | |
| 227 | ### Container Scanning |
| 228 | |
| 229 | <Card title="Container Security" icon="docker"> |
| 230 | Analyze Docker images for vulnerabilities in base images and packages. |
| 231 | |
| 232 | **TUI Mode Prompt:** |
| 233 | ``` |
| 234 | Scan image my-api:latest. Exclude base image vulns. |
| 235 | Print dependency tree. Recommend a safer base image or upgrades. |
| 236 | Re-test after the change (dry run). |
| 237 | ``` |
| 238 | |
| 239 | **Headless Mode Prompt:** |
| 240 | ```bash |
| 241 | cn -p "Scan image my-api:latest. Exclude base image vulns. Print dependency tree. Recommend a safer base image or upgrades. Re-test after the change (dry run)." |
| 242 | ``` |
| 243 | |
| 244 | </Card> |
| 245 | |
| 246 | ### Pull Request Scanning |
| 247 | |
| 248 | <Card title="Changed Files Only" icon="code-branch"> |
| 249 | Focus scanning on modified files to catch issues before merging. |
| 250 | |
| 251 | **TUI Mode Prompt:** |
| 252 | ``` |
| 253 | Scan only files changed since origin/main with Snyk Code. |
| 254 | Block if new high issues would be introduced. Show deltas. |
| 255 | ``` |
| 256 | |
| 257 | **Headless Mode Prompt:** |
| 258 | ```bash |
| 259 | cn -p "Scan only files changed since origin/main with Snyk Code. Block if new high issues would be introduced. Show deltas." |
| 260 | ``` |
| 261 | |
| 262 | </Card> |
| 263 | |
| 264 | ### Security Learning |
| 265 | |
| 266 | <Card title="Snyk Learn Integration" icon="graduation-cap"> |
| 267 | Access security education resources based on identified vulnerabilities ([CWE](https://cwe.mitre.org/)). |
| 268 | |
| 269 | **TUI Mode Prompt:** |
| 270 | ``` |
| 271 | Open Snyk Learn lessons related to the top CWE(s) from this scan. |
| 272 | ``` |
| 273 | |
| 274 | **Headless Mode Prompt:** |
| 275 | ```bash |
| 276 | cn -p "Open Snyk Learn lessons related to the top CWE(s) from this scan." |
| 277 | ``` |
| 278 | |
| 279 | </Card> |
| 280 | |
| 281 | ## Continuous Security with GitHub Actions |
| 282 | |
| 283 | This example demonstrates a **Continuous AI workflow** where security scanning runs automatically in your CI/CD pipeline Headless Mode Prompt in headless mode (`cn -p`) with Snyk MCP. |
| 284 | |
| 285 | ### Add GitHub Secrets |
| 286 | |
| 287 | Navigate to **Repository Settings โ Secrets and variables โ Actions** and add: |
| 288 | |
| 289 | - `CONTINUE_API_KEY`: Your Continue API key from [hub.continue.dev/settings/api-keys](https://hub.continue.dev/settings/api-keys) |
| 290 | |
| 291 | ### Create Workflow File |
| 292 | |
| 293 | Create `.github/workflows/snyk-security.yml` in your repository: |
| 294 | |
| 295 | ```yaml |
| 296 | name: Security Scanning with Snyk MCP |
| 297 | |
| 298 | on: |
| 299 | pull_request: |
| 300 | branches: [main] |
| 301 | push: |
| 302 | branches: [main] |
| 303 | schedule: |
| 304 | - cron: "0 8 * * *" # Daily at 8 AM UTC |
| 305 | |
| 306 | jobs: |
| 307 | security-scan: |
| 308 | runs-on: ubuntu-latest |
| 309 | |
| 310 | steps: |
| 311 | - uses: actions/checkout@v4 |
| 312 | |
| 313 | - name: Set up Node.js |
| 314 | uses: actions/setup-node@v4 |
| 315 | with: |
| 316 | node-version: "18" |
| 317 | |
| 318 | - name: Install Continue CLI |
| 319 | run: | |
| 320 | npm install -g @continuedev/cli |
| 321 | echo "โ
Continue CLI installed" |
| 322 | |
| 323 | - name: Authenticate Continue CLI |
| 324 | env: |
| 325 | CONTINUE_API_KEY: ${{ secrets.CONTINUE_API_KEY }} |
| 326 | run: | |
| 327 | cn auth login --api-key "$CONTINUE_API_KEY" |
| 328 | echo "โ
Continue CLI authenticated" |
| 329 | |
| 330 | - name: Run Security Scans |
| 331 | run: | |
| 332 | echo "๐ Running code vulnerability scan..." |
| 333 | cn -p "Run Snyk Code scan with severity high on this repo. |
| 334 | Fail if any high issues are present." |
| 335 | |
| 336 | echo "๐ฆ Checking dependencies..." |
| 337 | cn -p "Run Snyk Open Source on this repo. |
| 338 | Fail on fixable high issues." |
| 339 | |
| 340 | - name: Generate Security Report |
| 341 | if: always() |
| 342 | run: | |
| 343 | cn -p "Generate a markdown security report summarizing: |
| 344 | - Total vulnerabilities by severity |
| 345 | - Top 3 critical issues (if any) |
| 346 | - Recommended next steps |
| 347 | Save to security-report.md" |
| 348 | |
| 349 | - name: Upload Security Report |
| 350 | uses: actions/upload-artifact@v4 |
| 351 | if: always() |
| 352 | with: |
| 353 | name: security-report-${{ github.run_number }} |
| 354 | path: security-report.md |
| 355 | retention-days: 30 |
| 356 | ``` |
| 357 | |
| 358 | <Info> |
| 359 | The Snyk MCP authentication is handled through Continue Hub. No need to manage |
| 360 | Snyk tokens directly in CI - the agent manages authentication. |
| 361 | </Info> |
| 362 | |
| 363 | ## Security Guardrails |
| 364 | |
| 365 | Implement automated security policies using Continue's rule system. See the [Rules deep dive](/customize/deep-dives/rules) for authoring tips. |
| 366 | |
| 367 | <Note> |
| 368 | **Coming Soon**: These security guardrail prompts will be available as pre-configured rules on the Continue Hub for easy installation. |
| 369 | </Note> |
| 370 | |
| 371 | <Card title="Pre-commit Scanning" icon="lock"> |
| 372 | ```bash |
| 373 | "Always run Snyk Code before committing newly |
| 374 | generated code; refuse to proceed if high |
| 375 | issues remain." |
| 376 | ``` |
| 377 | </Card> |
| 378 | |
| 379 | <Card title="Dependency Safety" icon="shield-check"> |
| 380 | ```bash |
| 381 | "When adding/updating a dependency, run Snyk Open Source, choose the |
| 382 | lowest-risk upgrade, and re-test." |
| 383 | ``` |
| 384 | </Card> |
| 385 | |
| 386 | <Card title="Container Hardening" icon="box"> |
| 387 | ```bash |
| 388 | "Before building containers, scan base images and recommend |
| 389 | security-hardened alternatives." |
| 390 | ``` |
| 391 | </Card> |
| 392 | |
| 393 | <Card title="IaC Compliance" icon="clipboard-list"> |
| 394 | ```bash |
| 395 | "Scan all Terraform changes for compliance |
| 396 | violations before applying infrastructure." |
| 397 | ``` |
| 398 | </Card> |
| 399 | |
| 400 | <Tip> |
| 401 | Enable the **Secure-at-Inception** rules from the Hub to automatically apply |
| 402 | these guardrails to all code generation and modifications. |
| 403 | </Tip> |
| 404 | |
| 405 | ## Troubleshooting |
| 406 | |
| 407 | ### Authentication Issues |
| 408 | |
| 409 | ```bash |
| 410 | "Check Snyk auth status and current org. If not authenticated, |
| 411 | help me authenticate. Then run a quick Code scan on ./ |
| 412 | with severity medium and print one example issue." |
| 413 | ``` |
| 414 | |
| 415 | ### Fix Validation |
| 416 | |
| 417 | ```bash |
| 418 | "Propose minimal diffs only in affected files, |
| 419 | then rerun the same Snyk scan to confirm resolution." |
| 420 | ``` |
| 421 | |
| 422 | ### Connection Problems |
| 423 | |
| 424 | <Check> |
| 425 | **Verification Steps:** - Snyk MCP is installed via [Continue |
| 426 | Hub](https://hub.continue.dev/snyk/snyk-mcp) - Secure-at-Inception rules are |
| 427 | [enabled](https://hub.continue.dev/snyk/secure-at-inception) - Authentication |
| 428 | completed successfully - Project folder has been trusted |
| 429 | </Check> |
| 430 | |
| 431 | ## What You've Built |
| 432 | |
| 433 | After completing this guide, you have a complete **AI-powered security system** that: |
| 434 | |
| 435 | โ
Uses natural language โ Simple prompts instead of complex CLI commands |
| 436 | โ
Fixes automatically โ AI suggests and validates security fixes |
| 437 | โ
Runs continuously โ Automated scanning in CI/CD pipelines |
| 438 | โ
Enforces guardrails โ Security rules prevent vulnerable code from shipping |
| 439 | |
| 440 | <Card title="Continuous AI" icon="rocket"> |
| 441 | Your security workflow now operates at **[Level 2 Continuous |
| 442 | AI](https://blog.continue.dev/what-is-continuous-ai-a-developers-guide/)** - |
| 443 | AI handles routine security scanning and remediation with human oversight |
| 444 | through review and approval of fixes. |
| 445 | </Card> |
| 446 | |
| 447 | ## Next Steps |
| 448 | |
| 449 | 1. **Run your first scan** - Try the [SAST](https://snyk.io/learn/application-security/sast/) prompt on your current project |
| 450 | 2. **Review findings** - Analyze the security report and implement fixes |
| 451 | 3. **Set up CI pipeline** - Add the GitHub Actions workflow to your repo |
| 452 | 4. **Customize rules** - Add project-specific security policies |
| 453 | 5. **Monitor trends** - Track [vulnerability](https://snyk.io/learn/security-vulnerability/) reduction over time |
| 454 | |
| 455 | ## Additional Resources |
| 456 | |
| 457 | <CardGroup cols={2}> |
| 458 | <Card title="Snyk Documentation" icon="book" href="https://docs.snyk.io"> |
| 459 | Complete Snyk platform documentation |
| 460 | </Card> |
| 461 | <Card title="Continue Hub" icon="plug" href="https://hub.continue.dev"> |
| 462 | Explore more MCP integrations and agents |
| 463 | </Card> |
| 464 | <Card |
| 465 | title="Security Best Practices" |
| 466 | icon="shield" |
| 467 | href="https://snyk.io/learn" |
| 468 | > |
| 469 | Learn about secure coding practices |
| 470 | </Card> |
| 471 | <Card |
| 472 | title="MCP Concepts" |
| 473 | icon="puzzle-piece" |
| 474 | href="https://docs.snyk.io/integrations/developer-guardrails-for-agentic-workflows" |
| 475 | > |
| 476 | Understanding MCP architecture |
| 477 | </Card> |
| 478 | </CardGroup> |