loading…
Search for a command to run...
loading…
Provides centralized security instructions for AI-assisted code generation by matching context-aware rules to the user's programming language and file patterns.
Provides centralized security instructions for AI-assisted code generation by matching context-aware rules to the user's programming language and file patterns. It ensures generated code adheres to security best practices without requiring manual maintenance of instruction files across individual repositories.
Security rules for AI code generation via Model Context Protocol.
Built upon Project CodeGuard: This MCP server integrates the comprehensive security instruction rules from Project CodeGuard, solving scaling and central governance challenges by delivering them via Model Context Protocol instead of per-repository file duplication.
GitHub Copilot can use .github/instructions/ files for security rules, but this sucks for orgs:
This MCP server centralizes all security rules in one place.
npm install -g @isagasi/codeguard-mcp-server
Windows:
# Get the global npm modules path
$npmPath = npm root -g
$serverPath = Join-Path $npmPath "@isagasi\codeguard-mcp-server\dist\index.js"
# Create configuration using node with args for reliable stdio
$config = @"
{
"servers": {
"codeguard": {
"type": "stdio",
"command": "node",
"args": ["$($serverPath -replace '\\', '\\\\')"],
"autoStart": true
}
}
}
"@
[System.IO.File]::WriteAllText("$env:APPDATA\Code\User\mcp.json", $config, (New-Object System.Text.UTF8Encoding $false))
Write-Host "✓ mcp.json created at: $env:APPDATA\Code\User\mcp.json"
macOS/Linux:
# Get the global npm modules path
NPM_PATH=$(npm root -g)
SERVER_PATH="$NPM_PATH/@isagasi/codeguard-mcp-server/dist/index.js"
# Create configuration using node with args for reliable stdio
cat > ~/Library/Application\ Support/Code/User/mcp.json << EOF
{
"servers": {
"codeguard": {
"type": "stdio",
"command": "node",
"args": ["$SERVER_PATH"],
"autoStart": true
}
}
}
EOF
echo "✓ mcp.json created"
code --install-extension alankyshum.vscode-mcp-autostarter
Press Ctrl+Shift+P → "Developer: Reload Window"
Ctrl+Shift+P → "MCP: List Servers" → Should show codeguard running ✅
Done! Server is now active and will auto-start with VS Code.
Verify the MCP server is actually being invoked by Copilot:
Test 1: Password Hashing
@workspace Generate a Python function to hash a password
Expected: Copilot should generate code using bcrypt or Argon2 (not MD5 or SHA1)
Test 2: Database Query
@workspace Create a PostgreSQL query function in Node.js
Expected: Code should use parameterized queries, not string concatenation
Test 3: API Key Storage
@workspace Show how to store an API key in a Python app
Expected: Should suggest environment variables (os.getenv), not hardcoded strings
If Copilot generates insecure code (MD5 passwords, SQL injection, hardcoded keys), the MCP server may not be loaded. Retry steps 4-5.
The server provides 23 default security instruction files + 3 custom org rules:
Copilot Chat can query these via MCP tools when generating code.
Add org-specific rules in rules/custom/:
---
applyTo: '**/*.ts'
description: Company API Standards
---
# API Standards
All REST endpoints must:
- Use company error format
- Log to ELK stack
- Rate limit: 100 req/min
Custom rules get +25 priority and override defaults.
Update to latest version:
npm update -g @isagasi/codeguard-mcp-server
# Then reload VS Code
Publishing new versions (Maintainers):
npm version patch (1.0.8 → 1.0.9)git push --follow-tagsServer not running:
Ctrl+Shift+P → "MCP: List Servers"codeguard with status "running"Error: spawn ENOENT or spawn EINVAL:
node with args configuration shown in Step 2 (not codeguard-mcp command)node directly ensures compatibilityView server logs:
Reinstall package:
npm uninstall -g @isagasi/codeguard-mcp-server
npm install -g @isagasi/codeguard-mcp-server
# Reload VS Code
This project integrates the security instruction rules from Project CodeGuard, a comprehensive collection of security best practices for AI-assisted code generation.
The MCP server architecture solves the scaling and central governance challenges inherent in per-repository instruction files, enabling organizations to maintain a single source of truth for security standards across all projects.
MIT
Add this to claude_desktop_config.json and restart Claude Desktop.
{
"mcpServers": {
"codeguard-mcp-server": {
"command": "npx",
"args": []
}
}
}