Skip to content

bug(mcp): a denied chat_with_agent / fan_out call is audited as a successful tool call #2807

Description

@webmixgamer

Summary

Every MCP tool is wrapped by withAudit (src/mcp-server/src/server.ts), which sets details.success by whether the tool threw (src/mcp-server/src/audit.ts). The checkAgentAccess denials in src/mcp-server/src/tools/chat.ts return a JSON string ({"error": "Access denied", "reason": …}) instead of throwing, so the audit row for a refused agent-to-agent call says success: true and carries no denial marker. An operator reading the audit log cannot tell a permitted call from a refused one.

Context

Found while building the J10 journey harness (#2349): its "the denial is observable" criterion holds for the caller (the tool result says why) but not for the operator. The harness asserts today that the row exists, and carries the denial marker as a strict=True xfail.

Acceptance Criteria

  • A checkAgentAccess denial in chat_with_agent, the dedicated chat_with_<slug> tools and fan_out produces an audit row with details.success == false (or an explicit denied: true plus the reason), without changing the JSON the caller receives — agents parse it
  • Flip condition for the J10 xfail: test_the_operator_can_see_that_a_call_was_refused passes and the marker is removed in the same PR

Technical Notes

Smallest shape: the deny branch records the audit outcome itself (success=false, reason) before returning, or throws an error the wrapper classifies while a thin catch preserves the caller-visible JSON.

Activity

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions