MCP Hub
Back to servers

MCP Interface Validator

Automatically validates consistency between AI-generated frontend and backend code by enforcing OpenAPI 3.0 specifications and injecting smart constraints into AI prompts.

Stars
4
Updated
Jul 15, 2025
Validated
Jan 17, 2026

MCP Interface Validator - Intelligent Interface Constraints & Validation

Website npm

❌ Without MCP Interface Validator

AI-generated frontend and backend code may have interface inconsistency issues:

  • ❌ Frontend API calls don't match backend implementations
  • ❌ Inconsistent data structure definitions causing runtime errors
  • ❌ Lack of unified interface specifications
  • ❌ Manual interface consistency checking is inefficient

✅ With MCP Interface Validator

MCP Interface Validator automatically validates interface consistency between AI-generated frontend and backend code using OpenAPI 3.0 specifications.

Add .use interface to your prompts in Cursor:

Develop a user login system with frontend form and backend API. .use interface
Create a product management module with CRUD operations. .use interface

MCP Interface Validator will:

  • 🔍 Smart Constraint Injection - Automatically add interface validation constraints to AI prompts
  • 📋 OpenAPI Specification Validation - Ensure generated code follows API specifications
  • 🔄 Real-time Interface Checking - Validate frontend-backend interface consistency
  • 🛠️ Multi-tool Support - Support Cursor, Windsurf, Trae, Augment and other AI tools

🚀 Core Features

Intelligent Constraint System

  • .use interface Command - One-click activation of interface validation constraints
  • Automatic Prompt Injection - Smart recognition and injection of OpenAPI constraint prompts
  • Multi-language Support - Support for Chinese and English commands
  • Fuzzy Instruction Processing - Handle imprecise user instructions

Interface Validation Engine

  • OpenAPI 3.0 Support - Complete Swagger specification validation
  • Real-time Validation - Real-time interface checking during code generation
  • Error Reporting - Detailed interface inconsistency reports
  • Auto-fix Suggestions - Provide interface repair suggestions

Multi-tool Integration

  • Cursor - Full support for Cursor AI programming assistant
  • Windsurf - Integration with Windsurf development environment
  • Trae - Support for Trae AI tools
  • Augment - Compatible with Augment code assistant
  • Claude Desktop - Support for Claude desktop application

🛠️ Quick Start

Requirements

  • Node.js >= v18.0.0
  • AI tools supporting MCP protocol (Cursor, Windsurf, Claude Desktop, etc.)

Global Installation

npm install -g mcp-interface-validator

Install from GitHub

npm install -g https://github.com/xiaoxiaofeiya/mcp-interface-validator.git

📦 Configuration Setup

Augment Code

在Augment配置中添加:

{
  "mcpServers": {
    "interface-validator": {
      "command": "mcp-interface-validator",
      "transport": "stdio",
      "env": {
        "NODE_ENV": "production"
      }
    }
  }
}

Claude Desktop

  1. 打开Claude Desktop配置文件:

    • Windows: %APPDATA%\Claude\claude_desktop_config.json
    • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
    • Linux: ~/.config/Claude/claude_desktop_config.json
  2. 添加MCP服务器配置:

{
  "mcpServers": {
    "mcp-interface-validator": {
      "command": "npx",
      "args": ["mcp-interface-validator"],
      "env": {
        "NODE_ENV": "production"
      }
    }
  }
}

Cline (Claude in VSCode)

在VSCode的Cline扩展设置中添加:

{
  "cline.mcpServers": {
    "mcp-interface-validator": {
      "command": "npx",
      "args": ["mcp-interface-validator"],
      "env": {
        "NODE_ENV": "production"
      }
    }
  }
}

Codex (GitHub Copilot)

在GitHub Copilot配置中添加:

{
  "github.copilot.advanced": {
    "mcpServers": {
      "interface-validator": {
        "command": "mcp-interface-validator",
        "args": ["--stdio"],
        "enabled": true
      }
    }
  }
}

Cursor AI

在Cursor设置中添加:

{
  "mcp": {
    "servers": {
      "interface-validator": {
        "command": "mcp-interface-validator",
        "args": ["--stdio"],
        "env": {
          "NODE_ENV": "production"
        }
      }
    }
  }
}

Roo (Roo.dev)

在Roo配置文件中添加:

{
  "tools": {
    "mcp-interface-validator": {
      "type": "mcp",
      "command": "mcp-interface-validator",
      "args": ["--stdio"],
      "description": "API interface validation for generated code"
    }
  }
}

Trae AI

在Trae配置中添加:

{
  "integrations": {
    "mcp": {
      "servers": {
        "interface-validator": {
          "command": "mcp-interface-validator",
          "transport": "stdio",
          "autoStart": true
        }
      }
    }
  }
}

VSCode (with MCP extension)

在VSCode的settings.json中添加:

{
  "mcp.servers": {
    "interface-validator": {
      "command": "mcp-interface-validator",
      "args": ["--stdio"],
      "env": {
        "NODE_ENV": "production"
      }
    }
  }
}

Windsurf

在Windsurf配置中添加:

{
  "extensions": {
    "mcp-interface-validator": {
      "enabled": true,
      "command": "mcp-interface-validator",
      "args": ["--stdio"],
      "config": "./config/mcp-validator.json"
    }
  }
}

📋 配置文件设置

创建配置文件

在项目根目录创建 mcp-validator.json

{
  "server": {
    "name": "mcp-interface-validator",
    "version": "1.0.0",
    "description": "MCP Interface Validation Component"
  },
  "validation": {
    "strictMode": true,
    "allowAdditionalProperties": false,
    "validateExamples": true,
    "customRules": [
      "require-response-schemas",
      "validate-parameter-types",
      "check-security-definitions"
    ]
  },
  "integrations": {
    "cursor": { "enabled": true },
    "windsurf": { "enabled": true },
    "augment": { "enabled": true },
    "trae": { "enabled": true }
  },
  "monitoring": {
    "watchPatterns": [
      "**/*.ts", "**/*.js", "**/*.json", "**/*.yaml"
    ],
    "ignorePatterns": [
      "node_modules/**", "build/**", "dist/**"
    ],
    "debounceMs": 500
  }
}

🧪 验证安装

测试MCP服务器

# 检查版本
mcp-interface-validator --version

# 测试STDIO通信
echo '{"jsonrpc": "2.0", "id": 1, "method": "initialize", "params": {"protocolVersion": "2024-11-05", "capabilities": {"tools": {}}, "clientInfo": {"name": "test", "version": "1.0.0"}}}' | mcp-interface-validator

测试工具功能

# 列出可用工具
echo '{"jsonrpc": "2.0", "id": 2, "method": "tools/list", "params": {}}' | mcp-interface-validator

🔍 使用示例

基本验证

# 验证API接口
mcp-interface-validator validate --spec ./api-spec.yaml --code ./src/api.ts

实时监控

# 启动文件监控
mcp-interface-validator monitor --watch ./src --spec ./api-spec.yaml

🛠️ 故障排除

常见问题

  1. 命令未找到

    # 确保全局安装
    npm install -g mcp-interface-validator
    
    # 或使用npx
    npx mcp-interface-validator --version
    
  2. 权限错误

    # Windows (以管理员身份运行)
    npm install -g mcp-interface-validator
    
    # macOS/Linux
    sudo npm install -g mcp-interface-validator
    
  3. 配置文件未找到

    # 创建默认配置
    mcp-interface-validator init
    

调试模式

# 启用详细日志
DEBUG=mcp-interface-validator* mcp-interface-validator

# 或设置环境变量
export NODE_ENV=development
mcp-interface-validator --verbose

📊 性能优化

大型项目配置

{
  "monitoring": {
    "maxFileSize": 1048576,
    "debounceMs": 1000,
    "ignorePatterns": [
      "node_modules/**",
      "**/*.test.*",
      "**/*.spec.*",
      "coverage/**"
    ]
  },
  "validation": {
    "cacheEnabled": true,
    "parallelProcessing": true,
    "maxConcurrency": 4
  }
}

🔐 安全配置

生产环境

{
  "security": {
    "enableSandbox": true,
    "allowedPaths": ["./src", "./api"],
    "maxFileSize": 1048576,
    "timeoutMs": 30000
  },
  "logging": {
    "level": "warn",
    "sanitizeOutput": true
  }
}

📈 监控和日志

日志配置

{
  "logging": {
    "level": "info",
    "format": "structured",
    "output": "./logs/mcp-validator.log",
    "rotation": {
      "enabled": true,
      "maxSize": "10MB",
      "maxFiles": 5
    }
  }
}

🚀 生产部署

Docker部署

FROM node:18-alpine
WORKDIR /app
COPY package*.json ./
RUN npm ci --only=production
COPY . .
EXPOSE 3000
CMD ["mcp-interface-validator", "--port", "3000"]

系统服务

# 创建systemd服务
sudo tee /etc/systemd/system/mcp-validator.service > /dev/null <<EOF
[Unit]
Description=MCP Interface Validator
After=network.target

[Service]
Type=simple
User=node
WorkingDirectory=/opt/mcp-validator
ExecStart=/usr/bin/node /opt/mcp-validator/build/index.js
Restart=always

[Install]
WantedBy=multi-user.target
EOF

# 启动服务
sudo systemctl enable mcp-validator
sudo systemctl start mcp-validator

🎯 Usage

Basic Usage

  1. Activate Smart Constraints: Add .use interface to your AI prompts
  2. Describe Requirements: Normally describe your development needs
  3. Automatic Validation: System automatically injects interface validation constraints
  4. Get Results: Receive code that complies with OpenAPI specifications

Example Scenarios

User Management System:

Develop user registration and login functionality with frontend form validation and backend API. .use interface

Product Management Module:

Create product CRUD operations, frontend using React, backend using Express. .use interface

Order Processing System:

Implement order creation, query, and update functions, ensuring frontend-backend data structure consistency. .use interface

🔧 Advanced Configuration

Custom Constraint Rules

Create constraint-config.json file:

{
  "openapi": {
    "version": "3.0.0",
    "strictMode": true,
    "validateResponses": true
  },
  "validation": {
    "realTime": true,
    "autoFix": true
  }
}

Multi-language Support

Supported command formats:

  • Chinese: .use interface, .使用接口
  • English: .use interface, .apply constraints

📚 Documentation Links

🌟 Key Advantages

  • Zero Configuration Startup - Ready to use after installation, no complex configuration needed
  • Smart Recognition - Automatically recognize interface validation requirements
  • Real-time Feedback - Instant interface consistency checking
  • Cross-platform Support - Full support for Windows, macOS, Linux
  • Open Source & Free - MIT license, completely open source

🤝 Contributing

Issues and Pull Requests are welcome!

📄 License

MIT License - See LICENSE file for details

Reviews

No reviews yet

Sign in to write a review