Repository navigation
Description
Problem: The README now promises "context, not just code": Confluence pages, Jira, SharePoint and other documentation reach the agent through MCP servers configured in ~/.secfoo/config.toml. That is true for --agent claude only. The api agent (src/secfoo/agents/api.py), which is the default in the GitHub Action and the only option for people without a coding-agent CLI, is a fixed LangGraph pipeline: collect_files → assess (one litellm.completion call) → request_fix. It has no tool loop, so --confluence URLs are listed in the brief and the model can only write "could not be reached" under Coverage Notes, and the secfoo-memory pattern tools are unavailable. In CI, where api is the norm, the context story does not exist.
Goal: secfoo run --agent api can call the MCP servers from [[mcp_servers]] (stdio and HTTP/SSE) as tools during the assessment, with the same read-only posture and call budget the Claude adapter has.
Build:
- MCP client in the
apiagent. Use the officialmcpPython SDK to start/connect each server fromeffective_servers()(src/secfoo/mcp.py), list its tools, and expose them to LiteLLM as function tools (tools=[...]onlitellm.completion). Add a tool-calling loop node to the graph (assess→tool→assess, LangGraphToolNodeor hand-rolled), bounded by a call budget (reuseMEMORY_GUIDANCE's{call_budget}idea, default 20) and a wall-clock timeout, after which the model is told the budget is spent and asked to finish the report. - Read-only by construction. Only expose tools whose MCP annotations say
readOnlyHint: true, plus an allowlist override per server in config (tools = ["confluence_get_page", ...]). Log every tool call (server, tool, argument summary, bytes returned) to the run'sstderr.logand count tokens/cost from the full conversation, not just the first call. - Context size control. Tool results count toward
--max-input-tokens; truncate oversized results with a visible marker and keep the budget check before every completion call, as today. - Coverage honesty. The brief's "Documentation & Confluence Coverage" section must reflect what was fetched: pass the tool-call log into the final prompt so the model cannot claim a page it never retrieved.
- Tests with a fake MCP server (stdio, a few lines of Python using the SDK's server API) and a fake LiteLLM: tools are discovered, a
--confluenceURL leads to a tool call, the budget stops the loop, a write-capable tool is never exposed, and the cost sums every call. - Docs:
docs/agents.md(apirow and the MCP support table indocs/REFERENCE.md) and the README's "Context, not just code" note about which agents support MCP.
Where to look: src/secfoo/agents/api.py (build_graph, _State, KEY_VARS), src/secfoo/mcp.py (effective_servers, _server_to_standard_shape), src/secfoo/skills/renderer.py (_confluence_section, MEMORY_GUIDANCE), src/secfoo/memory.py, tests/test_agents/test_api.py, pyproject.toml (add mcp to dependencies or the extra you decide on).
Done when: an api run with a configured MCP server calls it (shown in a test with the fake server and in a manual run against the Atlassian Rovo server with a screenshot of the coverage section); the write-tool exclusion and budget are tested; the README and REFERENCE tables say api supports MCP.
Activity
feat(api): MCP tool loop so API-key runs can read Confluence, Jira an…