Skip to content

Commit b114f8b

Browse files
committed
CM-49113 - Add Cycode MCP (Model Context Protocol)
1 parent 9a90843 commit b114f8b

7 files changed

Lines changed: 992 additions & 11 deletions

File tree

README.md

Lines changed: 204 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,12 @@ This guide walks you through both installation and usage.
1616
2. [On Windows](#on-windows)
1717
2. [Install Pre-Commit Hook](#install-pre-commit-hook)
1818
3. [Cycode CLI Commands](#cycode-cli-commands)
19-
4. [Scan Command](#scan-command)
19+
4. [MCP Command](#mcp-command)
20+
1. [Starting the MCP Server](#starting-the-mcp-server)
21+
2. [Available Options](#available-options)
22+
3. [MCP Tools](#mcp-tools)
23+
4. [Usage Examples](#usage-examples)
24+
5. [Scan Command](#scan-command)
2025
1. [Running a Scan](#running-a-scan)
2126
1. [Options](#options)
2227
1. [Severity Threshold](#severity-option)
@@ -48,9 +53,9 @@ This guide walks you through both installation and usage.
4853
4. [Ignoring a Secret, IaC, or SCA Rule](#ignoring-a-secret-iac-sca-or-sast-rule)
4954
5. [Ignoring a Package](#ignoring-a-package)
5055
6. [Ignoring via a config file](#ignoring-via-a-config-file)
51-
5. [Report command](#report-command)
56+
6. [Report command](#report-command)
5257
1. [Generating SBOM Report](#generating-sbom-report)
53-
6. [Syntax Help](#syntax-help)
58+
7. [Syntax Help](#syntax-help)
5459

5560
# Prerequisites
5661

@@ -221,7 +226,7 @@ Perform the following steps to install the pre-commit hook:
221226
```yaml
222227
repos:
223228
- repo: https://github.com/cycodehq/cycode-cli
224-
rev: v3.0.0
229+
rev: v3.1.0
225230
hooks:
226231
- id: cycode
227232
stages:
@@ -233,7 +238,7 @@ Perform the following steps to install the pre-commit hook:
233238
```yaml
234239
repos:
235240
- repo: https://github.com/cycodehq/cycode-cli
236-
rev: v3.0.0
241+
rev: v3.1.0
237242
hooks:
238243
- id: cycode
239244
stages:
@@ -281,10 +286,204 @@ The following are the options and commands available with the Cycode CLI applica
281286
| [auth](#using-the-auth-command) | Authenticate your machine to associate the CLI with your Cycode account. |
282287
| [configure](#using-the-configure-command) | Initial command to configure your CLI client authentication. |
283288
| [ignore](#ignoring-scan-results) | Ignores a specific value, path or rule ID. |
289+
| [mcp](#mcp-command) | Start the Model Context Protocol (MCP) server to enable AI integration with Cycode scanning capabilities. |
284290
| [scan](#running-a-scan) | Scan the content for Secrets/IaC/SCA/SAST violations. You`ll need to specify which scan type to perform: commit-history/path/repository/etc. |
285291
| [report](#report-command) | Generate report. You`ll need to specify which report type to perform as SBOM. |
286292
| status | Show the CLI status and exit. |
287293

294+
# MCP Command
295+
296+
The Model Context Protocol (MCP) command allows you to start an MCP server that exposes Cycode's scanning capabilities to AI systems and applications. This enables AI models to interact with Cycode CLI tools through a standardized protocol.
297+
298+
> [!TIP]
299+
> For the best experience, install Cycode CLI globally on your system using `pip install cycode` or `brew install cycode`, then authenticate once with `cycode auth`. After global installation and authentication, you won't need to configure `CYCODE_CLIENT_ID` and `CYCODE_CLIENT_SECRET` environment variables in your MCP configuration files.
300+
301+
## Starting the MCP Server
302+
303+
To start the MCP server, use the following command:
304+
305+
```bash
306+
cycode mcp
307+
```
308+
309+
By default, this starts the server using the `stdio` transport, which is suitable for local integrations and AI applications that can spawn subprocess.
310+
311+
### Available Options
312+
313+
| Option | Description |
314+
|-------------------|--------------------------------------------------------------------------------------------|
315+
| `-t, --transport` | Transport type for the MCP server: `stdio`, `sse`, or `streamable-http` (default: `stdio`) |
316+
| `-H, --host` | Host address to bind the server (used only for non stdio transport) (default: `127.0.0.1`) |
317+
| `-p, --port` | Port number to bind the server (used only for non stdio transport) (default: `8000`) |
318+
| `--help` | Show help message and available options |
319+
320+
### MCP Tools
321+
322+
The MCP server provides the following tools that AI systems can use:
323+
324+
| Tool Name | Description |
325+
|----------------------|---------------------------------------------------------------------------------------------|
326+
| `cycode_secret_scan` | Scan files for hardcoded secrets |
327+
| `cycode_sca_scan` | Scan files for Software Composition Analysis (SCA) - vulnerabilities and license issues |
328+
| `cycode_iac_scan` | Scan files for Infrastructure as Code (IaC) misconfigurations |
329+
| `cycode_sast_scan` | Scan files for Static Application Security Testing (SAST) - code quality and security flaws |
330+
| `cycode_status` | Get Cycode CLI version, authentication status, and configuration information |
331+
332+
### Usage Examples
333+
334+
#### Basic Command Examples
335+
336+
Start the MCP server with default settings (stdio transport):
337+
```bash
338+
cycode mcp
339+
```
340+
341+
Start the MCP server with explicit stdio transport:
342+
```bash
343+
cycode mcp -t stdio
344+
```
345+
346+
Start the MCP server with Server-Sent Events (SSE) transport:
347+
```bash
348+
cycode mcp -t sse -p 8080
349+
```
350+
351+
Start the MCP server with streamable HTTP transport on custom host and port:
352+
```bash
353+
cycode mcp -t streamable-http -H 0.0.0.0 -p 9000
354+
```
355+
356+
Learn more about MCP Transport types in the [MCP Protocol Specification – Transports](https://modelcontextprotocol.io/specification/2025-03-26/basic/transports).
357+
358+
#### Configuration Examples
359+
360+
##### Using MCP with Cursor/Claude Desktop/etc (mcp.json)
361+
362+
> [!NOTE]
363+
> For EU Cycode environments, make sure to set the appropriate `CYCODE_API_URL` and `CYCODE_APP_URL` values in the environment variables (e.g., `https://api.eu.cycode.com` and `https://app.eu.cycode.com`).
364+
365+
For **stdio transport** (direct execution):
366+
```json
367+
{
368+
"mcpServers": {
369+
"cycode": {
370+
"command": "cycode",
371+
"args": ["mcp"],
372+
"env": {
373+
"CYCODE_CLIENT_ID": "your-cycode-id",
374+
"CYCODE_CLIENT_SECRET": "your-cycode-secret-key",
375+
"CYCODE_API_URL": "https://api.cycode.com",
376+
"CYCODE_APP_URL": "https://app.cycode.com"
377+
}
378+
}
379+
}
380+
}
381+
```
382+
383+
For **stdio transport** with `pipx` installation:
384+
```json
385+
{
386+
"mcpServers": {
387+
"cycode": {
388+
"command": "pipx",
389+
"args": ["run", "cycode", "mcp"],
390+
"env": {
391+
"CYCODE_CLIENT_ID": "your-cycode-id",
392+
"CYCODE_CLIENT_SECRET": "your-cycode-secret-key",
393+
"CYCODE_API_URL": "https://api.cycode.com",
394+
"CYCODE_APP_URL": "https://app.cycode.com"
395+
}
396+
}
397+
}
398+
}
399+
```
400+
401+
For **stdio transport** with `uvx` installation:
402+
```json
403+
{
404+
"mcpServers": {
405+
"cycode": {
406+
"command": "uvx",
407+
"args": ["cycode", "mcp"],
408+
"env": {
409+
"CYCODE_CLIENT_ID": "your-cycode-id",
410+
"CYCODE_CLIENT_SECRET": "your-cycode-secret-key",
411+
"CYCODE_API_URL": "https://api.cycode.com",
412+
"CYCODE_APP_URL": "https://app.cycode.com"
413+
}
414+
}
415+
}
416+
}
417+
```
418+
419+
For **SSE transport** (Server-Sent Events):
420+
```json
421+
{
422+
"mcpServers": {
423+
"cycode": {
424+
"url": "http://127.0.0.1:8000/sse"
425+
}
426+
}
427+
}
428+
```
429+
430+
For **SSE transport** on custom port:
431+
```json
432+
{
433+
"mcpServers": {
434+
"cycode": {
435+
"url": "http://127.0.0.1:8080/sse"
436+
}
437+
}
438+
}
439+
```
440+
441+
For **streamable HTTP transport**:
442+
```json
443+
{
444+
"mcpServers": {
445+
"cycode": {
446+
"url": "http://127.0.0.1:8000/mcp"
447+
}
448+
}
449+
}
450+
```
451+
452+
##### Running MCP Server in Background
453+
454+
For **SSE transport** (start server first, then configure client):
455+
```bash
456+
# Start the MCP server in background
457+
cycode mcp -t sse -p 8000 &
458+
459+
# Configure in mcp.json
460+
{
461+
"mcpServers": {
462+
"cycode": {
463+
"url": "http://127.0.0.1:8000/sse"
464+
}
465+
}
466+
}
467+
```
468+
469+
For **streamable HTTP transport**:
470+
```bash
471+
# Start the MCP server in background
472+
cycode mcp -t streamable-http -H 0.0.0.0 -p 9000 &
473+
474+
# Configure in mcp.json
475+
{
476+
"mcpServers": {
477+
"cycode": {
478+
"url": "http://0.0.0.0:9000/mcp"
479+
}
480+
}
481+
}
482+
```
483+
484+
> [!NOTE]
485+
> The MCP server requires proper Cycode CLI authentication to function. Make sure you have authenticated using `cycode auth` or configured your credentials before starting the MCP server.
486+
288487
# Scan Command
289488

290489
## Running a Scan

cycode/cli/app.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import logging
2+
import sys
23
from typing import Annotated, Optional
34

45
import typer
@@ -9,6 +10,10 @@
910

1011
from cycode import __version__
1112
from cycode.cli.apps import ai_remediation, auth, configure, ignore, report, scan, status
13+
14+
if sys.version_info >= (3, 10):
15+
from cycode.cli.apps import mcp
16+
1217
from cycode.cli.cli_types import OutputTypeOption
1318
from cycode.cli.consts import CLI_CONTEXT_SETTINGS
1419
from cycode.cli.printers import ConsolePrinter
@@ -47,6 +52,8 @@
4752
app.add_typer(report.app)
4853
app.add_typer(scan.app)
4954
app.add_typer(status.app)
55+
if sys.version_info >= (3, 10):
56+
app.add_typer(mcp.app)
5057

5158

5259
def check_latest_version_on_close(ctx: typer.Context) -> None:

cycode/cli/apps/mcp/__init__.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import typer
2+
3+
from cycode.cli.apps.mcp.mcp_command import mcp_command
4+
5+
app = typer.Typer()
6+
7+
_mcp_command_docs = 'https://github.com/cycodehq/cycode-cli/blob/main/README.md#mcp-command'
8+
_mcp_command_epilog = f'[bold]Documentation:[/] [link={_mcp_command_docs}]{_mcp_command_docs}[/link]'
9+
10+
app.command(
11+
name='mcp',
12+
short_help='Start the Cycode MCP (Model Context Protocol) server.',
13+
epilog=_mcp_command_epilog,
14+
)(mcp_command)

0 commit comments

Comments
 (0)