add hooks for antigravity cli#5489
Open
DharunThota wants to merge 1 commit into
Open
Conversation
DharunThota
commented
Jun 23, 2026
Contributor
- hooks do not support blocking yet
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds an Antigravity CLI connector to the MCP Endpoint Shield hooks, wiring Antigravity hook events into Akto’s guardrails + ingestion pipeline by introducing new hook scripts/config and extending the shared ingestion utility’s connector maps.
Changes:
- Add Antigravity CLI hook scripts for PreInvocation / PostInvocation / PreToolUse / PostToolUse, plus wrapper scripts and example env.
- Introduce
hooks.jsonto register Antigravity hook commands. - Extend
shared/akto_ingestion_utility.pywith Antigravity connector tag, log dir, and session-field mapping.
Reviewed changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated 11 comments.
Show a summary per file
| File | Description |
|---|---|
| apps/mcp-endpoint-shield/shared/akto_ingestion_utility.py | Adds antigravity_cli connector tag/log dir and session field map integration. |
| apps/mcp-endpoint-shield/antigravity-cli-hooks/hooks.json | Registers Antigravity CLI hook event handlers to invoke Akto wrappers. |
| apps/mcp-endpoint-shield/antigravity-cli-hooks/akto-validate-pre-tool.py | PreToolUse guardrails + (attempted) blocking + step cache write. |
| apps/mcp-endpoint-shield/antigravity-cli-hooks/akto-validate-post-tool.py | PostToolUse ingestion, reading tool details from step cache. |
| apps/mcp-endpoint-shield/antigravity-cli-hooks/akto-validate-pre-invocation.py | PreInvocation prompt guardrails via transcript + deferred blocking state. |
| apps/mcp-endpoint-shield/antigravity-cli-hooks/akto-validate-post-invocation.py | PostInvocation deferred prompt enforcement + response guardrails + termination output. |
| apps/mcp-endpoint-shield/antigravity-cli-hooks/akto_machine_id.py | New machine/user identification helper for Antigravity hooks. |
| apps/mcp-endpoint-shield/antigravity-cli-hooks/akto-validate-*-wrapper.sh | Bash wrappers exporting required env vars for each hook script. |
| apps/mcp-endpoint-shield/antigravity-cli-hooks/akto-validate-*-wrapper.ps1 | PowerShell wrappers exporting required env vars for each hook script. |
| apps/mcp-endpoint-shield/antigravity-cli-hooks/.env.example | Example environment configuration for local testing. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+6
to
+12
| import os | ||
| import platform | ||
| import pwd | ||
| import subprocess | ||
| import uuid | ||
| import re | ||
| import socket |
Comment on lines
+66
to
+67
| def create_ssl_context() -> ssl.SSLContext: | ||
| return ssl._create_unverified_context() |
Comment on lines
+473
to
+475
| # Log full toolCall for MCP format investigation | ||
| tool_call = input_data.get("toolCall") or {} | ||
| logger.info(f"Full toolCall received: {json.dumps(tool_call)}") |
Comment on lines
+526
to
+528
| output = {"decision": "deny", "reason": block_reason} | ||
| logger.warning(f"BLOCKING tool request - Tool: {tool_name!r}, Reason: {block_reason}") | ||
| sys.stdout.write(json.dumps(output)) |
Comment on lines
+57
to
+58
| def create_ssl_context() -> ssl.SSLContext: | ||
| return ssl._create_unverified_context() |
Comment on lines
+56
to
+57
| def create_ssl_context() -> ssl.SSLContext: | ||
| return ssl._create_unverified_context() |
| sys.stdout.write("{}") | ||
| sys.exit(0) | ||
|
|
||
| logger.info(f"Raw PostToolUse input: {json.dumps(input_data)}") |
Comment on lines
+176
to
+178
| return { | ||
| "path": "/mcp" if is_mcp else f"/tool/{tool_name}", | ||
| "requestHeaders": json.dumps(req_hdr), |
Comment on lines
+74
to
+75
| def create_ssl_context() -> ssl.SSLContext: | ||
| return ssl._create_unverified_context() |
| sys.stdout.write(json.dumps(OUTPUT_ALLOW)) | ||
| sys.exit(0) | ||
|
|
||
| logger.info(f"Raw stdin (first 500 chars): {raw_input[:500]}") |
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.