Zero dependencies. 145 detection patterns. Works with Node.js 18+. Detects 23 LLM SDKs, 24 AI frameworks, 20+ AI token patterns, and 59 generic secret patterns across Python, JavaScript, TypeScript, Go, Java, and more.
๐จ Token & Secret Detection
Catches hardcoded API keys for OpenAI, Anthropic, Stripe, GitHub, Slack, Twilio, and 50+ more providers. AI tokens + generic secrets in one scan.
๐ฆ SDK Discovery
Detects imports and client initialization for 23 LLM SDKs across all major languages.
๐ง Framework Detection
Finds LangChain, LlamaIndex, CrewAI, AutoGen, DSPy, Vercel AI SDK, and 24 total frameworks.
๐งน Smart Filtering
Context-aware โ ignores mentions in docs and README files. Skips .env files by default.
๐ค MCP Server
Use with Claude Code, Cursor, and Windsurf via the Model Context Protocol. 3 tools for AI agents.
๐ CI/CD Ready
JSON and SARIF output. Exit code flag. GitHub Actions, pre-commit hooks, scheduled audits.
Installation
# Run directly โ no install needed
npx ai-scanner ./my-project
# Or install globally
npm install -g ai-scanner
ai-scanner ./my-project
Requires Node.js 18 or higher. Zero dependencies โ the tool is completely self-contained.
Quick Start
Point ai-scanner at any directory to get instant results:
# Scan current directory (AI + generic secrets)
ai-scanner
# Scan a specific project
ai-scanner ./my-project
# Security-only: just find exposed tokens & secrets
ai-scanner --tokens-only
CLI Options
| Flag | Description |
|---|---|
-o, --output <file> | Write JSON report to file |
--sarif <file> | Write SARIF report (for CI/CD integration) |
--tokens-only | Only scan for exposed tokens & secrets (security mode) |
--ai-only | Only scan AI-specific patterns (skip generic secrets) |
--scan-env | Include .env files (skipped by default) |
--no-endpoints | Skip API endpoint detection |
--no-models | Skip model name reference detection |
--json | Output results as JSON to stdout |
--exit-code | Exit with code 1 if critical/high findings |
-h, --help | Show help message |
-v, --version | Show version number |
# Combine flags for CI pipelines
ai-scanner ./src --tokens-only --exit-code --json
# AI patterns only (no Stripe, GitHub tokens, etc.)
ai-scanner --ai-only
# Include .env files in the scan
ai-scanner --scan-env
Smart Filtering
ai-scanner is context-aware. It distinguishes between using an SDK in source code vs. mentioning it in documentation.
| File type | SDK/Framework mentions | Exposed tokens & secrets |
|---|---|---|
Source code (.js, .py, .go, etc.) | โ Reported | โ Reported |
| README, docs, markdown | โ Ignored | โ Reported |
examples/, samples/, docs/ dirs | โ Ignored | โ Reported |
.env files | โ Skipped | โ Skipped by default |
.env with --scan-env | โ | โ Reported |
.env files are designed to hold secrets โ they should be in your .gitignore. The real risk is keys hardcoded directly in source files. Use --scan-env if you want to include them.
Detection Coverage
AI Tokens 20+
Generic Secrets 59 patterns
| Category | Detections |
|---|---|
| Payment | Stripe (live, restricted, webhook), Square, PayPal Braintree |
| Communication | Twilio, SendGrid, Mailgun, Mailchimp, Postmark |
| Source Control | GitHub (PAT, fine-grained, OAuth, app), GitLab, Bitbucket, CircleCI |
| Cloud | GCP service accounts, DigitalOcean, Heroku, Vercel, Netlify, Cloudflare |
| Messaging | Slack (bot, user, webhook), Discord (bot, webhook), Telegram |
| Database | Postgres/MySQL/MongoDB/Redis/AMQP URIs, Supabase, Firebase, PlanetScale |
| Auth | Auth0, Okta, Clerk |
| Monitoring | Datadog, Sentry DSN, New Relic, Segment, Mixpanel |
| Crypto | RSA, EC, DSA, SSH, PGP private keys |
| Generic | Passwords, client secrets, connection strings, JWTs |
LLM SDKs 23
AI Frameworks 24
Severity Levels
| Level | Meaning | Example |
|---|---|---|
| CRITICAL | Exposed key with known prefix | sk-ant-abc123..., sk_live_..., ghp_... |
| HIGH | Likely hardcoded credential | api_key = "...", JWT tokens, DB strings |
| INFO | SDK/framework usage (awareness) | import openai |
MCP Server
Use ai-scanner as a tool for AI agents via the Model Context Protocol. Works with Claude Code, Claude Desktop, Cursor, and Windsurf.
Setup
# Claude Code โ one command
claude mcp add ai-scanner npx ai-scanner-mcp
For Claude Desktop, Cursor, or Windsurf โ add to your MCP config file:
{
"mcpServers": {
"ai-scanner": {
"command": "npx",
"args": ["ai-scanner-mcp"]
}
}
}
Tools
| Tool | Description |
|---|---|
scan_directory | Full scan โ LLM SDKs, AI frameworks, exposed tokens, and hardcoded secrets |
check_secrets | Security check โ pass/fail for exposed credentials only |
ai_inventory | AI stack overview โ which SDKs, frameworks, models are used |
Once connected, ask your AI agent things like:
"Scan this project for any exposed API keys" ยท "Check if there are any hardcoded secrets before I commit" ยท "What AI frameworks does this codebase use?"
See ai-scanner-mcp for full documentation.
Examples
Scan a GitHub Repo
Clone any public repo and scan it in one command:
git clone --depth 1 https://github.com/user/repo /tmp/repo
npx ai-scanner /tmp/repo
rm -rf /tmp/repo
Or use the included helper scripts:
# Shell โ clones, scans, cleans up automatically
./examples/scan-github-repo.sh https://github.com/langchain-ai/langchainjs
# Node.js โ uses ai-scanner as a library, saves JSON report
node examples/scan-github-repo.js https://github.com/langchain-ai/langchainjs
Batch Scan Multiple Repos
# Edit the REPOS array in the script, then run:
node examples/scan-multiple-repos.js
# Output:
# ๐จ my-api 12 findings 3 critical 2 SDKs 1 frameworks
# ๐ฆ my-app 8 findings 0 critical 3 SDKs 2 frameworks
# โ
my-lib 0 findings 0 critical 0 SDKs 0 frameworks
Use as a Library
const { Scanner } = require('ai-scanner');
const scanner = new Scanner({ rootDir: './my-project' });
const result = scanner.scan();
// Access structured results
console.log(result.stats.criticalFindings);
console.log(result.findings.filter(f => f.type === 'token'));
See the examples/ directory for pre-commit hooks, GitHub Actions workflows, and more.
CI/CD Integration
GitHub Actions
# .github/workflows/ai-scan.yml
name: AI Security Scan
on: [push, pull_request]
jobs:
scan:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Scan for exposed tokens & secrets
run: npx ai-scanner --tokens-only --exit-code
Pre-commit Hook
# .husky/pre-commit
npx ai-scanner --tokens-only --exit-code
With --exit-code, the tool returns 0 if clean, 1 if critical/high findings are detected โ perfect for CI gates.
About
Built by Aakash Bhardwaj.