Skip to content

Pbeslin/parse mcp history - #1244

Merged
pbeslin-gg merged 7 commits into
mainfrom
pbeslin/parse-mcp-history
May 29, 2026
Merged

Pbeslin/parse mcp history#1244
pbeslin-gg merged 7 commits into
mainfrom
pbeslin/parse-mcp-history

Conversation

@pbeslin-gg

@pbeslin-gg pbeslin-gg commented May 18, 2026

Copy link
Copy Markdown
Collaborator

Context

New option in ggshield ai discover: --history allows parsing and sending MCP calls found in agent transcripts, in order to obtain insight on calls made before installing the hook.
⚠️ Requires py-gitguardian changes: GitGuardian/py-gitguardian#173

image

What has been done

  • ggshield ai discover takes a new optional flag option: --history. Not passing the flag results in the same behavior as before.
  • Passing the flag runs the history parsing in addition to the default behavior
  • Transcript files are parsed for all supported agents: Claude Code, Copilot, Cursor
    • Claude Code and VSCode Chat store them in .jsonl files
    • Cursor uses a database
  • Each agent implements its own way of iterating over the past events
  • All activities are sent to the GitGuardian API in batches (500). The GitGuardian API handles idempotency.

Validation

  1. Wire py-gitguardian correct version (feat: bulk mcp activity route py-gitguardian#173)
  2. Wire the local GitGuardian API with the new route (if not deployed yet)
  3. Run ggshield ai discover --history
  4. Go to the Agentic AI dashboard

PR check list

  • As much as possible, the changes include tests (unit and/or functional)
  • If the changes affect the end user (new feature, behavior change, bug fix) then the PR has a changelog entry (see doc/dev/getting-started.md). If the changes do not affect the end user, then the skip-changelog label has been added to the PR.

@pbeslin-gg
pbeslin-gg force-pushed the pbeslin/parse-mcp-history branch 4 times, most recently from 12eee7f to 6f506ee Compare May 20, 2026 14:57
@pbeslin-gg
pbeslin-gg requested review from paulpetit-gg-ext and xblanchot-gg and removed request for paulpetit-gg-ext May 21, 2026 08:20
@pbeslin-gg
pbeslin-gg force-pushed the pbeslin/parse-mcp-history branch 3 times, most recently from aa9da72 to 6d2c6b1 Compare May 26, 2026 11:58
@paulpetit-gg-ext
paulpetit-gg-ext force-pushed the pbeslin/parse-mcp-history branch from 6d2c6b1 to fc79150 Compare May 27, 2026 09:18
@pbeslin-gg
pbeslin-gg force-pushed the pbeslin/parse-mcp-history branch from fc79150 to 79bc9d8 Compare May 27, 2026 12:38
@pbeslin-gg
pbeslin-gg marked this pull request as ready for review May 27, 2026 13:24
@pbeslin-gg
pbeslin-gg requested a review from a team as a code owner May 27, 2026 13:24

@xblanchot-gg xblanchot-gg left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for the implem ! Handling all coding agents at once can be a pain ! :)

@pbeslin-gg
pbeslin-gg force-pushed the pbeslin/parse-mcp-history branch from 8a33074 to 403283c Compare May 29, 2026 07:56
@pbeslin-gg
pbeslin-gg force-pushed the pbeslin/parse-mcp-history branch from 403283c to f6f7354 Compare May 29, 2026 08:26
@codecov

codecov Bot commented May 29, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 85.13189% with 62 lines in your changes missing coverage. Please review.
✅ Project coverage is 93.29%. Comparing base (58dac51) to head (47b3e80).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
ggshield/verticals/ai/agents/cursor.py 79.09% 23 Missing ⚠️
ggshield/verticals/ai/agents/codex.py 81.03% 11 Missing ⚠️
ggshield/verticals/ai/agents/vscode.py 89.53% 9 Missing ⚠️
ggshield/verticals/ai/history.py 84.78% 7 Missing ⚠️
ggshield/verticals/ai/agents/claude_code.py 86.04% 6 Missing ⚠️
ggshield/verticals/ai/agents/copilot.py 91.66% 4 Missing ⚠️
ggshield/verticals/ai/models.py 80.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1244      +/-   ##
==========================================
- Coverage   93.63%   93.29%   -0.34%     
==========================================
  Files         183      184       +1     
  Lines        9980    10373     +393     
