Skip to content
Open
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
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@ 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 Gemini CLI, Cursor and Codex run
`secfoo mcp sync --agent <agent>` (or `secfoo mcp sync`) once. Antigravity and the
`api` agent cannot use MCP servers yet. 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
13 changes: 8 additions & 5 deletions docs/REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -986,9 +986,12 @@ 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 |
| `gemini`, `agent` (Cursor), `codex` | Run `secfoo mcp sync --agent <agent>` (or `secfoo mcp sync` to sync all installed agents) once to register persistently in that tool's own config |
| `agy` (Antigravity) | `agy 1.5.3` has an `agy mcp` subcommand, but secfoo does not yet automate syncing with agy's configuration |
| `copilot`, `opencode`, `droid`, `devin` | Not yet automated in `secfoo mcp sync` (planned for follow-up) |
| `api` | Not supported — direct API adapter has no tool loop |

Existing same-named servers are preserved and skipped to prevent overwriting user edits or credentials. When rotating API keys or tokens (such as `secfoo-memory`), remove the server entry from the agent's config or re-run sync after removing it.

```bash
secfoo mcp list # show what's configured
Expand All @@ -1012,8 +1015,8 @@ 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 `gemini`, Cursor (`agent`) or `codex`, run
`secfoo mcp sync --agent <agent>` (or `secfoo mcp sync`) once. 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
2 changes: 1 addition & 1 deletion docs/agents.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ brackets indicate optional arguments. All CLI processes run in `WORKDIR`.
| `agent` (Cursor) | Install via `curl https://cursor.com/install -fsS \| bash` ([docs](https://cursor.com/docs/cli/overview)). Authenticate with `agent login` or set `CURSOR_API_KEY` for non-interactive use (login and `CURSOR_API_KEY` confirmed in `agent --help` for `2026.08.11-e8db854` on 2026-11-21, macOS arm64; install command from the official docs). `agent [--model MODEL] -p PROMPT` |
| `agy` (Antigravity) | Install the `agy` CLI from the Antigravity distribution ([docs](https://antigravity.google)), then run `agy install` to add it to `PATH`. The CLI has no login subcommand: sign in through Antigravity before headless runs (checked against `agy --help` for `1.5.3` on 2026-11-21, macOS arm64). `agy --print PROMPT --print-timeout Ns` (`N` is the effective timeout in seconds). Headless mode denies tool calls requiring approval. |
| `gemini` | Install via `npm install -g @google/gemini-cli` ([docs](https://github.com/google-gemini/gemini-cli)). Authenticate interactively with `gemini` or set `GEMINI_API_KEY` for non-interactive use (verified `0.38.1` on 2026-11-21, macOS Darwin arm64). `gemini [--model MODEL] -p PROMPT --output-format json --skip-trust`. No `--yolo` write auto-approval is passed. |
| `codex` | Install via `npm install -g @openai/codex` ([docs](https://github.com/openai/codex)). Authenticate with `codex login` or set `OPENAI_API_KEY` for non-interactive use (verified `codex-cli 0.159.0` on 2026-11-21, macOS Darwin arm64). `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). |
| `codex` | Install via `npm install -g @openai/codex` ([docs](https://github.com/openai/codex)). Authenticate with `codex login` or set `OPENAI_API_KEY` for non-interactive use (verified `codex-cli 0.159.0` on 2026-11-21, macOS Darwin arm64; `codex-cli 0.172.0` on Windows). `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 are registered into `$CODEX_HOME/config.toml` (default `~/.codex/config.toml`) via `secfoo mcp sync --agent codex` (or `secfoo mcp sync`). |
| `copilot` | Install via `npm install -g @github/copilot` ([docs](https://docs.github.com/en/copilot/how-tos/use-copilot-agents/use-copilot-cli)). Authenticate by running `copilot` and using its `/login` command, or set `GH_TOKEN` / `GITHUB_TOKEN` (a fine-grained token with the Copilot Requests permission) for non-interactive use (checked against official docs on 2026-11-21). `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 via `curl -fsSL https://app.factory.ai/cli \| sh` ([docs](https://docs.factory.ai/cli/getting-started/overview)). Set `FACTORY_API_KEY` for non-interactive use or run `droid` to sign in interactively (checked against official docs on 2026-11-21, not on an installed CLI). `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` | Install via `brew install --cask devin-cli` ([docs](https://docs.devin.ai)). Authenticate beforehand with `devin auth login`; credential reuse for headless runs is unverified (install and login checked against official docs on 2026-11-21, not on an installed CLI). `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. |
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ dependencies = [
"markdown-it-py>=4.3.0",
"python-multipart>=0.0.32",
"tomli>=2.0; python_version < '3.11'",
"tomlkit>=0.13.0",
# Pure-Python text extraction for uploaded third-party vendor documents
# (docext.py) -- deliberately no system-level binaries (no poppler, no
# LibreOffice) so the Docker/Kubernetes image stays lean and doesn't
Expand Down
63 changes: 54 additions & 9 deletions src/secfoo/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -978,17 +978,31 @@ def serve_key_revoke(key_id: Annotated[int, typer.Argument(help="Key id from `se

@app.command()
def agents() -> None:
"""List known agent adapters and whether their CLI is installed."""
"""List known agent adapters, whether their CLI is installed, and their MCP support."""
table = Table(title="Agent adapters")
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'}[/]")
avail_style = "green" if available else "red"
mcp_support = mcp_module.CANONICAL_MCP_SUPPORT.get(agent_id)
mechanism = mcp_support.mechanism if mcp_support else "none"
if mechanism == "per-run":
mcp_style = "green"
elif mechanism == "sync":
mcp_style = "cyan"
else:
mcp_style = "dim"
table.add_row(
agent_id,
adapter.binary,
f"[{avail_style}]{'yes' if available else 'no'}[/]",
f"[{mcp_style}]{mechanism}[/]",
)
console.print(table)


Expand Down Expand Up @@ -2681,19 +2695,27 @@ def mcp_list() -> None:
console.print(table)
console.print(
"\n[bold]claude[/] picks these up automatically on every run (--mcp-config, "
"scoped to that run only).\nFor [bold]gemini[/] or [bold]agent[/] (Cursor), run "
"scoped to that run only).\nFor [bold]gemini[/], [bold]agent[/] (Cursor) or [bold]codex[/], run "
"[bold]secfoo mcp sync --agent <agent>[/] once to register them persistently."
)


@mcp_app.command(name="sync")
def mcp_sync(
agent: AgentId = typer.Option(..., "--agent", "-a", help="Which agent's MCP config to update."),
agent: AgentId | None = typer.Option(
None,
"--agent",
"-a",
help="Which agent's MCP config to update. If omitted, syncs all installed sync-supported agents.",
),
) -> 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 gemini, Cursor or Codex config.
claude doesn't need this -- it picks up ~/.secfoo/config.toml automatically on every run.
Other agents are not yet supported for automated sync.

Existing same-named servers are preserved and skipped to prevent overwriting user edits.
To update credentials after rotating keys (e.g. secfoo-memory), remove the server entry
from the agent's config or re-run sync after removing it.
"""
try:
cfg = load_config()
Expand All @@ -2706,6 +2728,29 @@ def mcp_sync(
console.print(f"No MCP servers configured in {CONFIG_PATH} -- nothing to sync.")
return

if agent is None:
targets = [
aid for aid in sorted(mcp_module.SYNC_SUPPORTED_AGENTS)
if get_adapter(aid).is_available()
]
if not targets:
console.print("[yellow]No sync-supported agent CLIs are installed on PATH.[/]")
return
any_failed = False
for aid in targets:
console.print(f"\n[bold]Syncing {aid}...[/]")
results = mcp_module.sync(aid, servers)
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

if agent.value == "claude":
console.print("[yellow]claude doesn't need syncing[/] -- it loads MCP servers automatically on every run.")
return
Expand Down
22 changes: 17 additions & 5 deletions src/secfoo/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from __future__ import annotations

import os
import time
from pathlib import Path

STORE_DIR = Path(os.environ.get("SECFOO_HOME", Path.home() / ".secfoo"))
Expand Down Expand Up @@ -40,19 +41,30 @@ def _make_private(directory: Path) -> None:


def write_private_text(path: Path, text: str) -> None:
"""Write a secret-bearing file that is never readable by others, not even
between creation and a later chmod (and tighten an existing file first)."""
path.parent.mkdir(parents=True, exist_ok=True)
fd = os.open(path, os.O_WRONLY | os.O_CREAT | os.O_TRUNC, 0o600)
"""Write a secret-bearing file atomically and symlink-safely so it is never
readable by others, not even between creation and replacement.

Resolves symlinks first so that dotfile managers (e.g. stow, chezmoi)
do not have their symlink replaced with a regular file, and writes via a
temporary file in the target directory before atomically replacing it.
"""
target = path.resolve()
target.parent.mkdir(parents=True, exist_ok=True)
tmp_path = target.with_name(f".{target.name}.tmp.{os.getpid()}.{time.time_ns()}")
fd = os.open(tmp_path, os.O_WRONLY | os.O_CREAT | os.O_EXCL, 0o600)
try:
if hasattr(os, "fchmod"): # POSIX; O_CREAT's mode does not apply to an existing file
# POSIX: O_CREAT's mode does not apply to an existing file
if hasattr(os, "fchmod"):
os.fchmod(fd, 0o600)
with os.fdopen(fd, "w", encoding="utf-8") as handle:
fd = -1
handle.write(text)
os.replace(tmp_path, target)
finally:
if fd != -1:
os.close(fd)
if tmp_path.exists():
tmp_path.unlink(missing_ok=True)


def run_dir(run_uuid: str) -> Path:
Expand Down
Loading
Loading