grok-diff-guardian
Parses unified diffs or runs git diff in a repository to map impacted Python AST symbols and evaluate deterministic security rules.
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
Grok Diff Guardian
AST-aware git diff analyzer, deterministic security gate, and MCP server built for xAI Grok Build and Grok API workflows.
grok-diff-guardian pairs fast, offline Python AST symbol mapping and static security checks with an optional xAI Grok API review pass (https://api.x.ai/v1) and a zero-dependency Model Context Protocol (MCP) stdio server so coding agents (such as Grok Build) can inspect impacted symbols and risk signals before opening or merging a PR.
Architecture
git diff ──▶ diff_parser ──▶ ast_analyzer (AST symbols + static rules)
│
┌────────────────────────┴────────────────────────┐
▼ ▼
CLI / CI gate MCP stdio server
(--json / --strict / --ai) (analyze_diff, inspect_ast_file,
│ scan_repo_risks)
▼
xAI Grok API (/v1/chat/completions)Related MCP server: ctxkit
Features
Zero runtime dependencies: Built entirely on the Python 3.10+ standard library.
AST-scoped impact mapping: Maps changed diff lines directly to enclosing Python classes, functions, and async methods (
SymbolSpan) with branch complexity hints.Deterministic static security gate: Detects dangerous sinks (
eval,exec,os.system,pickle.loads,subprocess(..., shell=True)), TLS bypass (verify=False), unsafeyaml.load(), SQL f-string interpolation, bareexcept:, and hardcoded credential patterns.Native xAI Grok API integration (
--ai): Sends a compact AST-enriched context payload and unified diff tohttps://api.x.ai/v1/chat/completions(grok-code-fast-1by default, configurable via--model/GROK_MODELandXAI_API_KEYorGROK_API_KEY).Stdio MCP server (
mcp): Implements JSON-RPC 2.0initialize,tools/list, andtools/callexposinganalyze_diff,inspect_ast_file, andscan_repo_risks.
Quickstart
Install locally
git clone https://github.com/Pedrohs1771/grok-diff-guardian.git
cd grok-diff-guardian
pip install -e ".[dev]"Review current repository diff (offline deterministic mode)
grok-diff-guardian review --repo .
grok-diff-guardian review --repo . --staged --json --strictEnable xAI Grok AI deep review
export XAI_API_KEY="your-xai-api-key"
grok-diff-guardian review --repo . --ai --model grok-code-fast-1Scan an entire directory
grok-diff-guardian scan src --strictMCP Server Configuration (Grok Build / Coding Agents)
Add grok-diff-guardian as a local stdio MCP server:
{
"mcpServers": {
"grok-diff-guardian": {
"command": "grok-diff-guardian",
"args": ["mcp", "--repo", "."]
}
}
}Exposed MCP tools:
analyze_diff— Parses a unified diff (or runsgit diff), maps impacted Python AST symbols, and evaluates static security rules.inspect_ast_file— Extracts class/function spans, parameter lists, and branch complexity for a Python file.scan_repo_risks— Recursively scans source files in a path for deterministic security/reliability findings.
Running Tests
pytest -vLicense
MIT — Built by @Pedrohs1771.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
IaC, CI and dependency security review for coding agents: local scan CLI plus hosted OAuth MCP.
Package, dependency, CI and config safety checks for coding agents. Pay per call.
Code intelligence platform for AI agents. 20 tools for architecture, security & impact analysis.
Zero-install security baseline for AI coding agents — OWASP/CWE-cited rules over MCP.
Related MCP Servers
- AlicenseNot gradedqualityBmaintenanceEnables coding agents to perform deterministic, model-free repository analysis and patch operations—tree-sitter repo maps, symbol/reference lookup, and SEARCH/REPLACE parsing/validation—via a CLI or MCP stdio server, without ever calling a language model.1MIT
- AlicenseNot gradedqualityCmaintenanceEnables AI coding agents to retrieve repository context through stdio-based MCP tools, including ranked repo maps, context packs, and live symbol search.11 npmMIT
- AlicenseNot gradedqualityCmaintenanceEnables coding agents to inspect files, search text, compare directories, read symbols, and apply structured edits against large codebases through bounded, local-first MCP tools.4Apache 2.0
- AlicenseNot gradedqualityBmaintenanceEnables local LLM tools and agentic IDEs to inspect repository token maps, retrieve clean token-bounded codebase snapshots, and audit code for hardcoded secrets via MCP over stdio.4MIT