Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,11 @@ headers = { Authorization = "Bearer ..." }

With `--agent claude` the configured servers are attached to each run
automatically and nothing else (your global Claude config is not touched and
the target's own `.mcp.json` is not loaded). For Gemini CLI and Cursor run
`secfoo mcp sync --agent <agent>` once. Codex, Antigravity and the `api`
agent cannot use MCP servers yet. Details in
the target's own `.mcp.json` is not loaded). For persistent agents (`gemini`,
`agent` (Cursor), `codex`, `copilot`, `opencode`, `droid`, `devin`), run
`secfoo mcp sync --agent <agent>` once (or `secfoo mcp sync` to sync all installed).
Antigravity (`agy`) and the `api` agent are not wired up for MCP (no mechanism is
documented for the agy CLI; not re-verified against a current release). Details in
[docs/REFERENCE.md](https://github.com/secfoo-com/secfoo/blob/main/docs/REFERENCE.md#configuration-secfooconfigtoml).

## A 30-second look at the dashboard
Expand Down
51 changes: 43 additions & 8 deletions docs/REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -961,18 +961,52 @@ your installed CLI version; an invalid ID is reported by that CLI.

How MCP servers reach each agent varies by what its CLI actually supports:

| Agent | Mechanism |
|---|---|
| `claude` | Automatic on every `secfoo run` (`--mcp-config`, scoped to that invocation only — your global Claude config is never touched). These are the only MCP servers loaded during a scan (`--strict-mcp-config`): servers from your global Claude config or from the target's `.mcp.json` are not started |
| `gemini`, `agent` (Cursor) | Run `secfoo mcp sync --agent <agent>` once to register persistently in that tool's own config |
| `codex` | Not wired up yet — Codex reads MCP servers from its own `~/.codex/config.toml` |
| `agy` (Antigravity) | Not supported yet — its CLI has no MCP configuration mechanism as of this writing |
| Agent | Mechanism | Guidance |
|---|---|---|
| `claude` | per-run | Automatic on every `secfoo run` (`--mcp-config`, scoped to that invocation only — your global Claude config is never touched). These are the only MCP servers loaded during a scan (`--strict-mcp-config`): servers from your global Claude config or from the target's `.mcp.json` are not started |
| `agent` | sync | Run `secfoo mcp sync --agent agent` once to register persistently in `~/.cursor/mcp.json` |
| `gemini` | sync | Run `secfoo mcp sync --agent gemini` once to register persistently via `gemini mcp add` |
| `codex` | sync | Run `secfoo mcp sync --agent codex` once to merge persistently into `~/.codex/config.toml` without clobbering other settings |
| `copilot` | sync | Run `secfoo mcp sync --agent copilot` once to register persistently in `~/.copilot/mcp-config.json` |
| `opencode` | sync | Run `secfoo mcp sync --agent opencode` once to register persistently in `~/.config/opencode/opencode.json` |
| `droid` | sync | Run `secfoo mcp sync --agent droid` once to register persistently in `~/.factory/mcp.json` |
| `devin` | sync | Run `secfoo mcp sync --agent devin` once to register persistently in `~/.config/devin/mcp_config.json` (%APPDATA%\devin\mcp_config.json on Windows) |
| `agy` | none | Not supported by secfoo: no MCP configuration mechanism is documented for the agy CLI, and this has not been re-verified against a current release |
| `api` | none | Not applicable — the API adapter calls model endpoints directly and has no tool loop |

`claude` is the only agent whose MCP servers are scoped to a single run. For the others, secfoo's adapters currently pass no MCP configuration per run, so secfoo writes those files at 0600 (for gemini, the Gemini CLI performs the write). Those servers then load for every use of that CLI, not just secfoo scans, and secrets in them are stored in plaintext at rest.

```bash
secfoo mcp list # show what's configured
secfoo mcp sync # register into all installed agents
secfoo mcp sync --agent gemini # register into gemini's own config
```

### Write-tool security guidance

MCP servers can expose both read-only operations (e.g. searching Confluence,
querying Jira issues) and state-mutating write tools (e.g. creating tickets,
editing documents, executing actions). Because secfoo performs read-only
assessments, write tools should never be executed during a review:

- **Claude:** Uses `--allowedTools`. Note that `--allowedTools mcp__<server>`
grants all tools exposed by that server (including any write tools on it).
To restrict write tools, use server-level read-only API tokens or fine-grained
per-tool allowlisting (`mcp__<server>__<tool>`) if supported by your Claude Code version.
- **Copilot:** Synchronizes servers with `tools: ["*"]` so all tools exposed by
the server are available. Since non-interactive Copilot runs require
`--allow-all-tools`, read-only behavior relies on secfoo's review prompt
instructions rather than an OS-level or CLI sandbox.
- **Codex:** Configured via `~/.codex/config.toml`. secfoo invokes Codex with
`--sandbox read-only`. For remote servers or tools outside the local sandbox,
use read-only credentials or server-side access controls.
- **OpenCode:** Permissions can be restricted via `permission` settings in
`opencode.json` or `OPENCODE_PERMISSION` (e.g. `{"permission": {"edit": "deny"}}`).
- **Principle of least privilege:** For remote MCP servers with authentication
(such as Atlassian Rovo, GitHub, or enterprise APIs), always issue read-only
API tokens or scoped credentials so write operations cannot execute even if
invoked.

## Pattern memory (`secfoo-memory`)

secfoo-memory is a hosted service of curated, generalized vulnerability
Expand All @@ -990,8 +1024,9 @@ secfoo memory logout

Once a key is saved, secfoo registers `secfoo-memory` as a default MCP
server. `secfoo mcp list` shows it next to your own servers. `claude` picks
it up on every run. For `gemini` or Cursor (`agent`), run
`secfoo mcp sync --agent <agent>` once. The `api` agent has no tool loop,
it up on every run. For persistent agents (`gemini`, `agent`, `codex`, `copilot`,
`opencode`, `droid`, `devin`), run `secfoo mcp sync --agent <agent>` once (or
`secfoo mcp sync` to sync all installed). The `api` agent has no tool loop,
so memory doesn't apply to it. When memory is on, the prompt tells the
agent when to use the three tools (`lookup_patterns`, `get_remediation`,
`check_false_positive`) and how to phrase a query.
Expand Down
19 changes: 10 additions & 9 deletions docs/agents.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,16 @@ brackets indicate optional arguments. All CLI processes run in `WORKDIR`.

| `--agent` | Setup and command |
| --- | --- |
| `claude` | Install command unverified; subscription login is supported. `claude [--model MODEL] -p --output-format json --allowedTools TOOLS --permission-mode default --setting-sources user --strict-mcp-config --no-session-persistence [--mcp-config PATH]` (prompt on stdin). `TOOLS` starts with `Read,Grep,Glob,Bash(git log:*),Bash(git diff:*)` and includes configured MCP servers when present. The tool grant is read-only, not an OS sandbox. |
| `agent` (Cursor) | Install and authentication commands unverified. `agent [--model MODEL] -p PROMPT` |
| `agy` (Antigravity) | Install and authentication commands unverified. `agy --print PROMPT --print-timeout Ns` (`N` is the effective timeout in seconds). Headless mode denies tool calls requiring approval. |
| `gemini` | Install and authentication commands unverified. `gemini [--model MODEL] -p PROMPT --output-format json --skip-trust`. No `--yolo` write auto-approval is passed. |
| `codex` | Install and authentication commands unverified. `codex exec [--model MODEL] --sandbox read-only [-c windows.sandbox="unelevated"] --skip-git-repo-check --ephemeral --color never --cd WORKDIR -` (prompt on stdin; `-c` is Windows-only). |
| `copilot` | The adapter identifies the npm package as `@github/copilot`; install and authentication commands are unverified. `copilot [--model MODEL] --output-format json --allow-all-tools` (prompt on stdin). Tools, including writes, are auto-approved: read-only behavior relies on review instructions, not a sandbox. |
| `droid` | Install command unverified. Set `FACTORY_API_KEY` for noninteractive use. `droid exec [-m MODEL] --output-format json --cwd WORKDIR -- PROMPT`. Droid defaults to read-only; a full authenticated secfoo run was not verified in the adapter. |
| `devin` | The adapter identifies the official Homebrew cask as `devin-cli`; install command unverified. Authenticate beforehand with `devin auth login`; credential reuse for headless runs is unverified. `devin -p PROMPT --respect-workspace-trust false --permission-mode auto`. The combined command and an authenticated end-to-end run are unverified; `auto` is documented by the CLI as approving read-only tools. |
| `api` | No agent binary is invoked. `litellm` and `langgraph` are installed with secfoo; if importing them fails, reinstall secfoo the way you installed it (`pipx reinstall secfoo` or `pip install --force-reinstall secfoo`). Set `OPENAI_API_KEY`, `ANTHROPIC_API_KEY`, or `GEMINI_API_KEY`. Source files are included in the API prompt. Model selection uses the configured model, then `SECFOO_API_MODEL`, then `openai/gpt-4.1-mini`. |
| `claude` | Install command unverified; subscription login is supported. `claude [--model MODEL] -p --output-format json --allowedTools TOOLS --permission-mode default --setting-sources user --strict-mcp-config --no-session-persistence [--mcp-config PATH]` (prompt on stdin). `TOOLS` starts with `Read,Grep,Glob,Bash(git log:*),Bash(git diff:*)` and includes configured MCP servers when present. MCP servers loaded automatically via `--mcp-config` on every run. The tool grant is read-only, not an OS sandbox. |
| `agent` (Cursor) | Install and authentication commands unverified. `agent [--model MODEL] -p PROMPT`. MCP servers registered via `secfoo mcp sync --agent agent` (`~/.cursor/mcp.json`). |
| `agy` (Antigravity) | Install and authentication commands unverified. `agy --print PROMPT --print-timeout Ns` (`N` is the effective timeout in seconds). Headless mode denies tool calls requiring approval. secfoo does not configure MCP for agy: none is documented for its CLI; not re-verified against a current release. |
| `gemini` | Install and authentication commands unverified. `gemini [--model MODEL] -p PROMPT --output-format json --skip-trust`. No `--yolo` write auto-approval is passed. MCP servers registered via `secfoo mcp sync --agent gemini`. |
| `codex` | Install and authentication commands unverified. `codex exec [--model MODEL] --sandbox read-only [-c windows.sandbox="unelevated"] --skip-git-repo-check --ephemeral --color never --cd WORKDIR -` (prompt on stdin; `-c` is Windows-only). MCP servers merged via `secfoo mcp sync --agent codex` (`~/.codex/config.toml`). |
| `copilot` | The adapter identifies the npm package as `@github/copilot`; install and authentication commands are unverified. `copilot [--model MODEL] --output-format json --allow-all-tools` (prompt on stdin). Tools, including writes, are auto-approved: read-only behavior relies on review instructions, not a sandbox. MCP servers registered via `secfoo mcp sync --agent copilot` (`~/.copilot/mcp-config.json`). |
| `opencode` | Install command unverified. `opencode run --pure --format json --dir WORKDIR [-m MODEL]` (prompt on stdin). Read-only permissions set via `OPENCODE_PERMISSION`. MCP servers registered via `secfoo mcp sync --agent opencode` (`~/.config/opencode/opencode.json`). |
| `droid` | Install command unverified. Set `FACTORY_API_KEY` for noninteractive use. `droid exec [-m MODEL] --output-format json --cwd WORKDIR -- PROMPT`. Droid defaults to read-only; a full authenticated secfoo run was not verified in the adapter. MCP servers registered via `secfoo mcp sync --agent droid` (`~/.factory/mcp.json`). |
| `devin` | The adapter identifies the official Homebrew cask as `devin-cli`; install command unverified. Authenticate beforehand with `devin auth login`; credential reuse for headless runs is unverified. `devin -p PROMPT --respect-workspace-trust false --permission-mode auto`. The combined command and an authenticated end-to-end run are unverified; `auto` is documented by the CLI as approving read-only tools. MCP servers registered via `secfoo mcp sync --agent devin` (`~/.config/devin/mcp_config.json` or `%APPDATA%\devin\mcp_config.json`). |
| `api` | No agent binary is invoked. `litellm` and `langgraph` are installed with secfoo; if importing them fails, reinstall secfoo the way you installed it (`pipx reinstall secfoo` or `pip install --force-reinstall secfoo`). Set `OPENAI_API_KEY`, `ANTHROPIC_API_KEY`, or `GEMINI_API_KEY`. Source files are included in the API prompt. Model selection uses the configured model, then `SECFOO_API_MODEL`, then `openai/gpt-4.1-mini`. No MCP support; direct model API without tool loop. |

`agy` and `devin` do not support adapter model selection; secfoo warns and
ignores a requested model. Other CLI model flags are shown above.
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ dependencies = [
"python-pptx>=1.0.2",
"langgraph>=1.2.21",
"litellm>=1.109.1",
"tomlkit>=0.13.0",
]

[project.optional-dependencies]
Expand Down
68 changes: 51 additions & 17 deletions src/secfoo/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -982,12 +982,15 @@ def agents() -> None:
table.add_column("Agent ID")
table.add_column("Binary")
table.add_column("Available")
table.add_column("MCP")

for agent_id in ADAPTERS:
adapter = get_adapter(agent_id)
available = adapter.is_available()
style = "green" if available else "red"
table.add_row(agent_id, adapter.binary, f"[{style}]{'yes' if available else 'no'}[/]")
mcp_info = mcp_module.CANONICAL_MCP_SUPPORT.get(agent_id)
mcp_val = mcp_info.mechanism if mcp_info else "none"
table.add_row(agent_id, adapter.binary, f"[{style}]{'yes' if available else 'no'}[/]", mcp_val)
console.print(table)


Expand Down Expand Up @@ -2646,12 +2649,15 @@ def mcp_list() -> None:

@mcp_app.command(name="sync")
def mcp_sync(
agent: AgentId = typer.Option(..., "--agent", "-a", help="Which agent's MCP config to update."),
agent: Annotated[
AgentId | None,
typer.Option("--agent", "-a", help="Which agent's MCP config to update."),
] = None,
) -> None:
"""Register configured MCP servers persistently into gemini's or Cursor's own
config. claude doesn't need this -- it picks up ~/.secfoo/config.toml
automatically on every run. agy isn't supported (its CLI has no MCP
configuration mechanism yet).
"""Register configured MCP servers persistently into an agent's own config.
claude doesn't need this -- it picks up ~/.secfoo/config.toml
automatically on every run. When --agent is omitted, syncs all available
agents on PATH.
"""
try:
cfg = load_config()
Expand All @@ -2664,22 +2670,50 @@ def mcp_sync(
console.print(f"No MCP servers configured in {CONFIG_PATH} -- nothing to sync.")
return

if agent.value == "claude":
console.print("[yellow]claude doesn't need syncing[/] -- it loads MCP servers automatically on every run.")
if agent is not None:
if agent.value == "claude":
console.print("[yellow]claude doesn't need syncing[/] -- it loads MCP servers automatically on every run.")
return

try:
results = mcp_module.sync(agent.value, servers)
except ValueError as exc:
err_console.print(f"[red]Error:[/] {exc}")
raise typer.Exit(code=1) from None

any_failed = False
for result in results:
style = "green" if result.ok else "red"
console.print(f" [{style}]{'ok' if result.ok else 'failed'}[/] {result.server_name}: {result.message}")
if not result.ok:
any_failed = True
if any_failed:
raise typer.Exit(code=1)
return

try:
results = mcp_module.sync(agent.value, servers)
except ValueError as exc:
err_console.print(f"[red]Error:[/] {exc}")
raise typer.Exit(code=1) from None
installed_targets = [
aid for aid in sorted(mcp_module.SYNC_SUPPORTED_AGENTS)
if get_adapter(aid).is_available()
]
if not installed_targets:
console.print("No sync-supported agent CLIs installed on PATH -- nothing to sync.")
return

any_failed = False
for result in results:
style = "green" if result.ok else "red"
console.print(f" [{style}]{'ok' if result.ok else 'failed'}[/] {result.server_name}: {result.message}")
if not result.ok:
for aid in installed_targets:
console.print(f"[bold]{aid}:[/]")
try:
results = mcp_module.sync(aid, servers)
except ValueError as exc:
err_console.print(f" [red]Error:[/] {exc}")
any_failed = True
continue
for result in results:
style = "green" if result.ok else "red"
console.print(f" [{style}]{'ok' if result.ok else 'failed'}[/] {result.server_name}: {result.message}")
if not result.ok:
any_failed = True

if any_failed:
raise typer.Exit(code=1)

Expand Down
Loading