Skip to content

feat(mcp): serve role-scoped tool sets over authenticated HTTP #3219

Closed

Description

@dan-petty

Problem or Motivation

The jobs of the roadmap pipeline (planning, implementation, review) get their tools from code that runs inside the job container. The planner has nine read-only Python tools (StageTools), and the runner image carries only git, gh, curl, jq, promtool and the devops venv. A job that needs another tool (a scanner, kubectl, helm, a web search, a cluster read) has to have the tool built into its image, or it cannot use it. The owner wants MCP tool sets that depend on the job that runs, such as planning or implementation, so a job can use those functions without staging them in its own container.

devops mcp serve cannot serve this today. I read main (24ef67ac):

  • It has two transports, stdio and sse. There is no streamable HTTP.
  • A non-loopback bind is refused unless --allow-remote is given, and the server has no authentication. The only middleware are DomainGateMiddleware (advertises the eager domains) and ArgumentContractMiddleware.
  • The set of advertised tools is process-wide state (_HYDRATED_DOMAINS in ai/mcp/server.py), so one caller's hydrate_tool_domain changes what every caller sees. It cannot give two jobs two different tool sets.
  • 141 tools are exposed, and 44 of them are not read-only (gh issues create/edit/close, k8s deploy-stack, k8s teardown-stack, argo fleet sync, docker sign, among others).

Proposed Solution & Architectural Design

  • Role-scoped tool sets. Name the sets planning, implementation, review and ops. Each is a list of tools from CONST_MCP_EXPOSURE_TABLE, with the read_only flag deciding what a role may hold. planning and review hold read-only tools only. ops is the only set with the mutating tools, and no job role gets it. The set is chosen per connection and not per process, for example one mounted path for each role (/planning, /implementation), so two jobs never share state.
  • Authentication. A request carries the projected ServiceAccount token of the calling pod (an audience set for the MCP server). The server checks it with the Kubernetes TokenReview API, and maps the ServiceAccount and the Job labels to a role. No shared secret is stored, and a token cannot be reused for another role.
  • Transport. Add streamable HTTP next to stdio and sse. sse keeps its loopback rule. The remote transport refuses to start without an auth setting.
  • Keep workspace tools in the job. A tool that reads or edits the job's checkout (the planner's read_file, search_code, repo_map, the implement step's edit and command tools) must stay in the job, because the files are in the job's container. Moving those tools to a server would need the repository there, and adds a network hop to each call. Only tools that do not depend on the job's files move: scanners, cluster reads, documentation and web search, GitHub reads.
  • Audit and limits. Each call is logged with the role and the Job name, has a timeout from the exposure table, and counts against the job's tool-call limit.

Open questions for the refine step: whether FastMCP's mount or its auth providers cover the per-connection role and the TokenReview check, or this needs custom middleware; whether the roles should be tags on the exposure table or a separate table; and how a tool that needs a binary (kubectl) runs on the server, which is the manifest issue.

Target Subsystem

src/devops_cli/ai/mcp/server.py, src/devops_cli/commands/mcp.py, src/devops_cli/config/constants.py (CONST_MCP_EXPOSURE_TABLE), SECURITY.md (rule 11 on MCP tool inputs).

Existing Tool Considered

FastMCP supports authentication providers, server composition (mount), and the streamable HTTP transport, so most of the work should use it. The Kubernetes TokenReview API checks a ServiceAccount token with no secret. Cost to build: about 200k tokens and 10 hours. To keep: the role table, which changes when a tool is added. This adds a network listener, so a person must approve the design before it is built.

Related: the issues for the MCP deployment and for the client in the jobs; #3204 (scaffold, which adds a command to the MCP lists); #3066.

