CanIUse MCP

CanIUse MCP

Provides intelligent CSS/JS feature compatibility checking with configurable browser targets, polyfill support, and smart project scanning. Enables developers to automatically detect browser compatibility issues and get actionable remediation steps with build tool configurations.

Category
访问服务器

README

🚀 CanIUse MCP - Browser Compatibility Intelligence

A powerful Model Context Protocol (MCP) server that provides intelligent CSS/JS feature compatibility checking with configurable browser targets, polyfill support, and smart project scanning. Perfect for web developers using AI-powered tools like Cursor, Claude, and other MCP-compatible clients.

npm version License: MIT

✨ Key Features

  • 🔍 Smart Project Scanning: Automatically detect CSS/JS features in your codebase
  • 🎯 Configurable Browser Targets: Support for any browser version with custom baselines
  • 💊 Polyfill-Aware Checking: Mark features as "supported" when you have polyfills available
  • ⚡ Batch Compatibility Analysis: Check entire projects across multiple browsers instantly
  • 🛠️ Actionable Remediation: Get specific npm install commands, code examples, and configs
  • 📋 Complete Toolchain Generation: Auto-generate Babel, PostCSS, Webpack, and CI configurations
  • 🔧 Runtime Configuration: Configure via files, environment variables, or MCP commands

📦 Installation

Global Installation (Recommended)

npm install -g @mahdiar/caniuse-mcp

Local Installation

npm install @mahdiar/caniuse-mcp

🔌 Setup for MCP Clients

Option 1: Global Installation (Recommended)

First, install the package globally:

npm install -g @mahdiar/caniuse-mcp

Cursor IDE

Add to your Cursor settings (Cmd/Ctrl + , → MCP):

{
  "mcpServers": {
    "caniuse": {
      "command": "caniuse-mcp",
      "args": [],
      "env": {}
    }
  }
}

Claude Desktop

Add to claude_desktop_config.json:

{
  "mcpServers": {
    "caniuse": {
      "command": "caniuse-mcp",
      "args": [],
      "env": {}
    }
  }
}

Option 2: Using npx (Alternative)

If global installation doesn't work, use npx:

Cursor IDE

{
  "mcpServers": {
    "caniuse": {
      "command": "npx",
      "args": ["@mahdiar/caniuse-mcp"],
      "env": {}
    }
  }
}

Claude Desktop

{
  "mcpServers": {
    "caniuse": {
      "command": "npx",
      "args": ["@mahdiar/caniuse-mcp"],
      "env": {}
    }
  }
}

Option 3: Direct Node.js Path

If you have issues with command resolution:

Find your global npm bin path:

npm config get prefix
# On macOS/Linux, usually: /usr/local/bin or ~/.npm-global/bin
# On Windows: C:\Users\[username]\AppData\Roaming\npm

Use full path in MCP configuration:

{
  "mcpServers": {
    "caniuse": {
      "command": "/usr/local/bin/caniuse-mcp",
      "args": [],
      "env": {}
    }
  }
}

⚡ Quick Start

1. Basic Compatibility Check

// Check your project against default baseline (Chrome 37)
scan_project

2. Configure Your Target Browser

// Set up for Chrome 57 with CSS Variables polyfill
manage_config {
  "action": "set_baseline",
  "baseline": "chrome-57"
}

manage_config {
  "action": "add_polyfill", 
  "polyfill": "css-variables"
}

3. Check Specific Features

// Check if features work in your target browsers
check_compatibility {
  "features": ["css-variables", "promise-allsettled"],
  "targets": ["chrome-57", "firefox-70"]
}

4. Get Fix Recommendations

// Get actionable remediation steps
get_fixes {
  "features": ["css-grid", "arrow-functions"],
  "includeCommands": true,
  "includeExamples": true
}

🛠️ Available Tools

Core Tools

scan_project - Smart Project Analysis

Automatically scans your project and detects compatibility issues.

// Basic project scan
scan_project

// Advanced scanning with custom targets
scan_project {
  "projectPath": "./src",
  "targets": ["chrome-57", "firefox-esr", "safari-12"],
  "maxDepth": 3,
  "excludeDirs": ["node_modules", "dist"]
}

check_compatibility - Feature Testing

Check specific features or files against browser targets.

// Test specific features
check_compatibility {
  "features": ["css-variables", "promise-allsettled"],
  "targets": ["chrome-57", "firefox-70"]
}

// Analyze specific files
check_compatibility {
  "files": ["src/styles/main.css", "src/utils/async.js"],
  "targets": ["chrome-57"]
}

get_fixes - Get Solutions

Receive actionable remediation steps and polyfill recommendations.

get_fixes {
  "features": ["css-variables", "promise-allsettled"],
  "priority": "critical",
  "includeExamples": true,
  "includeCommands": true
}

generate_configs - Build Tool Setup

Generate complete build configurations for your toolchain.

generate_configs {
  "configType": "all",
  "target": "chrome-57",
  "includePolyfills": true,
  "projectType": "react"
}

manage_config - Configuration Management

Configure baselines, polyfills, and browser targets.

// View current configuration
manage_config { "action": "view" }

// Set baseline browser
manage_config { 
  "action": "set_baseline", 
  "baseline": "chrome-57" 
}

// Add polyfill support
manage_config { 
  "action": "add_polyfill", 
  "polyfill": "css-variables" 
}

// Add custom browser target
manage_config {
  "action": "add_target",
  "targetName": "chrome-65",
  "browser": "chrome",
  "version": "65"
}

🎯 Browser Targets Supported

Target Browser Version Use Case
chrome-37 Chrome 37 Legacy Android support
chrome-latest Chrome Latest Modern development
firefox-esr Firefox 78 ESR Enterprise compatibility
safari-12 Safari 12 iOS 12+ support
ie-11 Internet Explorer 11 Legacy Windows support
edge-legacy Edge 18 Pre-Chromium Edge

🔧 Configuration

Configuration File (.caniuse-config.json)

Create a .caniuse-config.json in your project root to customize behavior:

{
  "defaultBaseline": "chrome-57",
  "customTargets": {
    "chrome-57": { "browser": "chrome", "version": "57" },
    "chrome-65": { "browser": "chrome", "version": "65" }
  },
  "polyfills": [
    "css-variables", 
    "promise-allsettled"
  ],
  "overrides": {
    "css-variables": "supported",
    "promise-allsettled": "supported"
  }
}

Quick Configuration Setup

// Create a configuration template
manage_config { "action": "create_template" }

// Or use pre-built examples

Copy example configurations from the examples/ directory:

# CSS Variables support for older browsers
cp node_modules/caniuse-mcp/examples/css-variables-polyfill.json .caniuse-config.json

# Promise.allSettled polyfill configuration  
cp node_modules/caniuse-mcp/examples/promise-allsettled-polyfill.json .caniuse-config.json

# Enterprise multi-browser support
cp node_modules/caniuse-mcp/examples/enterprise-config.json .caniuse-config.json

Environment Variables

Configure via environment variables for CI/CD:

# Set default baseline
export CANIUSE_DEFAULT_BASELINE="chrome-57"

# Configure polyfills
export CANIUSE_POLYFILLS='["css-variables","promise-allsettled"]'

# Set feature overrides
export CANIUSE_OVERRIDES='{"css-variables":"supported","promise-allsettled":"supported"}'

💡 Real-World Use Cases

1. CSS Variables Polyfill Support

// Set up CSS Variables for older browsers
manage_config {
  "action": "add_polyfill",
  "polyfill": "css-variables" 
}

manage_config {
  "action": "set_override",
  "feature": "css-variables",
  "override": "supported"
}

// Now CSS Variables will be treated as supported
check_compatibility {
  "features": ["css-variables"],
  "targets": ["chrome-40", "ie-11"]
}

2. Promise.allSettled Polyfill Support

// Configure Promise.allSettled polyfill
manage_config {
  "action": "add_polyfill",
  "polyfill": "promise-allsettled"
}

// Set baseline to older Chrome that needs polyfill
manage_config {
  "action": "set_baseline", 
  "baseline": "chrome-60"
}

// Check compatibility - will show as supported due to polyfill
check_compatibility {
  "features": ["promise-allsettled"],
  "targets": ["chrome-60", "firefox-70"]
}

// Get implementation guidance
get_fixes {
  "features": ["promise-allsettled"],
  "includeCommands": true,
  "includeExamples": true
}

3. Enterprise Legacy Browser Support

// Scan for enterprise browser compatibility
scan_project {
  "targets": ["chrome-50", "firefox-esr", "safari-12", "ie-11"]
}

// Configure extensive polyfill support
manage_config { "action": "create_template" }
// Edit .caniuse-config.json to include:
// "polyfills": ["css-variables", "promise-allsettled", "fetch", "object-assign"]

4. Modern Development with Progressive Enhancement

// Check latest browser features
check_compatibility {
  "features": ["css-container-queries", "css-cascade-layers"],
  "targets": ["chrome-latest", "firefox-latest", "safari-latest"]
}

// Get fallback strategies
get_fixes {
  "features": ["css-container-queries"],
  "includeExamples": true
}

📈 Enhanced Output Examples

Scan Project Output

{
  "status": "completed",
  "project": {
    "path": "./src",
    "scanned": "24 files",
    "jsFiles": 12,
    "cssFiles": 8,
    "featuresDetected": 15
  },
  "compatibility": {
    "targets": ["chrome-37"],
    "overallScore": 73,
    "criticalIssues": 3,
    "commonUnsupported": ["css-grid", "arrow-functions", "const"]
  },
  "recommendations": [
    {
      "type": "critical",
      "title": "Critical Features Unsupported",
      "message": "These essential features are unsupported: css-grid, arrow-functions",
      "action": "Implement polyfills or use alternative approaches immediately"
    }
  ],
  "nextSteps": [
    {
      "step": 1,
      "title": "Get specific fixes",
      "command": "Use get_fixes tool with features: css-grid, arrow-functions, const",
      "priority": "high"
    }
  ]
}

Get Fixes Output

{
  "features": ["css-grid"],
  "fixes": [
    {
      "feature": "css-grid",
      "priority": "critical",
      "alternatives": ["flexbox", "CSS tables", "float layouts"],
      "polyfills": ["CSS Grid Polyfill"],
      "commands": [
        {
          "type": "install",
          "description": "Install css-grid polyfills",
          "command": "npm install postcss-grid-kiss --save-dev"
        }
      ],
      "cssExample": "/* Instead of Grid */\n.container { display: grid; }\n\n/* Use Flexbox */\n.container { display: flex; }"
    }
  ],
  "quickStart": [
    {
      "step": 1,
      "title": "Install critical polyfills",
      "command": "npm install css-grid-polyfill --save",
      "priority": "critical"
    }
  ]
}

🔧 Configuration Examples

Babel Configuration (.babelrc)

{
  "presets": [
    ["@babel/preset-env", {
      "targets": { "chrome": "37" },
      "useBuiltIns": "usage",
      "corejs": 3
    }],
    "@babel/preset-react"
  ]
}

PostCSS Configuration

module.exports = {
  plugins: {
    'autoprefixer': {
      overrideBrowserslist: ['Chrome >= 37']
    },
    'postcss-custom-properties': {
      preserve: false
    }
  }
};

🏗️ Development Workflow Integration

Git Hooks

# .husky/pre-commit
echo "🔍 Checking browser compatibility..."
npx @mahdiar/caniuse-mcp scan_project

CI/CD Pipeline

# .github/workflows/compatibility.yml
- name: Check Browser Compatibility
  run: |
    npm install -g caniuse-mcp
    caniuse-mcp scan_project
    caniuse-mcp get_fixes --features="css-grid,promise-allsettled"

🚨 Troubleshooting

Common Issues

"No tools found" Error in Cursor/Claude

This is the most common issue. Try these solutions in order:

1. Verify Global Installation

# Check if package is installed globally
npm list -g @mahdiar/caniuse-mcp

# If not installed, install globally
npm install -g @mahdiar/caniuse-mcp

# Test the command directly
caniuse-mcp
# Should show: "🚀 Enhanced CanIUse MCP Server running on stdio"

2. Check Your PATH

# Verify npm global bin is in your PATH
echo $PATH | grep $(npm config get prefix)/bin

# If not found, add to your shell profile (~/.bashrc, ~/.zshrc, etc.)
export PATH="$(npm config get prefix)/bin:$PATH"

# Then restart your terminal and MCP client

3. Try Different Installation Methods

# Method 1: Clean reinstall
npm uninstall -g @mahdiar/caniuse-mcp
npm install -g @mahdiar/caniuse-mcp

# Method 2: Install without global flag and use npx
npm install @mahdiar/caniuse-mcp
# Then use "npx @mahdiar/caniuse-mcp" in MCP config

# Method 3: Install via different package manager
# Using yarn
yarn global add @mahdiar/caniuse-mcp

# Using pnpm
pnpm add -g @mahdiar/caniuse-mcp

4. Update MCP Configuration Format Make sure your Cursor/Claude configuration uses the correct format:

❌ Incorrect:

{
  "mcpServers": {
    "caniuse": {
      "command": "@mahdiar/caniuse-mcp"
    }
  }
}

✅ Correct:

{
  "mcpServers": {
    "caniuse": {
      "command": "caniuse-mcp",
      "args": [],
      "env": {}
    }
  }
}

5. Test MCP Server Manually

# Test if the server responds to MCP protocol
echo '{"jsonrpc": "2.0", "id": 1, "method": "tools/list"}' | caniuse-mcp

# Should return a JSON response with available tools

Other Common Issues

"Module not found" errors

# Make sure package is installed correctly
npm install -g @mahdiar/caniuse-mcp

# Clear npm cache if needed
npm cache clean --force

# Or use npx for one-time execution
npx @mahdiar/caniuse-mcp

Configuration not loading

# Check if config file exists and is valid JSON
cat .caniuse-config.json | jq '.'

# Reset to defaults if corrupted
manage_config { "action": "reset" }

Polyfills not working

// Verify polyfill is added
manage_config { "action": "view" }

// Check override is set
manage_config {
  "action": "set_override",
  "feature": "css-variables",
  "override": "supported"
}

Permission errors on macOS/Linux

# Fix npm permissions
sudo chown -R $(whoami) $(npm config get prefix)/{lib/node_modules,bin,share}

# Or reinstall npm with a node version manager
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash
nvm install node

Platform-Specific Issues

macOS

# If using Homebrew node
brew reinstall node

# Check npm prefix
npm config set prefix ~/.npm-global
export PATH=~/.npm-global/bin:$PATH

Windows

# Run as Administrator and install globally
npm install -g @mahdiar/caniuse-mcp

# Add npm global path to system PATH
# Usually: C:\Users\[username]\AppData\Roaming\npm

Linux

# Use node version manager to avoid permission issues
curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash -
sudo apt-get install -y nodejs

Debug Mode

Enable verbose logging with environment variables:

export DEBUG="caniuse-mcp*"
caniuse-mcp

Still Having Issues?

  1. Check Node.js version: Requires Node.js 18+

    node --version
    
  2. Verify npm configuration:

    npm config list
    npm doctor
    
  3. Try a clean environment:

    # Create a test directory
    mkdir test-caniuse && cd test-caniuse
    npx @mahdiar/caniuse-mcp
    
  4. Report the issue: If none of the above work, please open an issue at https://github.com/Amirmahdi-Kaheh/caniuse-mcp/issues with:

    • Your operating system
    • Node.js version (node --version)
    • npm version (npm --version)
    • Complete error message
    • MCP client you're using (Cursor, Claude Desktop, etc.)

🔗 Links & Resources

  • NPM Package: https://www.npmjs.com/package/@mahdiar/caniuse-mcp
  • Can I Use Database: https://caniuse.com
  • Model Context Protocol: https://docs.anthropic.com/en/docs/build-with-claude/mcp
  • Cursor IDE: https://cursor.sh
  • Claude Desktop: https://claude.ai/desktop

🤝 Contributing

We welcome contributions! Please see our contributing guidelines:

  1. Report Issues: Found a bug or missing feature? Open an issue
  2. Feature Requests: Have ideas for new functionality? Let us know
  3. Pull Requests: Want to contribute code? Fork and submit a PR
  4. Documentation: Help improve our docs and examples

Development Setup

git clone <your-fork-url>
cd caniuse-mcp
npm install
npm run dev  # Start in development mode

📊 Why Use CanIUse MCP?

Before

  • Manual caniuse.com lookups
  • Guessing at polyfill needs
  • Trial-and-error browser testing
  • Separate compatibility checking tools

After

  • AI-powered compatibility analysis
  • Automated polyfill recommendations
  • Smart project-wide scanning
  • Integrated development workflow

70% faster compatibility checking with actionable results 🚀

📄 License

MIT License © 2025 Mahdiar Kaheh

Built for the developer community - Free to use, modify, and distribute.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选