# CodeSlick MCP Server

Comprehensive security analysis for source code via Model Context Protocol (MCP). Run 306 security checks, detect secrets, scan dependencies, and generate SBOMs directly from Cursor, Claude Desktop, or any MCP-compatible AI tool.

## Features

- **306 Security Checks** across 7 formats (JavaScript, TypeScript, Python, Java, Go, Terraform, Kubernetes)
- **OWASP 2025 Compliance** (95% coverage) with CVSS 3.1 scoring
- **AI Code Detection** with 164 signals (hallucinations, heuristics, LLM fingerprints)
- **Secrets Detection** for 38 patterns (API keys, passwords, tokens, certificates)
- **Dependency Scanning** for npm, pip, Maven, Gradle, Go modules
- **SBOM Generation** in SPDX 2.3 and CycloneDX 1.4 formats
- **AI Bill of Materials** — inventory AI models, MCP tools, agent frameworks, and API keys in any codebase
- **Malicious Package Detection** for 66 known packages

## Installation

**Prerequisites**: CodeSlick CLI must be installed globally.

```bash
npm install -g codeslick
```

### Cursor

Add to `~/.cursor/mcp.json` (create if it doesn't exist):

```json
{
  "mcpServers": {
    "codeslick": {
      "command": "npx",
      "args": ["-y", "codeslick-mcp-server@latest"],
      "env": {}
    }
  }
}
```

Restart Cursor. The CodeSlick tools will appear in the MCP tools panel.

### Claude Desktop

Add to `~/Library/Application Support/Claude/claude_desktop_config.json` (macOS):

```json
{
  "mcpServers": {
    "codeslick": {
      "command": "npx",
      "args": ["-y", "codeslick-mcp-server@latest"]
    }
  }
}
```

On Windows: `%APPDATA%\Claude\claude_desktop_config.json`

Restart Claude Desktop. Click the hammer icon to confirm CodeSlick tools are listed.

### Claude Code (CLI)

```bash
claude mcp add codeslick -- npx -y codeslick-mcp-server@latest
```

Or add manually to `~/.claude/mcp.json`:

```json
{
  "mcpServers": {
    "codeslick": {
      "command": "npx",
      "args": ["-y", "codeslick-mcp-server@latest"]
    }
  }
}
```

## Available Tools

### 1. `analyze_code`

Run comprehensive security analysis on source code.

**Parameters:**
- `code` (string, required): Source code to analyze
- `language` (string, required): One of `javascript`, `typescript`, `python`, `java`, `go`, `terraform`, `kubernetes`
- `filename` (string, optional): Filename for context

**Example:**

```
Analyze this JavaScript code for security issues:

function login(username, password) {
  const query = "SELECT * FROM users WHERE username='" + username + "'";
  // ... SQL injection vulnerability
}
```

**Output:**
- Security score (0-100)
- Vulnerability list with severity, CVSS score, OWASP/CWE mappings
- Remediation guidance with before/after code examples
- Attack vector descriptions

### 2. `scan_dependencies`

Scan project dependencies for vulnerabilities.

**Parameters:**
- `content` (string, required): Content of dependency file (package.json, requirements.txt, etc.)
- `type` (string, required): One of `npm`, `pip`, `maven`, `gradle`, `go`

**Example:**

```
Scan this package.json for vulnerable dependencies:

{
  "dependencies": {
    "express": "4.16.0",
    "lodash": "4.17.0"
  }
}
```

**Output:**
- Vulnerable packages with CVE IDs
- Malicious package detection
- Upgrade recommendations
- Severity breakdown

### 3. `generate_sbom`

Generate Software Bill of Materials.

**Parameters:**
- `content` (string, required): Content of dependency file
- `type` (string, required): One of `npm`, `pip`, `maven`, `gradle`, `go`
- `format` (string, optional): One of `spdx`, `cyclonedx`, `both` (default: `both`)
- `projectName` (string, optional): Project name for metadata
- `projectVersion` (string, optional): Project version for metadata

**Example:**

```
Generate SBOM for this package.json in SPDX format:

{
  "name": "my-app",
  "version": "1.0.0",
  "dependencies": {
    "react": "^18.0.0"
  }
}
```

**Output:**
- SPDX 2.3 formatted SBOM
- CycloneDX 1.4 formatted SBOM
- Component count and metadata
- License information

### 4. `detect_secrets`

Detect hardcoded secrets in source code.

**Parameters:**
- `code` (string, required): Source code to scan
- `language` (string, optional): One of `javascript`, `typescript`, `python`, `java`, `go`, `terraform`, `kubernetes`
- `filename` (string, optional): Filename for context

**Example:**

```
Check this code for hardcoded secrets:

const config = {
  awsAccessKey: "AKIAIOSFODNN7EXAMPLE",
  dbPassword: "super_secret_password_123"
};
```

**Output:**
- Detected secrets with pattern type
- Severity (critical, high, medium)
- Line numbers
- Remediation steps
- Risk descriptions

### 5. `generate_ai_bom`

Generate an AI Bill of Materials (AI-BOM) — a structured inventory of all AI components in a codebase.

**Parameters:**
- `code` (string): Source code to scan (single file). Use `files` for multi-file scanning.
- `filename` (string, optional): Filename for context (e.g., `"agent.ts"`)
- `files` (object, optional): Map of `filename → content` for multi-file scanning

**Detects:**
- **AI model API calls**: OpenAI, Anthropic, Gemini, Ollama, HuggingFace, Cohere, Mistral, Groq, Azure OpenAI, Replicate, Together AI, Vercel AI SDK, OpenRouter
- **MCP tool registrations**: `server.tool()`, `FastMCP`, `@Tool` decorators, McpServer, MCP SDK imports
- **Agent frameworks**: LangChain, AutoGen, CrewAI, Mastra, LlamaIndex, DSPy, Haystack, PydanticAI, Semantic Kernel, BeeAgent, Agentkit
- **AI API keys**: `OPENAI_API_KEY`, `ANTHROPIC_API_KEY`, `GEMINI_API_KEY`, and 11 others

**Example (single file):**

```
What AI providers does this code use?

import OpenAI from 'openai';
import { ChatOpenAI } from '@langchain/openai';

const client = new OpenAI({ apiKey: process.env.OPENAI_API_KEY });
const response = await client.chat.completions.create({
  model: 'gpt-4o',
  messages: [{ role: 'user', content: 'Hello' }],
});
```

**Example (multi-file):**

```
Generate an AI BOM for these files:
- app/api/chat/route.ts: [content]
- lib/agents/researcher.ts: [content]
- .env.example: [content]
```

**Output:**
- Detected AI providers and model names
- Named MCP tools registered in the server
- Agent frameworks and import paths
- AI API key references by file and line

## Language Support

| Language | Security Checks | Features |
|----------|----------------|----------|
| **JavaScript** | 36 checks | XSS, injection, insecure functions, MCP security |
| **TypeScript** | 64 checks | Type safety + JS checks, MCP security |
| **Python** | 51 checks | SQL injection, pickle, eval, MCP security |
| **Java** | 32 checks | XXE, deserialization, LDAP injection |
| **Go** | 26 checks | SQL injection, file paths, crypto |
| **Terraform** | 22 checks | AWS misconfigs, secrets, PII |
| **Kubernetes** | 37 checks | RBAC, pod security, secrets |

## Security Check Categories

- **Injection Attacks**: SQL, XSS, command injection, LDAP injection
- **Authentication/Authorization**: Weak crypto, insecure sessions, RBAC issues
- **Sensitive Data Exposure**: Hardcoded secrets, PII, API keys
- **XML/Deserialization**: XXE, unsafe pickle, Java deserialization
- **Security Misconfiguration**: Missing security headers, weak SSL, insecure defaults
- **Known Vulnerabilities**: Malicious packages, outdated dependencies
- **AI Code Detection**: LLM hallucinations, AI-generated patterns

## OWASP 2025 Coverage

- **A01:2021 - Broken Access Control**: ✅ 100%
- **A02:2021 - Cryptographic Failures**: ✅ 100%
- **A03:2021 - Injection**: ✅ 100%
- **A04:2021 - Insecure Design**: ✅ 95%
- **A05:2021 - Security Misconfiguration**: ✅ 90%
- **A06:2021 - Vulnerable Components**: ✅ 100%
- **A07:2021 - Authentication Failures**: ✅ 100%
- **A08:2021 - Data Integrity Failures**: ✅ 85%
- **A09:2021 - Logging Failures**: ✅ 90%
- **A10:2021 - SSRF**: ✅ 100%

**Overall Coverage**: 95%

## Examples

### Example 1: Analyze Python Code

```
User: Analyze this Python code for security issues:

import pickle
import os

def load_data(filename):
    with open(filename, 'rb') as f:
        data = pickle.load(f)  # Unsafe deserialization
    return data

def execute_command(user_input):
    os.system("ls " + user_input)  # Command injection
```

**Claude Code Response:**

```
# CodeSlick Security Analysis Report

**Language:** python
**Security Score:** 42/100
**Total Vulnerabilities:** 2

## Vulnerability Summary

[CRITICAL]: 2

---

## Top Vulnerabilities

### 1. Unsafe Pickle Deserialization

**Severity:** CRITICAL
**CVSS Score:** 9.8/10
**OWASP:** A08:2021
**CWE:** CWE-502

**Recommendation:** Use safe alternatives like JSON or XML. Never unpickle data from untrusted sources.

**Fix:**
```python
// Before:
data = pickle.load(f)

// After:
import json
data = json.load(f)
```
Replace pickle with JSON for safe deserialization.

---

### 2. Command Injection via os.system()

**Severity:** CRITICAL
**CVSS Score:** 9.8/10
**OWASP:** A03:2021
**CWE:** CWE-78

**Recommendation:** Use subprocess with shell=False and argument list instead of os.system().

**Fix:**
```python
// Before:
os.system("ls " + user_input)

// After:
subprocess.run(["ls", user_input], shell=False, check=True)
```
Use subprocess with argument array to prevent command injection.
```

### Example 2: Scan Dependencies

```
User: Scan these npm dependencies:

{
  "dependencies": {
    "express": "4.16.0",
    "lodash": "4.17.0",
    "event-stream": "3.3.4"
  }
}
```

**Claude Code Response:**

```
# Dependency Scan Report

**Package Manager:** npm
**Total Vulnerabilities:** 3

## Vulnerability Summary

[CRITICAL]: 1 (malicious package)
[HIGH]: 2 (known CVEs)

---

## Vulnerable Dependencies

### 1. event-stream@3.3.4

**Severity:** CRITICAL
**Issue:** Malicious package - Bitcoin wallet stealer (CVE-2018-3721)
**Fix:** Remove immediately - use alternative package

### 2. lodash@4.17.0

**Severity:** HIGH
**Issue:** Prototype pollution (CVE-2019-10744)
**Fix:** Upgrade to version 4.17.21

### 3. express@4.16.0

**Severity:** HIGH
**Issue:** Open redirect vulnerability (CVE-2018-3717)
**Fix:** Upgrade to version 4.18.0
```

## Performance

- **Analysis Speed**: <3s for typical files (WebTool requirement)
- **Memory Usage**: Low (optimized AST traversal)
- **False Positive Rate**: <10% (context-aware filtering)

## Privacy Policy

CodeSlick MCP Server prioritizes your privacy and security:

### Data Processing
- **Local Processing Only**: All code analysis is performed locally on your machine
- **No Data Collection**: We do not collect, store, or transmit your source code
- **No Telemetry**: No usage statistics, analytics, or tracking of any kind
- **No Account Required**: The MCP server works completely offline without authentication

### Network Activity
- **Fully Offline**: Security analysis runs without internet connectivity
- **Optional External Calls**: Only for dependency scanning (OSV.dev vulnerability database) if enabled
- **No Third-Party Services**: No data sent to CodeSlick servers or any third parties

### API Key Usage
- **Your Keys, Your Control**: If using advanced AI features, your OpenRouter API key is used directly
- **No Key Storage**: API keys are not stored or logged by the MCP server
- **No Access**: CodeSlick does not see or have access to your API keys

### Open Source & Auditable
- **MIT License**: Fully open source and auditable
- **Transparent Code**: All source code available for security review
- **No Hidden Functionality**: What you see is what you get

### CodeSlick Web Service (Separate)
This MCP server is separate from the CodeSlick web service. For the web service privacy policy, see: https://codeslick.dev/privacy

### Contact
For privacy-related questions: privacy@codeslick.dev

## Support

- **Documentation**: https://codeslick.dev/docs
- **Issues**: https://github.com/VitorLourenco/codeslick2/issues
- **Email**: support@codeslick.dev

## License

MIT License - Copyright (c) 2026 CodeSlick

## Contributing

Contributions welcome! See [CONTRIBUTING.md](../../CONTRIBUTING.md) for guidelines.

## Roadmap

- [ ] C/C++ language support
- [ ] Rust language support
- [ ] CloudFormation support
- [ ] Custom rule configuration
- [ ] CI/CD integration templates
- [ ] VS Code extension

## Credits

Built with:
- [@modelcontextprotocol/sdk](https://github.com/anthropics/mcp) - MCP SDK by Anthropic
- [TypeScript](https://www.typescriptlang.org/) - Type-safe JavaScript
- [CodeSlick](https://codeslick.dev) - Security analysis engine

---

**Made by the CodeSlick team**
