Skip to content

feat(mcp): the MCP inventory can reach the SIEM, when the operator asks - #213

Merged
blitzcrieg1 merged 1 commit into
masterfrom
feat/mcp-inventory-event
Oct 2, 2026
Merged

blitzcrieg1 merged 1 commit into
masterfrom
feat/mcp-inventory-event

Conversation

@blitzcrieg1

Copy link
Copy Markdown
Owner

Part 1 of #169. Leaves the issue open for part 2 (fingerprinting tools/list for servers nobody wrapped with the proxy).

Why

agentmetry mcp answers "what are the agents on this machine wired to", but only for whoever runs it, on that machine. Nothing reached the trail, so no SIEM could answer "which machines have this server" or "when did it first appear". That's the inventory question a fleet buyer asks first, and the enterprise Splunk fleet dashboard (agentmetry-enterprise) is built on this event.

What

AGENTMETRY_MCP_INVENTORY=1 (a Settings field, so it works from .env) makes the recorder emit an mcp_inventory event from the heartbeat loop:

  • once at startup (outcome: snapshot);
  • when the configured surface changes (outcome: changed);
  • once a day regardless (outcome: snapshot), so a dashboard over 24 hours sees every host.

It goes through the heartbeat's path: trail insert first, then sinks. It runs in its own try, so it can't stop the beat.

Not the heartbeat, on purpose

My first draft put the list in the heartbeat, and broke two tests that exist to prevent exactly that (test_the_mcp_digest_names_no_server, test_no_developer_content_reaches_the_beat). The heartbeat goes to every sink on every install and commits to the MCP surface by digest alone, so recording your own laptop never ships your tool inventory to a SOC. That property stays. Both tests pass, and a new test checks the heartbeat still names no server with the inventory turned on.

What a server entry carries (McpServer.wire_entry())

Key
agent, name, scope, transport as agentmetry mcp shows them; scope keeps only the project folder name
launcher npx, node, python...
package only for a fetch-and-run launcher (npx/uvx/...), where it's a public registry name
url_host the URL's host only. Named url_host so it never collides with the SIEM's own host field
findings codes: unpinned_fetch, auto_confirm, plaintext_http, no_command
fingerprint first 16 hex of the existing per-server fingerprint, which commits to everything

Withheld: arguments (tokens and home-directory paths), env keys and values, and the URL path and query (API keys). A changed argument still changes the fingerprint. test_no_argument_env_value_env_key_or_url_query_leaves_the_machine plants a token argument, a home path, an env key and value, and a URL query key, and checks none appears in the event. finding_codes() is checked against findings() so the two can't drift.

The list is capped at 100 servers, with server_count and truncated saying so.

Verification

  • pytest -q: 1419 passed, 1 skipped (15 new in test_mcp_inventory_event.py)
  • ruff check agentmetry tests: clean
  • ruleset fingerprint 15846a0915769d4a, unchanged

Docs: README "Running this across a team", .env.example (commented opt-in), CHANGELOG.

🤖 Generated with Claude Code

`agentmetry mcp` answered "what are the agents wired to" only for whoever
ran it, on that machine (#169, part 1). Nothing reached the trail, so no
SIEM could answer which machines have a server or when it appeared.

With AGENTMETRY_MCP_INVENTORY=1 the recorder now emits an `mcp_inventory`
event from the heartbeat loop: at startup, when the configured surface
changes (outcome `changed`), and daily (outcome `snapshot`), so a 24-hour
fleet view sees every host.

Off by default, and deliberately not in the heartbeat. A first draft put the
list there and broke two tests that exist to stop exactly that: the
heartbeat goes to every sink on every install and commits to the surface by
digest alone, so recording your own laptop never ships your tool inventory
to a SOC. Both pass, with the inventory on.

Each server leaves as McpServer.wire_entry(): agent, name, scope, transport,
launcher, the package name for a fetch-and-run launcher, the URL host as
`url_host` (never `host`, which every SIEM already owns), findings as codes,
and a fingerprint over everything. Arguments, env keys and values, and the
rest of the URL are withheld; a test plants five secrets and checks none
leaves. finding_codes() is checked against findings() so the two renderings
cannot drift.

Fingerprint unchanged (15846a0915769d4a).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@blitzcrieg1
blitzcrieg1 force-pushed the feat/mcp-inventory-event branch from 367d5ea to 7495508 Compare October 2, 2026 20:16
@blitzcrieg1
blitzcrieg1 merged commit 5dfe28d into master Oct 2, 2026
10 checks passed
@blitzcrieg1
blitzcrieg1 deleted the feat/mcp-inventory-event branch October 2, 2026 20:42
@github-actions github-actions Bot locked and limited conversation to collaborators Oct 2, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant