Repository navigation
feat(mcp): the MCP inventory can reach the SIEM, when the operator asks - #213
Merged
Merged
Conversation
`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
force-pushed
the
feat/mcp-inventory-event
branch
from
October 2, 2026 20:16
367d5ea to
7495508
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part 1 of #169. Leaves the issue open for part 2 (fingerprinting
tools/listfor servers nobody wrapped with the proxy).Why
agentmetry mcpanswers "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(aSettingsfield, so it works from.env) makes the recorder emit anmcp_inventoryevent from the heartbeat loop:outcome: snapshot);outcome: changed);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())agent,name,scope,transportagentmetry mcpshows them; scope keeps only the project folder namelaunchernpx,node,python...packagenpx/uvx/...), where it's a public registry nameurl_hosturl_hostso it never collides with the SIEM's ownhostfieldfindingsunpinned_fetch,auto_confirm,plaintext_http,no_commandfingerprintWithheld: 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_machineplants 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 againstfindings()so the two can't drift.The list is capped at 100 servers, with
server_countandtruncatedsaying so.Verification
pytest -q: 1419 passed, 1 skipped (15 new intest_mcp_inventory_event.py)ruff check agentmetry tests: clean15846a0915769d4a, unchangedDocs: README "Running this across a team",
.env.example(commented opt-in), CHANGELOG.🤖 Generated with Claude Code