Legacy Device Debugger MCP Server

Legacy Device Debugger MCP Server

This MCP server helps debug legacy devices behind proxies in OT environments by analyzing web interfaces and generating custom rewrite rules to fix proxy-related issues.

Category
访问服务器

README

Legacy Device Debugger MCP Server

An MCP (Model Context Protocol) server specifically designed for debugging legacy devices behind proxies in OT (Operational Technology) environments. This server helps support teams identify and fix proxy-related issues independently using custom header rewrite rules, eliminating the need to escalate to development teams.

Overview

Legacy devices in OT environments often have issues working behind proxies due to hardcoded IP addresses, hostname references, and outdated web technologies. This MCP server automates the debugging process and generates appropriate rewrite rules to fix these issues.

Features

🔍 Automated Page Analysis

  • Loads device web interfaces using Playwright
  • Detects network errors, console errors, and loading issues
  • Identifies broken resources and problematic URL patterns
  • Checks for WebSocket connection problems

🛠️ Custom Header Rewrite Rules Generation

  • Automatically generates proxy configuration rules
  • Supports various rule types: header manipulation, body rewriting, redirects
  • Handles common issues like device IP references and broken links

📋 Systematic Debugging Workflow

  • Follows established OT debugging procedures
  • Provides step-by-step analysis and recommendations
  • Generates actionable results for support teams

🌐 Network Analysis

  • Performs curl-like header analysis
  • Detects redirects to device IP/hostname
  • Identifies CSP and other proxy-blocking headers

Installation

# Clone the repository
git clone <repository-url>
cd legacy-device-debugger-mcp

# Install dependencies
npm install

# Install Playwright browsers
npx playwright install chromium

# Build the project
npm run build

Usage

As an MCP Server

Add to your MCP client configuration (e.g., Claude Desktop):

{
  "mcpServers": {
    "legacy-device-debugger": {
      "command": "node",
      "args": ["/absolute/path/to/legacy-device-debugger-mcp/build/index.js"]
    }
  }
}

Available Tools

1. analyze-device-page

Comprehensive analysis of a device's web interface.

Parameters:

  • deviceUrl (string): URL of the legacy device's web interface
  • timeout (number, optional): Timeout in milliseconds (default: 30000)

Example:

Please analyze this legacy device: http://192.168.1.100:8080

2. curl-analysis

HTTP header analysis similar to curl commands.

Parameters:

  • deviceUrl (string): URL of the legacy device

Example:

Perform curl analysis on http://192.168.1.100:8080

3. generate-rewrite-rules

Generate specific rewrite rules for common issues.

Parameters:

  • issueType: Type of issue (device_ip_references, broken_links, image_loading, etc.)
  • deviceUrl: Device URL
  • problemPattern (optional): Specific pattern causing issues
  • targetPath (optional): Specific path needing rewriting

Example:

Generate rewrite rules for broken_links issue on http://192.168.1.100:8080

4. debug-workflow

Complete debugging workflow following OT best practices.

Parameters:

  • deviceUrl: URL of the legacy device
  • deviceIP (optional): Device IP address if known
  • deviceHostname (optional): Device hostname if known

Example:

Run complete debug workflow for http://rtp-acl-bms:8080

Debugging Workflow

The server follows this systematic approach:

  1. Enable Default Rules & Basic Analysis

    • Check if web page loads at all
    • Identify partial loading issues
    • Detect broken images and resources
  2. Network Error Detection

    • Monitor 404/500 errors
    • Check for connection failures
    • Identify requests to device IP/hostname
  3. Header Analysis

    • Perform curl-like analysis
    • Check response headers for problematic patterns
    • Identify redirects and CSP issues
  4. Generate Rewrite Rules

    • Create appropriate proxy configuration
    • Handle common patterns like device IP references
    • Generate header manipulation rules
  5. Provide Recommendations

    • Actionable steps for support teams
    • Escalation guidance if needed
    • Direct access testing procedures

Common Use Cases

1. Device References Hardcoded IPs

Issue: Device web interface references its own IP address in resources Solution: Body rewrite rules to replace IP with external FQDN

2. Broken CSS/JS Loading

Issue: Stylesheets and scripts fail to load through proxy Solution: Header rewrite rules and resource path corrections

3. WebSocket Connection Issues

Issue: WebSocket connections bypass proxy or fail Solution: Protocol upgrade rules and hostname rewriting

4. Redirect to Device IP

Issue: Device redirects users to its internal IP Solution: Location header rewrite rules

Rewrite Rule Types

Header Rules

{
  "type": "header",
  "action": "add|replace|remove|append",
  "headerName": "X-Forwarded-Host",
  "headerValue": "{{DEVICE_EXTERNAL_FQDN}}"
}

Body Rules

{
  "type": "body",
  "action": "find_replace",
  "pattern": "rtp-acl-bms/static/jquery.min.js",
  "replacement": "{{DEVICE_EXTERNAL_FQDN}}/static/jquery.min.js"
}

Redirect Rules

{
  "type": "redirect",
  "action": "replace",
  "pattern": "{{DEVICE_IP}}",
  "replacement": "{{DEVICE_EXTERNAL_FQDN}}"
}

Development

Project Structure

├── src/
│   └── index.ts          # Main MCP server implementation
├── build/                # Compiled JavaScript
├── .vscode/
│   └── mcp.json         # MCP server configuration
├── .github/
│   └── copilot-instructions.md
└── README.md

Building

npm run build

Testing

# Test the server directly
npm run dev

# Test with MCP client
node build/index.js

Configuration Variables

The server uses these placeholder variables in generated rules:

  • {{DEVICE_EXTERNAL_FQDN}}: External FQDN for the device
  • {{DEVICE_INTERNAL_IP}}: Internal IP address of the device
  • {{DEVICE_IP}}: Generic device IP placeholder

Troubleshooting

Common Issues

  1. Playwright Installation

    npx playwright install chromium
    
  2. Permission Errors

    chmod +x build/index.js
    
  3. Module Resolution Ensure package.json has "type": "module"

Debug Mode

Set environment variable for verbose logging:

DEBUG=1 node build/index.js

Contributing

  1. Follow the established debugging workflow patterns
  2. Add appropriate error handling for network operations
  3. Generate actionable rewrite rules in the correct format
  4. Include comprehensive documentation

License

ISC License - see LICENSE file for details.

Support

For issues with legacy device debugging:

  1. Use the complete debug workflow first
  2. Check generated rewrite rules
  3. Test with direct device access
  4. Escalate to DevOps team with analysis results

推荐服务器

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 模型以安全和受控的方式获取实时的网络信息。

官方
精选