Skip to content

feat(mcp): add target_scope (local/remote/unknown) per tool configuration (#436) - #541

Open
TassioSales wants to merge 1 commit into
blitzcrieg1:masterfrom
TassioSales:feat/mcp-target-scope-436
Open

TassioSales wants to merge 1 commit into
blitzcrieg1:masterfrom
TassioSales:feat/mcp-target-scope-436

Conversation

@TassioSales

Copy link
Copy Markdown

Summary

Resolves #436.

Introduces an optional target scope per tool (local, remote, unknown) in the MCP audit proxy, keeping MCP transport (e.g. stdio) and target scope decoupled.

Key Changes

  1. Target Scope per Tool:
    • Supported values: local, remote, unknown.
    • Populated from operator configuration via CLI arguments (--scope tool=remote or --tool-scope) and environment variable AGENTMETRY_MCP_TOOL_SCOPES.
    • Legacy events and unconfigured tools read as unknown by default.
  2. Recording Host Activity Exclusions:
    • Added predicate acts_on_recording_host(event) to cleanly exclude tools executing on remote targets from activity statements on the recording host.
    • Original activity (qualified, input_hash, correlation_id) remains fully visible in the audit trail.
  3. Tests:
    • Synthetic fixtures covering a single stdio server with both a local tool (local_helper) and a remote tool (emp3r0r_cat).
    • Verified that legacy events without a scope field read as unknown.
    • Verified that remote tools are excluded from recording host activity while local tools are retained.
    • All 25 test cases in test_mcp_audit_proxy.py pass cleanly.

@blitzcrieg1 blitzcrieg1 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for taking #436. The parsing and the proxy-payload tests look fine, but as it stands the scope never reaches the trail:

  1. The ingest drops the field. build_call_payload adds tool.target_scope, but the receiver builds each event's tool block from a fixed set of keys (apps/orchestrator/agentmetry/core/audit/external.py, the event["tool"] = {...} block), so target_scope is discarded on arrival. Please carry it through canonicalization, document it in docs/agentmetry-event-schema.md as an additive field, and add a test that sends a proxy payload through ingest and finds tool.target_scope on the stored event.

  2. acts_on_recording_host isn't used. #436 is about remote-acting tools being labelled as activity on the recording host. Nothing calls the predicate yet, so no label changes. Please wire it where host activity is judged (the MITRE mapping and the host-scoped rules), with a test showing that a remote tool no longer produces a local-host technique.

  3. Minor: --scope, --tool-scope and AGENTMETRY_MCP_TOOL_SCOPES silently turn an unknown value into unknown. A warning on stderr would save someone a confused afternoon.

I'll approve the CI run so you get the full suite on this head.

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MCP tools that act on remote hosts are labelled as local activity, and an offensive MCP server is not recognised

2 participants