Skip to content

feat(examples): local redacting MCP gateway for OpenAI Agents SDK example (part 1 of #316) - #353

Draft
atrearyan wants to merge 1 commit into
google:mainfrom
atrearyan:feat/openai-agents-sdk-gateway
Draft

atrearyan wants to merge 1 commit into
google:mainfrom
atrearyan:feat/openai-agents-sdk-gateway

Conversation

@atrearyan

Copy link
Copy Markdown
Contributor

Part 1 of #316. Draft until the questions on the issue are answered.

What this adds

examples/openai-agents-sdk/ with a local MCP gateway that the OpenAI Agents SDK will reach over stdio (the agent itself comes in part 2). The gateway sits between the agent and two upstreams: the remote Chronicle MCP server (streamable HTTP) and the repo's GTI server (stdio).

  • Credentials stay local. It fetches a fresh ADC token for each request and sends x-goog-user-project. VT_APIKEY goes only to the GTI child process.
  • Read-only tools only.
    • The allowlist is 8 Chronicle and 4 GTI read tools.
    • Write and upload tools (create_rule, analyse_file, ...) are hidden and denied.
  • Tenant arguments are filled in locally, removed from the tool schemas, and replaced with labels in results.
  • Redaction (redaction.py).
    • Usernames, emails, display names, domain SIDs and IPs become typed placeholders ([[IP_EXT_001]], [[USER_001]], [[SVC_001]]).
    • Real values are restored only in outgoing tool arguments (escaped for UDM queries). Unknown or malformed placeholders are rejected before any upstream call.
    • Every result, including error text and tool definitions, is redacted and leak-checked, and is withheld on any failure.
  • Result status. Every result is labeled OK, EMPTY, NOT_FOUND, AUTH, QUOTA, UPSTREAM_ERROR, REDACTION_ERROR, UNRESOLVED_PLACEHOLDER, DENIED or SKIPPED, so a failed lookup is never reported as "no evidence".
  • GTI safeguards.
    • Internal IPs and usernames are never sent to VirusTotal.
    • Lookups stop after a quota error, with a per-run cap.
    • Repeated calls are cached, and identical concurrent calls are shared.
    • GTI's stderr goes to a private local log.
  • Robustness. An HTTP or credential failure fails one call, not the connection. Each call has a 120-second timeout.
  • --check preflight reports each misconfiguration with a named code.

Testing

  • 152 tests, run on Python 3.11, 3.12 and 3.14, with in-memory fake Chronicle and GTI servers and synthetic data only (documentation IP ranges, made-up names).
  • An egress canary test plants users, IPs and tenant IDs upstream and checks that none reach the agent.
  • A leak scan checks the example's own files for real IPs and credentials.
  • Mutation check: disabling each of 12 safeguards makes at least one test fail.
  • Checked against the real GTI server (tool listing only).
  • Not tested against a live Chronicle tenant.
cd examples/openai-agents-sdk
uv run --extra test python -m pytest tests -q

Known gaps (to be documented in the README)

  • A name that appears only in free text, before any user field reveals it, is not detected. Part 2 fetches the alert first to close most of this.
  • IPv4 written as one integer or in hex, and PTR names, are not handled.
  • Chronicle results are only capped by size; per-tool field trimming needs real response formats.

Next

Part 2: the agent (OpenAI Agents SDK, tracing and storage off), the code-written report with a coverage block, local --reveal, --demo with a scripted model. Part 3: README, diagram, and a path-filtered CI workflow.

… example

Part 1 of google#316. A local stdio MCP gateway that keeps Google credentials and real usernames and IPs on the analyst's machine. The agent and report follow in a later PR.
@atrearyan

Copy link
Copy Markdown
Contributor Author

Hi @dandye , I opened this as a draft so you can see the approach before I build the agent on top of it. The main design questions are in my comment on #316 (local SDK vs hosted Agents API, Python vs TypeScript, and whether redaction is in scope).

Early feedback on the gateway and redaction approach would help most. If the direction looks right, I'll add the agent and report in part 2.

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.

1 participant