Skip to content

fix(mcp): fastmcp's debug log of tool calls never records argument values #899

Closed

Description

@dan-petty

Context & Rationale

Found in #862's review. FastMCP logs every tools/call's arguments at DEBUG (fastmcp/server/mixins/mcp_operations.py:211, 'Handler called: call_tool %s with %s'), including vault_set key_values and oidc_token, on a logger #862's redacting filter does not cover. At default levels it is silent (effective level INFO, and a sentinel probe found no record), but FASTMCP_LOG_LEVEL=DEBUG would write every secret argument to the log.

Scope & Deliverables

Strategic Alignment

Activity

  1. added
    type/security
    scope/mcp
    priority/p2-medium
    on Oct 1, 2026
  2. added this to the v0.2.30 milestone on Oct 8, 2026
  3. dan-petty commented on Oct 8, 2026

    @dan-petty
    OwnerAuthor

    Placed in v0.2.30 on 2026-10-08 at the owner's request ("Populate 10 security and ci issues into each v0.2.30, v0.2.31, and v0.2.32 milestone"). This is a person's placement. Release theme: P1 secret and sandbox-boundary fixes, the review tools lock, kube-linter finding identity and a faster gate. Position 2 of 10 in the release's planned merge order. Its board Status is set to Ready, so the release-start fill keeps it.

  4. dan-petty-bot commented on Oct 9, 2026

    @dan-petty-bot
    Collaborator

    What changed

    #1459, merged into release/v0.2.30 as 961c4d9.

    Summary

    • FastMCP logs every tools/call and prompts/get with its arguments at DEBUG on fastmcp.server.mixins.mcp_operations, so with FASTMCP_LOG_LEVEL=DEBUG a vault_set call wrote its key_values to stderr.
    • ArgumentValueLogFilter (src/devops_cli/ai/mcp/argument_contract.py) is attached to that logger only. It replaces each mapping argument with <redacted> and keeps the record, so the log still names the tool or prompt: Handler called: call_tool vault_set with <redacted>.
    • The whole mapping is replaced, because an undeclared parameter's name is the caller's own text too (fix(mcp): mcp tools refuse coerced arguments before they run, with prescriptive errors that never echo values #862 masks such names before echoing them).
    • fix(mcp): mcp tools refuse coerced arguments before they run, with prescriptive errors that never echo values #862's RejectedInputLogFilter on fastmcp.server.server is removed, along with CONST_FASTMCP_SERVER_LOGGER. Since fastmcp 4.0.11 (chore(deps): bump fastmcp from 3.4.7 to 4.0.11 #1184), FastMCP logs a refused call's error count and types, never the input, so that filter matched nothing. A mapping filter on that logger would have redacted the error summary, which is the only useful detail in that warning.
    • The fastmcp_log test fixture now captures every FastMCP logger at DEBUG. The new test_no_tool_argument_reaches_a_debug_record checks that the DEBUG record is written and holds no sentinel. Two stale test docstrings are corrected.
    • The task-862 file is updated to match. This PR adds changelog.d/899.md (Security) and the task-899 file.

    Closes #899

    7 file(s) changed.

    How it was verified

    Check runs at 1f51446:

    • Prune PR DevContainer Images: pass
    • CodeQL: pass
    • Static Analysis: pass
    • Analyze (actions): pass
    • Analyze (python): pass
    • Tests & Coverage: pass
    • DevContainer Image: skipping
    • Service Image: skipping
    • Dependency Freshness: skipping

    Acceptance Criteria of docs/agent/tasks/task-899-fastmcp-debug-log-redacts-tool-arguments.md:

    • With every FastMCP logger at DEBUG, a vault_set call carrying a sentinel value leaves no
      log record containing it. test_no_tool_argument_reaches_a_debug_record
      (tests/test_fastmcp_contracts.py) captures the fastmcp logger tree at DEBUG through
      fastmcp.Client(mcp), finds Handler called: call_tool vault_set, so the record was written,
      and finds no sentinel, with the handler run once. Before the filter the record read
      call_tool vault_set with {'path': 'secret/app', 'key_values': ['API_KEY=sentinel-4b1d']}.
    • The fastmcp_log fixture now captures every FastMCP logger at DEBUG, so
      test_a_strict_refusal_is_rendered_like_a_schema_refusal also holds the DEBUG argument record
      to no 4242, which it failed before the filter. test_no_rejected_input_reaches_a_log_record
      holds FastMCP's own refusal warning to no rejected input, with no filter on that logger.
    • uv run devops ci passes.
  5. added a commit that references this issue on Oct 9, 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

    priority/p2-mediumscope/mcptype/security

    Type

    No type

    Projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions