A command-line interface tool that automatically discovers MCP server capabilities (tools, resources, and prompts) and performs AI-powered security analysis. Perfect for CI/CD pipelines and automated security audits.
# Install globally
npm install -g @mcp-shark/cli
# Get your API token from https://smart.mcpshark.sh/tokens
# Run a scan
mcp-shark-cli scan -c mcp-config.json --token=sk_your_token_here- 🔍 Automatic Discovery: Automatically discovers tools, resources, and prompts from MCP servers
- 🚀 Multiple Transports: Supports stdio, HTTP/SSE, and WebSocket connections
- 📊 Flexible Output: Human-readable tables or JSON for CI/CD pipelines
- 🔒 Security Analysis: AI-powered analysis of MCP server security risks
- ⚡ CI/CD Ready: Proper exit codes and JSON output for automation
- 📝 Verbose Logging: Detailed debug output when needed
- Quick Start
- Features
- Installation
- Getting Your API Token
- Usage
- Output Formats
- CI/CD Integration
- Configuration File Format
- Examples
- Testing Phase Notice
- Contributing
- Support
- License
npm install -g @mcp-shark/cliAfter installation, use the CLI from anywhere:
mcp-shark-cli scan -c config.json --token=your_tokennpm install @mcp-shark/cliThen use with npx:
npx @mcp-shark/cli scan -c config.json --token=your_tokenOr add to your package.json scripts:
{
"scripts": {
"scan": "mcp-shark-cli scan -c config.json"
}
}If you have npm but don't want to install globally:
npx -y @mcp-shark/cli scan -c config.json --token=your_token- Node.js v18 or higher
- npm (comes with Node.js)
- Sign in to the Smart Scan web application
- Navigate to the
/tokenspage - Create a new token (or use your existing token)
- Copy the token (it starts with
sk_)
Important: Save your token securely - it won't be shown again after creation!
Perform a security scan on MCP servers. This command will:
- Connect to each configured MCP server
- Discover their capabilities (tools, resources, prompts)
- Submit the data to the Smart Scan API
- Display the results in a formatted table or JSON
# Basic usage
mcp-shark-cli scan -c mcp-config.json --token=sk_your_token_here
# Using environment variable for token
export APP_TOKEN=sk_your_token_here
mcp-shark-cli scan -c mcp-config.json
# With verbose output
mcp-shark-cli scan -c mcp-config.json --token=sk_your_token_here --verbose
# JSON output (for CI/CD pipelines)
mcp-shark-cli scan -c mcp-config.json --token=sk_your_token_here --json
# Fail on medium risk as well (default: only fails on high/critical)
mcp-shark-cli scan -c mcp-config.json --token=sk_your_token_here --fail-on-mediumOptions:
-c, --config <path>(required): Path to MCP configuration file--token <token>: Authentication token for API (or setAPP_TOKENenvironment variable)--verbose: Enable verbose output--json: Output results as JSON (for piping to jq or other tools)--fail-on-high: Exit with error code if risk level is high or critical (default: enabled)--fail-on-medium: Exit with error code if risk level is medium (default: disabled)--fail-on-low: Exit with error code if risk level is low (default: disabled)
Environment Variables:
APP_TOKEN: Authentication token for the API (required if not provided via--token)
The CLI connects to https://smart.mcpshark.sh automatically.
Check the status and results of a previously performed scan:
# Basic usage
mcp-shark-cli check --scan-id=scan123 --token=sk_your_token_here
# With verbose output
mcp-shark-cli check --scan-id=scan123 --token=sk_your_token_here --verbose
# JSON output
mcp-shark-cli check --scan-id=scan123 --token=sk_your_token_here --json
# Using environment variable for token
export APP_TOKEN=sk_your_token_here
mcp-shark-cli check --scan-id=scan123Options:
-j, --scan-id <scanId>(required): Scan ID returned from the scan command--token <token>: Authentication token for API (or setAPP_TOKENenvironment variable)--verbose: Enable verbose output--json: Output results as JSON (for piping to jq or other tools)--fail-on-high: Exit with error code if risk level is high or critical (default: enabled)--fail-on-medium: Exit with error code if risk level is medium (default: disabled)--fail-on-low: Exit with error code if risk level is low (default: disabled)
The default output shows scan results in a formatted table:
─────────────────────────────────────────────────────────────
│ Scan ID │ abc-123-def-456 │
│ Created At │ 2024-01-15T10:30:00.000Z │
│ Status │ SUCCESS │
│ Risk Level │ HIGH │
│ Rate Limit │ 2/3 │
│ Overall Reason │ Multiple high-risk tools detected... │
│ Tool Findings │ 5 │
│ Resource Findings │ 2 │
│ Prompt Findings │ 1 │
─────────────────────────────────────────────────────────────
Use --json flag for machine-readable output:
mcp-shark-cli scan -c mcp-config.json --token=sk_your_token_here --jsonOutput:
{
"id": "abc-123-def-456",
"created_at": "2024-01-15T10:30:00.000Z",
"status": "success",
"overall_risk_level": "high",
"is_error": false,
"error_message": null,
"error_type": null,
"http_status_code": 200,
"rate_limit": {
"limit": 3,
"remaining": 2
},
"analysis_result": {
"overall_risk_level": "high",
"overall_reason": "Multiple high-risk tools detected...",
"tool_findings": [...],
"resource_findings": [...],
"prompt_findings": [...]
}
}The CLI is designed for CI/CD pipelines with proper exit codes:
0: Success (or risk level doesn't trigger failure)1: Error occurred or risk level triggers failure
By default, the CLI exits with code 1 if:
- The scan itself failed (API error, network error, etc.)
- The risk level is
highorcritical
# Fail on medium risk as well
mcp-shark-cli scan -c mcp-config.json --token=sk_your_token_here --fail-on-medium
# Fail on low risk too
mcp-shark-cli scan -c mcp-config.json --token=sk_your_token_here --fail-on-low
# Don't fail on high risk (not recommended)
mcp-shark-cli scan -c mcp-config.json --token=sk_your_token_here --no-fail-on-highname: Security Scan
on: [push, pull_request]
jobs:
scan:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: "20"
- name: Install CLI
run: npm install -g @mcp-shark/cli
- name: Run security scan
env:
APP_TOKEN: ${{ secrets.SMART_SCAN_TOKEN }}
run: |
mcp-shark-cli scan -c mcp-config.json --json > scan-result.json
- name: Check risk level
run: |
RISK_LEVEL=$(cat scan-result.json | jq -r '.overall_risk_level')
if [ "$RISK_LEVEL" = "high" ] || [ "$RISK_LEVEL" = "critical" ]; then
echo "High risk detected: $RISK_LEVEL"
exit 1
fi# Get risk level
mcp-shark-cli scan -c mcp-config.json --token=sk_your_token_here --json | jq -r '.overall_risk_level'
# Get scan ID
mcp-shark-cli scan -c mcp-config.json --token=sk_your_token_here --json | jq -r '.id'
# Check if scan was successful
mcp-shark-cli scan -c mcp-config.json --token=sk_your_token_here --json | jq -r '.status'
# Get rate limit info
mcp-shark-cli scan -c mcp-config.json --token=sk_your_token_here --json | jq '.rate_limit'The CLI expects an MCP configuration file in JSON format. The file can contain servers and/or mcpServers properties:
{
"servers": {
"server-name": {
"type": "stdio",
"command": "node",
"args": ["server.js"],
"env": {
"API_KEY": "your-key"
}
}
},
"mcpServers": {
"mcp-server-name": {
"type": "http",
"url": "https://api.example.com/mcp/",
"headers": {
"Authorization": "Bearer token"
}
}
}
}{
"type": "stdio",
"command": "npx",
"args": ["-y", "@package/name"],
"env": {}
}{
"type": "http",
"url": "https://api.example.com/mcp/",
"headers": {
"X-Custom-Header": "value"
}
}{
"type": "websocket",
"url": "wss://api.example.com/mcp/"
}- All servers from both
serversandmcpServersare included - If a server name exists in both,
mcpServerstakes precedence - MCP servers without a
typeproperty default tostdio
The CLI integrates with the Smart Scan API at https://smart.mcpshark.sh.
POST /api/scans: Create a new scan (perform security scan)GET /api/scans/{id}: Retrieve scan status and details by scan ID
All API requests require authentication using a Bearer token:
- Provide the token via
--tokencommand-line option, or - Set the
APP_TOKENenvironment variable
- Default rate limit: 3 scans per day per token
- Rate limit is configurable per token in the database
- Rate limit resets at midnight UTC
- Rate limit information is included in successful responses
{
"success": true,
"data": {
"overall_risk_level": "high",
"overall_reason": "Multiple high-risk tools detected...",
"tool_findings": [...],
"resource_findings": [...],
"prompt_findings": [...],
"notable_patterns": [...],
"recommendations": [...]
},
"scan_id": "uuid-here",
"rate_limit": {
"limit": 3,
"remaining": 2
}
}Rate Limit Exceeded (429):
{
"error": "Rate limit exceeded",
"message": "You have reached your daily limit of 3 scans. Please try again tomorrow.",
"limit": 3,
"remaining": 0
}Invalid Token (401):
{
"error": "Invalid or expired token"
}Bad Request (400):
{
"error": "Invalid request body. Expected JSON with MCP server data."
}Step 1: Create a configuration file (mcps.json):
{
"mcpServers": {
"@21st-dev/magic": {
"command": "npx",
"args": ["-y", "@21st-dev/magic@latest", "API_KEY=\"your-key\""]
},
"github": {
"type": "http",
"url": "https://api.githubcopilot.com/mcp/",
"headers": {
"Authorization": "Bearer your-github-token"
}
}
}
}Step 2: Run a scan:
export APP_TOKEN=sk_your_token_here
mcp-shark-cli scan -c mcps.json --verboseStep 3: Check scan results (if needed):
mcp-shark-cli check --scan-id=scan-abc123{
"mcpServers": {
"local-tool": {
"command": "npx",
"args": ["-y", "@21st-dev/magic@latest", "API_KEY=\"your-key\""]
}
}
}{
"mcpServers": {
"github": {
"type": "http",
"url": "https://api.githubcopilot.com/mcp/",
"headers": {
"Authorization": "Bearer your-token"
}
}
}
}{
"mcpServers": {
"websocket-server": {
"type": "websocket",
"url": "wss://api.example.com/mcp/"
}
}
}- Rate limit is set to 3 scans per day per account
- Features may change
- We appreciate your patience and understanding
The banner will be displayed when running scan commands to remind users of this limitation.
We welcome contributions! Please see our Contributing Guide for details.
- Report bugs: Open an issue
- Request features: Open an issue
- Submit PRs: Fork and contribute
ISC
- Web Application: https://smart.mcpshark.sh
- Documentation: Full Documentation
- Issues: Report bugs or request features
- Repository: GitHub