Skip to content

MCP for the api agent: a tool loop so API-key runs can read Confluence, Jira, SharePoint and secfoo-memory too #123

Open

Description

@vsn411

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:

  1. MCP client in the api agent. Use the official mcp Python SDK to start/connect each server from effective_servers() (src/secfoo/mcp.py), list its tools, and expose them to LiteLLM as function tools (tools=[...] on litellm.completion). Add a tool-calling loop node to the graph (assess → tool → assess, LangGraph ToolNode or hand-rolled), bounded by a call budget (reuse MEMORY_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.
  2. 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's stderr.log and count tokens/cost from the full conversation, not just the first call.
  3. 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.
  4. 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.
  5. 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 --confluence URL leads to a tool call, the budget stops the loop, a write-capable tool is never exposed, and the cost sums every call.
  6. Docs: docs/agents.md (api row and the MCP support table in docs/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

  1. added
    enhancement
    help wanted
    hackathon
    difficulty: hard
    on Nov 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    difficulty: hardenhancementhackathonhelp wanted

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions