security-mcp
Fetches GitHub Code Scanning alerts and applies minimal local patches to fix vulnerabilities, without creating branches, commits, or PRs.
README
Security MCP Setup for Claude Code
This setup connects a custom security-mcp server to Claude Code so Claude can fetch GitHub Code Scanning alerts for the current repository and apply local patches.
The lifecycle is intentionally limited:
/fix-vuls
→ fetch open GitHub Code Scanning alerts
→ map alerts to local files
→ apply minimal local patches
→ stop
No branch, commit, push, PR, test run, build, or validation is performed by Claude.
The GitHub token used to fetch alerts is read from a .env file inside the repo where claude is run — it is never passed on the command line or committed to source control.
1. Add a .env file with your GitHub token
The GitHub token is not passed as a CLI flag. Instead, create a .env file inside the repo where you run claude (i.e. the org repo you want to scan, not the security-mcp server folder).
For the current v1, the token only needs access to read security/code scanning alerts.
macOS:
cd your-org-repo
echo "GITHUB_TOKEN=YOUR_GITHUB_TOKEN" > .env
Windows (PowerShell):
cd your-org-repo
"GITHUB_TOKEN=YOUR_GITHUB_TOKEN" | Out-File -Encoding utf8 .env
Windows (Command Prompt):
cd your-org-repo
echo GITHUB_TOKEN=YOUR_GITHUB_TOKEN > .env
Replace YOUR_GITHUB_TOKEN with a GitHub token that has permission to read Code Scanning alerts.
⚠️ Add
.envto.gitignoreso the token is never committed.
2. Connect MCP to Claude Code
From the same repo folder, add the MCP server (no token flag needed — security-mcp reads it from .env at runtime):
macOS:
claude mcp add security-mcp -- node /absolute/path/to/security-mcp/server.js
Example:
claude mcp add security-mcp -- node /Users/p.shreyas/workplace/experiment/code-vuls/security-mcp/server.js
Windows (PowerShell / Command Prompt):
claude mcp add security-mcp -- node C:\absolute\path\to\security-mcp\server.js
Example:
claude mcp add security-mcp -- node C:\Users\shreyas\workplace\experiment\code-vuls\security-mcp\server.js
3. Verify MCP connection
Run:
claude mcp list
Expected output:
security-mcp ✓ Connected
If the server is not connected, restart Claude Code and verify the MCP path and .env file.
4. Open Claude Code in the target repo
Go to your org repo (the same folder containing your .env file):
macOS:
cd your-org-repo
claude
Example:
cd /Users/p.shreyas/workplace/vas-experience-api
claude
Windows (PowerShell / Command Prompt):
cd your-org-repo
claude
Example:
cd C:\Users\shreyas\workplace\vas-experience-api
claude
5. Test the MCP manually
Inside Claude Code, run this prompt:
Use the security-mcp tool to list open code scanning alerts for this current GitHub repo. Detect owner and repo from git remote.
Expected result:
Found open code scanning alerts:
- java/sql-injection ...
- java/path-injection ...
- java/log-injection ...
If you see this error:
Missing GITHUB_TOKEN in environment
Check the following:
- A
.envfile exists in the repo folder you ranclaudefrom (not thesecurity-mcpserver folder). - The
.envfile contains a line exactly likeGITHUB_TOKEN=YOUR_GITHUB_TOKEN, with no quotes or extra spaces. - You restarted Claude Code (
claude) after creating or editing.env.
If needed, remove and re-add the MCP:
macOS:
claude mcp remove security-mcp
claude mcp add security-mcp -- node /absolute/path/to/security-mcp/server.js
Windows:
claude mcp remove security-mcp
claude mcp add security-mcp -- node C:\absolute\path\to\security-mcp\server.js
Then restart Claude Code.
6. Create the Claude slash command
Inside the repo, create:
macOS:
mkdir -p .claude/commands
touch .claude/commands/fix-vuls.md
Windows (PowerShell):
New-Item -ItemType Directory -Force .claude\commands
New-Item -ItemType File -Force .claude\commands\fix-vuls.md
Windows (Command Prompt):
mkdir .claude\commands
type nul > .claude\commands\fix-vuls.md
Add this content to .claude/commands/fix-vuls.md:
You are a local security remediation agent for this repository.
Goal:
Fetch open GitHub code scanning vulnerabilities for the current repo and apply safe fixes locally only.
Use the Security MCP tools where available.
Lifecycle:
Your lifecycle ends immediately after applying patches locally.
Steps:
1. Detect the current GitHub owner/repo from git remote.
2. Fetch open GitHub code scanning alerts for this repo.
3. For each open alert, read:
- rule ID
- severity
- affected file
- affected line
- alert message
- code scanning location details
4. Map each alert to the matching local source file.
5. Apply the smallest safe patch that directly addresses the alert.
6. Stop after patching.
7. Summarize:
- alerts patched
- files changed
- alerts skipped
- reason for each skipped alert
- reminder that validation was not run
Strict rules:
- Do not create a branch.
- Do not commit.
- Do not push.
- Do not create a PR.
- Do not auto-merge.
- Do not run tests.
- Do not run build.
- Do not run validation.
- Do not run dependency audit.
- Do not modify CI/CD configuration.
- Do not suppress CodeQL/code scanning alerts unless the alert is clearly false positive and the local code change is unnecessary.
- Do not delete tests.
- Do not make broad refactors.
- Do not change unrelated files.
- Keep all fixes minimal and local.
7. Run the final command
Inside Claude Code:
/fix-vuls
Expected final behavior:
Applied local patches for 3 code scanning alerts.
Files changed:
- src/main/java/...
- src/main/java/...
Skipped:
- Alert #12 because affected file was generated code.
Stopped after applying patches locally.
No tests, build, validation, branch, commit, push, or PR were performed.
8. Developer review
After Claude stops, the developer owns the next steps.
Recommended manual checks:
git diff
Then run project-specific validation manually, for example:
mvn test
or:
npm test
If the changes look good, the developer can manually create a branch, commit, push, and PR using the normal team workflow.
Final lifecycle
Developer runs /fix-vuls
↓
Claude detects GitHub repo
↓
Security MCP fetches Code Scanning alerts
↓
Claude applies minimal local patches
↓
Claude stops
↓
Developer reviews, tests, commits, and raises PR manually
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。