context-preflight
Integrates directly into GitHub workflows for continuous context validation, automated PR checks, and security reporting via SARIF alerts.
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.
context-preflight
Zero-runtime-dependency preflight CI linter, GitHub Action, SARIF analyzer, and MCP server for AI coding-agent context layers.
context-preflight audits CLAUDE.md, AGENTS.md, GEMINI.md, .github/copilot-instructions.md, .cursor/rules/*, SKILL.md, .claude/settings.json, .mcp.json, saved MCP tool schemas/payloads, and LLM prompt-cache call sites before silent drift, token bloat, broken references, or hidden prompt injections ship to main.
Why Context Needs CI Preflight
Teams carefully CI-test source code, yet leave the instruction files and MCP configs loaded on every coding-agent turn unvalidated:
Silent context rot: A file gets renamed, a
package.jsonscript is removed, orCLAUDE.mdimports a deleted path (@docs/old.md). Agents waste turns hunting for missing files or running broken commands.Turn-0 token tax: Root
CLAUDE.md,AGENTS.md,GEMINI.md,.cursorrules,@importtrees, and MCP schemas load before the user types a single word. Passing your turn-0 budget degrades recall and burns quota.Security & supply-chain hazards: Invisible Unicode bidi overrides / tag characters, hardcoded API keys in
.mcp.json, overly broadBash(*)permissions in.claude/settings.json, or unpinnednpx -yservers silently bypass review.Prompt cache invalidation & MCP bloat: Dynamic
Date.now()/uuid4()calls inside cached system prompt prefixes invalidate KV caches every turn, while verbose MCP schemas or mirroredtext+structuredContentresponses double payload tokens.
context-preflight catches all of these in milliseconds using zero runtime dependencies (dependencies: {}).
Related MCP server: UpToCode
Quickstart (10 Seconds)
Run against any repository without installing dependencies:
npx context-preflightAudit the bundled healthy example or generate a starter workflow:
npx context-preflight ./examples/healthy
npx context-preflight initCompare a branch against a saved baseline report in PRs:
npx context-preflight --format json --output .preflight-baseline.json
npx context-preflight compare .preflight-baseline.json . --format markdownGitHub Action
Drop .github/workflows/context-preflight.yml into any repository for PR health checks, base-branch token deltas, sticky PR comments, Job Summaries, and optional GitHub Code Scanning SARIF alerts:
name: Context Preflight
on:
pull_request:
push:
branches: [main]
permissions:
contents: read
pull-requests: write
security-events: write
jobs:
preflight:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: SiluPanda/context-preflight@v1
with:
fail-on: error
max-turn0-tokens: "8000"
comment-pr: "true"
sarif-file: context-preflight.sarif
- uses: github/codeql-action/upload-sarif@v3
if: always()
with:
sarif_file: context-preflight.sarifAction Inputs & Outputs
Input | Default | Description |
|
| Repository subdirectory to scan |
|
| Maximum estimated turn-0 context tokens before failing |
|
| Maximum estimated tokens per always-loaded instruction file |
|
| Maximum recommended lines per |
|
| Exit threshold: |
|
| Comma-separated rule IDs to suppress |
|
| Comma-separated file/directory patterns to ignore |
|
| Optional output file path for SARIF 2.1.0 results |
|
| Create or update sticky |
|
| Token used for PR comment updates |
Outputs emitted on steps.<id>.outputs: score, grade, passed, turn0-tokens, error-count, warning-count, sarif-file.
Built-in Rule Reference (27 Rules)
Security & Configuration (security)
Rule ID | Severity | Description |
|
| Detects zero-width chars, bidirectional overrides, and Unicode tags in context files |
|
| Flags hardcoded Anthropic/OpenAI/GitHub/AWS/Slack/GitLab keys while ignoring |
|
| Flags malformed |
|
| Flags overly broad allow rules in |
|
| Flags unpinned |
|
| Flags hidden instruction overrides, concealment directives, exfil patterns, and unverified remote shell pipes |
Dead References & Tooling Drift (references)
Rule ID | Severity | Description |
|
| Validates Claude Code |
|
| Checks relative Markdown links against repository files |
|
| Verifies local script paths referenced in |
|
| Checks backticked repository file paths while skipping code fences, examples, and third-party SDK paths |
|
| Validates |
|
| Flags instructions using |
Budgets, Skills & Prompt Caching (budget, skill)
Rule ID | Severity | Description |
|
| Ensures |
|
| Flags |
|
| Flags single always-loaded context files exceeding |
|
| Warns when always-loaded turn-0 context crosses 75% of |
|
| Fails when always-loaded turn-0 context (including deduplicated |
|
| Detects >60% 4-gram overlap between root |
|
| Flags volatile |
MCP Schemas & Payload Waste (mcp)
Rule ID | Severity | Description |
|
| Flags duplicate tool names in an MCP server |
|
| Validates |
|
| Flags MCP result payloads exceeding |
|
| Flags MCP tools missing LLM-facing descriptions |
|
| Flags MCP tools exceeding |
|
| Reports spawn/timeout errors when |
|
| Detects |
|
| Detects repeated JSON subtrees >= 64 bytes inside MCP tool result payloads |
Real-World Audit Results
Validated locally against real open-source repositories across Python, Rust, TypeScript, and C++:
Repository | Artifacts Scanned | Turn-0 Context | Findings Summary |
| 3 files | ~571 tokens (7%) |
|
| 17 files (incl. 9 skills) | ~2,338 tokens (29%) |
|
| 1 file | ~0 root / 1,279 on-demand |
|
| 2 files | ~1,605 tokens (20%) |
|
| 27 files | ~4,157 tokens (52%) |
|
| 42 files | ~4,480 tokens (56%) |
|
| 2 MCP fixtures | ~0 tokens |
|
CLI Reference
Usage:
context-preflight [scan] [path] [options]
context-preflight compare <baseline.json> [path] [options]
context-preflight init [path]
context-preflight mcpOptions:
--format <text|json|markdown|sarif>— Output format (textby default)--output <file>— Write report output to a file--baseline <file.json>— Diff against a baselinePreflightReportJSON file--max-turn0-tokens <n>— Turn-0 token budget (default8000)--max-file-tokens <n>— Single always-loaded file limit (default4000)--max-skill-lines <n>—SKILL.mdline threshold (default500)--max-mcp-bytes <n>— MCP payload byte budget (default65536)--max-tool-desc-tokens <n>— Per-tool description token budget (default300)--fail-on <error|warning|never>— Non-zero exit condition (defaulterror)--ignore-rule <ruleId>— Suppress a specific rule (repeatable)--ignore-path <glob>— Skip matching paths/directories (repeatable)--probe-mcp— Opt-in live stdio MCPinitialize+tools/listschema probing from.mcp.json--probe-timeout <ms>— Per-server live probe timeout (default5000)--no-code-prompts— Skip scanning TS/JS/Python files for prompt-cache invalidators--no-color— Disable ANSI color codes
Exit codes: 0 (pass), 1 (failed threshold), 2 (invalid arguments or unreadable target).
MCP Server Mode
context-preflight doubles as a lightweight stdio Model Context Protocol server (2025-11-25) exposing:
preflight_scan(rootDir,maxTurn0Tokens)preflight_compare(baselinePath,rootDir)
Add it to .mcp.json or any MCP client:
{
"mcpServers": {
"context-preflight": {
"command": "npx",
"args": ["-y", "context-preflight@0.1.0", "mcp"]
}
}
}Programmatic TypeScript / Node.js API
Full ESM, CJS, and .d.ts exports verified with publint and @arethetypeswrong/cli:
import {
analyzeRepository,
diffReports,
formatMarkdownReport,
formatSarifReport,
} from "context-preflight";
const report = await analyzeRepository({
rootDir: process.cwd(),
maxTurn0Tokens: 8000,
failOn: "error",
});
console.log(report.summary.score, report.summary.grade);
console.log(formatMarkdownReport(report));License
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
Statically audits MCP tool surfaces for token cost, schema quality, and design issues.
Enforces architectural invariants and code quality rules inside your AI agent's edit loop.
Scan prompts for injection attacks, redact PII, and audit LLM SDK usage from any MCP client
Checks AI-written code for leaked keys and made-up packages, on your machine. Never uploads code.
Related MCP Servers
- AlicenseAqualityBmaintenanceAudits AI agent skills for safety using static, semantic, adversarial, and supply-chain analysis, providing scores and risk flags. Can be run via CLI, CI, or as an MCP tool from Claude Code, Cursor, and Codex.52Apache 2.0
- AlicenseNot gradedqualityCmaintenanceIt lets clients request design-time audits of Python and TypeScript agent applications for defects such as unbounded loops, ungated destructive actions, weak argument validation, insufficient run budgets, absent resiliency controls, overlooked evals, and poor observability. Findings include supporting evidence and feed an approval-driven mechanism for reviewing proposed fixes without mutating the original source.MIT
- AlicenseNot gradedqualityCmaintenanceEnables AI coding assistants to run static analysis on GitHub repositories, raw code snippets, or local directories to detect cloud cost leaks in Terraform/AWS configs, PostgreSQL migration table-lock hazards, and OWASP/Next.js API security gaps. Each finding returns structured severity, line-level detail, and drop-in fixes.MIT
- AlicenseNot gradedqualityBmaintenanceEnables coding agents in Claude Code, Cursor and other MCP clients to run five CI-style gates — hardcoded secrets, tenant-scoped queries, money float maths, unsafe migrations and dead doc links — over code the agent just wrote. Findings come back with the file, line, what is wrong and the fix, in the same turn, so expensive mistakes are caught before they merge.47 npmMIT