Activity

  1. dan-petty commented on Nov 2, 2026

    @dan-petty
    OwnerAuthor

    Design notes from the owner's questions, for the refine step. They are proposals, not decisions.

    1. Put LiteLLM in front of the MCP server. The cluster runs LiteLLM Proxy (k8s/llm/gateway/deployment.yaml, image ghcr.io/berriai/litellm:v1.103.0), and the gateway config has no MCP section today. From the LiteLLM documentation as I know it (not checked against v1.103.0), the proxy has an MCP gateway: MCP servers are listed in its config, a virtual key can be limited to some servers or tools, and the proxy has budgets and logs for each key. If that holds in the pinned version, the layers would be:

    • caller to LiteLLM: a virtual key per Job, minted by the Service with a short life, a budget and an allowed list of MCP servers and tools (the role);
    • LiteLLM to the MCP server: the MCP server's NetworkPolicy admits only LiteLLM, and the server checks the identity of LiteLLM;
    • MCP server to the systems it calls: the credential of item 2.
      The refine step must check in the v1.103.0 documentation: the endpoint and transport, the per-key tool list, and how a client passes an upstream credential. LiteLLM keys are not Kubernetes identities, so the server cannot use TokenReview for a caller that comes through LiteLLM.

    2. No secret as a tool parameter. The model writes the arguments of a tool call, so a secret in a parameter passes through the model context. It would reach the prompt, the provider, the LLM cache, the run trace (RunTrace, and the trace comment planned in #3032), and the model could send it to another tool. SECURITY.md rule 11 already treats a host or URL given by a model as untrusted. Carry the credential outside the model's view instead:

    • the harness sets it as a header on the MCP connection (the pydantic-ai MCP client takes headers; LiteLLM can pass a header on to the upstream server, to verify), never in the tool schema;
    • the server reads it from the request, uses it for the downstream call, masks it in logs, and never returns it;
    • the credential is short-lived and carries its own permissions: a GitHub App installation token limited to the repository and the rights of the job, a Kubernetes ServiceAccount with its own Role, a LiteLLM key with a list of tools. The permission is then in the credential, and not in the tool, which is the owner's aim.
    • If a client cannot set headers, the tool takes an opaque credential_ref that the server resolves from a secret store (Vault is already integrated). It never takes the value.

    These two items are separate: who may call a tool (authentication and role), and as whom the tool acts on the systems it calls (the delegated credential).


    Generated by Claude Code

  2. dan-petty commented on Nov 2, 2026

    @dan-petty
    OwnerAuthor

    Decisions recorded from the owner, 2026-11-02. They replace the TokenReview proposal in the body of this issue:

    1. Entry point: LiteLLM. Jobs reach the MCP server through the LiteLLM Proxy. The Service mints a short-lived virtual key for each Job, with a budget and an allowed list of MCP servers and tools (the role). The MCP server is reachable only from LiteLLM (NetworkPolicy), and checks the identity of LiteLLM with a bearer token that is a mounted secret. The server does not use TokenReview.
    2. No secret values as tool parameters. A credential is carried on the connection (a header set by the harness) or as an opaque credential_ref resolved on the server. A rule is added to SECURITY.md and a test guards the tool schemas (see the new issue for it).
    3. The ops role stays off. No job role gets the mutating tools.
    4. The client in the jobs (feat(roadmap): let a job call the tools of the MCP server #3221) waits for the cloud baseline (test(roadmap): score the stage pipeline with a cloud model first #3207).

    Work order for this issue: (a) the refine step checks LiteLLM v1.103.0 for the MCP gateway (endpoint and transport, per-key tool list, header passthrough) from the pinned image's source; (b) role-scoped tool sets per connection and a bearer-token check on the server, with the remote transport refusing to start without a token; (c) streamable HTTP. LiteLLM-specific configuration (the mcp_servers section, the key minting by the Service) belongs to the deployment issue #3220.


    Generated by Claude Code

  3. added
    type/feature
    scope/mcp
    status/new
    value/high
    effort/high
    on Nov 2, 2026
  4. devops-cli-service commented on Nov 2, 2026

    @devops-cli-service
    Contributor

    Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.

    • Type: type/feature. The feat prefix of the title gives the type.
    • Scope: scope/mcp. The (mcp) scope of the title gives the scope.
    • Priority: P2-Medium. It is a prerequisite for #3220 and #3221 but is not a security fix or a production outage.
    • Value: High. It is the server-side foundation that lets roadmap jobs use external tools without staging them in their images.
    • Effort: High. The body estimates about 200k tokens and 10 hours across transport, auth, role scoping, and audit.
    • Related: feat(k8s): deploy the MCP server for the roadmap jobs #3220, which asks for a different change. Both concern the MCP server for roadmap jobs, but the candidate builds the server code while #3220 adds the k8s deployment manifests for it.
  5. removed
    status/new
    on Nov 2, 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

    effort/highpriority/p2-mediumscope/mcptype/featurevalue/high

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions