Skip to content

add hooks for antigravity cli#5489

Open
DharunThota wants to merge 1 commit into
akto-api-security:masterfrom
DharunThota:feat/antigravity-cli-hooks
Open

add hooks for antigravity cli#5489
DharunThota wants to merge 1 commit into
akto-api-security:masterfrom
DharunThota:feat/antigravity-cli-hooks

Conversation

@DharunThota

Copy link
Copy Markdown
Contributor
  • hooks do not support blocking yet

Copilot AI review requested due to automatic review settings June 23, 2026 08:15

Copilot AI 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.

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.json to register Antigravity hook commands.
  • Extend shared/akto_ingestion_utility.py with 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]}")
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