Skip to main content

tracegc-mcp

Model Context Protocol (MCP) server integration for TraceGC context compaction.

Usage Example

tracegc-mcp exposes three core MCP tools backed by TraceGC's deterministic compaction pipeline:

  • add_event(event: dict, session_id: str) — Appends a structured event to an active session trace.
  • compact(session_id: str) — Runs dead-branch sweeping, override pruning, deduplication, and cycle collapse for a session, returning the compacted prompt and metrics.
  • get_receipt(session_id: str, node_id: str) — Retrieves full, unpruned event payload receipts for any pruned node.
from tracegc_mcp import TraceGCMCPServer, add_event, compact, get_receipt

# 1. Initialize server instance
server = TraceGCMCPServer()

# 2. Add events to a session
server.add_event({
    "id": "e1",
    "type": "set_var",
    "timestamp": 100,
    "key": "database",
    "value": "postgres"
}, session_id="sess_100")

server.add_event({
    "id": "e2",
    "type": "set_var",
    "timestamp": 200,
    "key": "database",
    "value": "sqlite"
}, session_id="sess_100")

# 3. Compact the session trace
result = server.compact(session_id="sess_100")
print(result["prompt"])
# Output: "database = sqlite"

# 4. Retrieve receipt for the pruned event
receipt = server.get_receipt(session_id="sess_100", node_id="e1")
print(receipt["receipt"]["value"])
# Output: "postgres"

Module-level tool helpers (add_event, compact, get_receipt) are also provided for direct tool dispatching.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tracegc_mcp-0.1.0-py3-none-any.whl (3.0 kB view details)

Uploaded Python 3

File details

Details for the file tracegc_mcp-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: tracegc_mcp-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 3.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.14.2

File hashes

Hashes for tracegc_mcp-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 fde67c04362e50186863f17dcad7e0e39356af82cd2a93a217d6fc8bb5c482c7
MD5 13801fc0e883e56b564e1daf68037bf1
BLAKE2b-256 5f322b171c2f46ef12646869d0c40f02c6128586cfdd74bfed01d9920edd278e

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.0 This release

1 file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page