Skip to content

feat(mcp): add secfoo mcp serve stdio server, single-source plugin builder, and server.json - #229

Open
SriRamkunamsetty wants to merge 1 commit into
secfoo-com:mainfrom
SriRamkunamsetty:feat/mcp-serve-foundation-224
Open

SriRamkunamsetty wants to merge 1 commit into
secfoo-com:mainfrom
SriRamkunamsetty:feat/mcp-serve-foundation-224

Conversation

@SriRamkunamsetty

Copy link
Copy Markdown
Contributor

Part of #224

Summary

  • Added stdio MCP server (src/secfoo/mcp_server.py) wired via secfoo mcp serve [--root PATH ...] exposing 7 tools (list_skills, submit_report,
    un_skill, list_findings, get_run, export_findings, cloud_status) and one MCP prompt per built-in skill from load_all_skills().
  • Enforced strict local-first defaults and key isolation: unconfigured or view-only keys (sfc_view_) never upload and never leave the machine; only ingest keys (sfc_ingest_ from SECFOO_CLOUD_API_KEY or ~/.secfoo/cloud.toml) upload via sync_run; secrets never appear in tool payloads or configs.
  • Enforced workspace root scoping (--root / Path.cwd()) and output contract validation (�alidate_report) before storing runs in SQLite.
  • Added scripts/build_plugins.py (--target all|claude|cursor, --check, --mcpb) to generate platform plugin skills from src/secfoo/skills/definitions/*.md without prompt duplication, plus official MCP Registry manifest server.json.

Verification

  • pytest -p no:langsmith -p no:hypothesis tests/test_mcp_server.py tests/test_plugins.py tests/test_docs_consistency.py -q -> 26 passed, 92% combined coverage (src/secfoo/mcp_server.py 90%, scripts/build_plugins.py 97%).
  • Live stdio MCP handshake (python -m secfoo.cli mcp serve --root .) -> initialized cleanly, enumerated 7 tools & 9 skill prompts.

uff check . & �andit -c .bandit -ll -r src/secfoo -q -> passed.

  • git merge-tree --write-tree HEAD upstream/main -> zero conflicts.

Comment thread src/secfoo/mcp_server.py
if col == "locations" and isinstance(val, str) and val.startswith("["):
try:
val = json.loads(val)
except json.JSONDecodeError:

@vsn411 vsn411 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, this is a strong foundation for #224. The workspace-root check, view keys never uploading, keys never appearing in tool output, and the --check drift test for generated skills are exactly what we wanted.

Before we merge (#230 and #231 are stacked on this, so they'll pick up the fixes):

  1. Failing test on all 4 platforms. test_mcp_serve_cli_help_and_root_forwarding looks for --root in Rich-formatted help, and the color codes split the string. Invoke with env={"NO_COLOR": "1", "TERM": "dumb"} (or strip ANSI) before asserting.
  2. Version pins. server.json (and the plugin/mcpb manifests in #230/#231) pin 0.3.2, which is the latest on PyPI and has no mcp serve, so the MCP Registry entry would install a version that can't start. Use the release that will ship this (0.3.3), and add a test that the manifest versions equal secfoo.__about__.__version__ without the .devN suffix, so they can't drift again.
  3. run_skill blocks the server, and the host agent can spend money with it. execute_runs is synchronous inside an async def, so the stdio server stops answering (pings included) for the length of a run. Please:
    • run it with anyio.to_thread.run_sync (or make the tool sync so FastMCP offloads it);
    • pass a timeout;
    • add a max_cost_usd argument with a conservative default, enforced the same way as the CLI's --max-cost. The host agent, which reads untrusted repo text, chooses when to call this tool.
  4. SECFOO_CLOUD_API_KEY only works for submit_report. Runs started by run_skill sync through runner._try_cloud_sync → cloud.load_cloud_config(), which reads only cloud.toml. Either teach cloud.load_cloud_config() the env var (one place, so the CLI, runner and MCP server agree), or drop the env var and document secfoo cloud login only. Then _read_raw_cloud_credentials can go, along with the use of the private cloud._portal_origin.

Small: submit_report doesn't store overall_rating for Responsible AI reports (the runner does). Copy rai_report.overall_rating into complete_run.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants