本地扫描MCP服务器

一个用于扫描本地代码和本地URL的模型上下文协议(MCP)服务器,提供代码验证、截图捕获和网页分析功能,适用于本地开发环境与AI助手的交互。

  • by treaties-ai
  • JavaScript
  • 本地部署
  • 更新于
在 GitHub 查看 treaties-ai/local-scanner-mcp

使用说明

本地扫描仪MCP服务器

用于扫描本地代码和本地主机URL的模型上下文协议(MCP)服务器。该服务器提供用于验证代码、捕获屏幕截图和分析在本地主机上运行的网页的工具。

概述

本地扫描程序MCP服务器扩展了AI助手与本地运行的web应用程序和代码文件交互的能力。它弥合了人工智能和本地开发环境之间的差距,使人工智能助手能够:

  • 测试和调试本地运行的web应用程序
  • 捕获屏幕截图以进行视觉验证
  • Lint代码文件,以确保质量和标准合规性
  • 验证HTML的可访问性和标准合规性

此服务器对于使用Cline(VSCode)或Cascade(WindSurf)等人工智能助手的开发人员特别有用,他们希望利用人工智能功能进行本地开发任务。

特性

服务器提供以下工具:

1.扫描主机

访问本地主机URL,捕获控制台日志,并检查运行时错误。

参数:

  • url (必需):要扫描的本地主机URL(必须以开头http://localhost或https://localhost)
  • waitTime (可选):页面加载后的等待时间(毫秒)(默认值:1000)
  • actions (可选):要在页面上执行的操作列表,例如:
    • 点击: { "type": "click", "selector": "#button-id" }
    • 类型: { "type": "type", "selector": "#input-id", "text": "Hello World" }
    • 等待: { "type": "wait", "time": 2000 }

例子:

{
  "url": "http://localhost:3000",
  "waitTime": 2000,
  "actions": [
    { "type": "click", "selector": "#login-button" },
    { "type": "type", "selector": "#username", "text": "testuser" },
    { "type": "type", "selector": "#password", "text": "password" },
    { "type": "click", "selector": "#submit-button" },
    { "type": "wait", "time": 1000 }
  ]
}

2.屏幕截图_主持人

截取本地主机URL的屏幕截图。

参数:

  • url (必填):要截图的本地主机URL(必须以开头http://localhost或https://localhost)
  • fullPage (可选):是否进行全页截图(默认:false)
  • waitTime (可选):页面加载后的等待时间(毫秒)(默认值:1000)

例子:

{
  "url": "http://localhost:3000/dashboard",
  "fullPage": true,
  "waitTime": 2000
}

3.lint_code

Lint JavaScript、TypeScript或CSS代码文件。

参数:

  • filePath (必填):lint文件的路径
  • language (可选):文件的语言(默认:从文件扩展名自动检测)
    • 选项:“javascript”、“typescript”、“css”

例子:

{
  "filePath": "/path/to/your/file.js",
  "language": "javascript"
}

4.validate_html

验证HTML内容或URL是否符合标准。

参数:

  • source (必填):要验证的HTML内容或URL
  • isUrl (可选):源是否为URL(默认值:false)

例子:

{
  "source": "<html><head><title>Test</title></head><body><h1>Hello World</h1></body></html>",
  "isUrl": false
}

或者对于URL:

{
  "source": "http://localhost:3000",
  "isUrl": true
}

安装

  1. 克隆存储库:
    git clone https://github.com/treaties-ai/local-scanner-mcp.git
    cd local-scanner-mcp
    
  2. 安装依赖项:
    npm install
    
  3. 构建项目:
    npm run build
    
  4. 启动服务器:
    npm start
    

与MCP客户端一起使用

此服务器实现了模型上下文协议(MCP),可以与任何MCP客户端一起使用。

适用于VSCode/Cline

在以下位置编辑MCP设置文件 ~/Library/Application Support/Code/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json:

{
  "mcpServers": {
    "local-scanner": {
      "command": "node",
      "args": ["/Users/your_username/Documents/Cline/MCP/local-scanner-mcp/build/index.js"],
      "disabled": false,
      "autoApprove": []
    }
  }
}

适用于WindSurf/Cascade

在以下位置编辑WindSurf配置文件 ~/Library/Application Support/WindSurf/windsurf_config.json:

{
  "mcpServers": {
    "local-scanner": {
      "command": "node",
      "args": ["/Users/your_username/Documents/WindSurf/MCP/local-scanner-mcp/build/index.js"],
      "disabled": false,
      "autoApprove": []
    }
  }
}

替换 your_username 在两种配置中都使用您的实际用户名。

发展

要添加新工具或增强现有工具,请执行以下操作:

  1. 为新工具参数添加验证函数
  2. 更新中的工具列表 setupToolHandlers 方法
  3. 为新工具实现处理函数
  4. 更新请求处理程序以处理新工具
  5. 构建和测试服务器

许可证

麻省理工学院