==========================================
+ Hits         9345     9678     +333     
- Misses        635      695      +60     
Flag Coverage Δ
unittests 93.29% <85.13%> (-0.34%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@pbeslin-gg
pbeslin-gg force-pushed the pbeslin/parse-mcp-history branch from f6f7354 to 47b3e80 Compare May 29, 2026 08:35
@pbeslin-gg
pbeslin-gg merged commit 7e9647f into main May 29, 2026
50 of 53 checks passed
@pbeslin-gg
pbeslin-gg deleted the pbeslin/parse-mcp-history branch May 29, 2026 11:32
@amascia-gg amascia-gg mentioned this pull request Jun 1, 2026
2 tasks
amascia-gg added a commit that referenced this pull request Jun 2, 2026
Extend the AI-agent history framework to ship per-event *usage metadata*
(not just MCP PreToolUse calls) to GitGuardian, powering usage dashboards.

- Per-agent sources (Claude, Codex, Cursor) walk transcripts/SQLite and, in a
  fail-closed `serialize()`, emit only an allow-list of safe structured fields
  (event type, tool name, model, timestamps, …). Free text — prompts, command
  strings, tool inputs/outputs, file contents — is never sent, so no secret or
  PII ever leaves the machine.
- Home paths are anonymised (`/Users/x` -> `~`); per-record size cap +
  byte-batching bound payloads.
- Base `ActivitySource.serialize` raises by default: a source can never
  accidentally ship raw content.
- Renamed the package raw_history -> agent_activity (it is metadata, not raw).
- Review fixes to the original framework: `GGClient` typing + `Detail` error
  handling in the orchestrator, and the home-path leak fix.
- Bump pygitguardian to the commit adding `send_agent_activity()`
  (GitGuardian/py-gitguardian#175); re-pin once that merges.

Builds on #1244 / #1257 (MCP history framework).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
amascia-gg added a commit that referenced this pull request Jun 2, 2026
Extend the AI-agent history framework to ship per-event *usage metadata*
(not just MCP PreToolUse calls) to GitGuardian, powering usage dashboards.

- Per-agent sources (Claude, Codex, Cursor) walk transcripts/SQLite and, in a
  fail-closed `serialize()`, emit only an allow-list of safe structured fields
  (event type, tool name, model, timestamps, …). Free text — prompts, command
  strings, tool inputs/outputs, file contents — is never sent, so no secret or
  PII ever leaves the machine.
- Home paths are anonymised (`/Users/x` -> `~`); per-record size cap +
  byte-batching bound payloads.
- Base `ActivitySource.serialize` raises by default: a source can never
  accidentally ship raw content.
- Renamed the package raw_history -> agent_activity (it is metadata, not raw).
- Review fixes to the original framework: `GGClient` typing + `Detail` error
  handling in the orchestrator, and the home-path leak fix.
- Bump pygitguardian to the commit adding `send_agent_activity()`
  (GitGuardian/py-gitguardian#175); re-pin once that merges.

Builds on #1244 / #1257 (MCP history framework).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
amascia-gg added a commit that referenced this pull request Jun 2, 2026
Extend the AI-agent history framework to ship per-event *usage metadata*
(not just MCP PreToolUse calls) to GitGuardian, powering usage dashboards.

- Per-agent sources (Claude, Codex, Cursor) walk transcripts/SQLite and, in a
  fail-closed `serialize()`, emit only an allow-list of safe structured fields
  (event type, tool name, model, timestamps, …). Free text — prompts, command
  strings, tool inputs/outputs, file contents — is never sent, so no secret or
  PII ever leaves the machine.
- Home paths are anonymised (`/Users/x` -> `~`); per-record size cap +
  byte-batching bound payloads.
- Base `ActivitySource.serialize` raises by default: a source can never
  accidentally ship raw content.
- Renamed the package raw_history -> agent_activity (it is metadata, not raw).
- Review fixes to the original framework: `GGClient` typing + `Detail` error
  handling in the orchestrator, and the home-path leak fix.
- Bump pygitguardian to the commit adding `send_agent_activity()`
  (GitGuardian/py-gitguardian#175); re-pin once that merges.

Builds on #1244 / #1257 (MCP history framework).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
amascia-gg added a commit that referenced this pull request Jun 2, 2026
Extend the AI-agent history framework to ship per-event *usage metadata*
(not just MCP PreToolUse calls) to GitGuardian, powering usage dashboards.

- Per-agent sources (Claude, Codex, Cursor) walk transcripts/SQLite and, in a
  fail-closed `serialize()`, emit only an allow-list of safe structured fields
  (event type, tool name, model, timestamps, …). Free text — prompts, command
  strings, tool inputs/outputs, file contents — is never sent, so no secret or
  PII ever leaves the machine.
- Home paths are anonymised (`/Users/x` -> `~`); per-record size cap +
  byte-batching bound payloads.
- Base `ActivitySource.serialize` raises by default: a source can never
  accidentally ship raw content.
- Renamed the package raw_history -> agent_activity (it is metadata, not raw).
- Review fixes to the original framework: `GGClient` typing + `Detail` error
  handling in the orchestrator, and the home-path leak fix.
- Bump pygitguardian to the commit adding `send_agent_activity()`
  (GitGuardian/py-gitguardian#175); re-pin once that merges.

Builds on #1244 / #1257 (MCP history framework).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
amascia-gg added a commit that referenced this pull request Jun 2, 2026
Extend the AI-agent history framework to ship per-event *usage metadata*
(not just MCP PreToolUse calls) to GitGuardian, powering usage dashboards.

- Per-agent sources (Claude, Codex, Cursor) walk transcripts/SQLite and, in a
  fail-closed `serialize()`, emit only an allow-list of safe structured fields
  (event type, tool name, model, timestamps, …). Free text — prompts, command
  strings, tool inputs/outputs, file contents — is never sent, so no secret or
  PII ever leaves the machine.
- Home paths are anonymised (`/Users/x` -> `~`); per-record size cap +
  byte-batching bound payloads.
- Base `ActivitySource.serialize` raises by default: a source can never
  accidentally ship raw content.
- Renamed the package raw_history -> agent_activity (it is metadata, not raw).
- Review fixes to the original framework: `GGClient` typing + `Detail` error
  handling in the orchestrator, and the home-path leak fix.
- Bump pygitguardian to the commit adding `send_agent_activity()`
  (GitGuardian/py-gitguardian#175); re-pin once that merges.

Builds on #1244 / #1257 (MCP history framework).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
amascia-gg added a commit that referenced this pull request Jun 2, 2026
…i discover --history`

Ship full AI-agent session activity (not just MCP calls) to a raw staging
table, keeping the client "dumb" and storing no detected secrets:

- ggshield ships the agent's RAW transcript lines / DB rows verbatim — the data
  shape never depends on the ggshield version (no per-agent field extraction).
- Before sending, each batch is scanned via the GitGuardian secret-scan API
  (multi_content_scan); detected secret spans are redacted client-side and home
  paths anonymised. Fail-closed: a batch that can't be scanned is dropped, never
  shipped.
- Per-record size cap + byte-batching; re-scan every run (offset-skip is a
  follow-up).
- Review fixes to the framework: GGClient typing + Detail handling in the
  orchestrator; POSIX source paths.
- Bumps pygitguardian to send_agent_activity (GitGuardian/py-gitguardian#175).

Aligns with the design doc's staging → canonical structure; the canonical typed
table + per-agent adapters are a follow-up MR. Builds on #1244 / #1257.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
amascia-gg added a commit that referenced this pull request Jun 2, 2026
…i discover --history`

Ship full AI-agent session activity (not just MCP calls) to a raw staging
table, keeping the client "dumb" and storing no detected secrets:

- ggshield ships the agent's RAW transcript lines / DB rows verbatim — the data
  shape never depends on the ggshield version (no per-agent field extraction).
- Before sending, each batch is scanned via the GitGuardian secret-scan API
  (multi_content_scan); detected secret spans are redacted client-side and home
  paths anonymised. Fail-closed: a batch that can't be scanned is dropped, never
  shipped.
- Per-record size cap + byte-batching; re-scan every run (offset-skip is a
  follow-up).
- Review fixes to the framework: GGClient typing + Detail handling in the
  orchestrator; POSIX source paths.
- Bumps pygitguardian to send_agent_activity (GitGuardian/py-gitguardian#175).

Aligns with the design doc's staging → canonical structure; the canonical typed
table + per-agent adapters are a follow-up MR. Builds on #1244 / #1257.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.

2 participants