Skip to main content
Glama
dark-scientist

Legacy Device Debugger MCP Server

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.

Related MCP server: Android Proxy MCP

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

Available Tools

1 tool
legacydevicedebugthinkingA

A comprehensive sequential thinking tool for debugging legacy OT devices behind proxies following the exact production workflow used by support teams.

This tool implements the precise OT debugging sequence from the production environment:

STEP 1: Enable default rules (automatic on initialization) STEP 2: Analyze page loading status (not loaded / partially loaded / fully loaded) STEP 3: Analyze resources (broken images pointing to device IP, broken links) STEP 4: Analyze WebSocket connections and proxy requirements STEP 5: Analyze redirects and port issues (curl-based analysis) STEP 6: Analyze network failures (404/500) and console errors (MIME type, bootstrap.js) STEP 7: Perform detailed curl analysis for request/response headers

The tool detects and handles these specific OT device issues:

  • Hostname requirements (Error 400 hostname invalid) → Host header rewrite

  • Real IP address requirements → X-Real-IP header addition

  • Bootstrap.js HTTPS protocol issues → https→spdy replacement (DSD-3756)

  • MIME type mismatches → Content-Type header fixes

  • Private API calls requiring JSON body rewrite → Body rewrite with JSON

  • Device IP/hostname references in resources → Body find/replace rules

  • Redirect loops and wrong port onboarding → Location header rewrites

  • WebSocket proxy configuration issues → WebSocket-specific rules

  • "Try again" errors after device upgrades → Comprehensive rule application

Generates production-ready rewrite rules with ALL action types:

  • HEADER REWRITE: find_replace, add, replace, remove, append

  • BODY REWRITE: find_replace for device IP/hostname references

  • JSON BODY REWRITE: Special handling for private-api calls

  • DEFAULT RULES: Enable baseline proxy configuration

Production workflow triggers:

  • "Start debugging for http://device-url" → Initialize browser + enable default rules

  • "Check page loading" → Analyze login page, detect "Try again" errors, check 400 hostname invalid

  • "Analyze images and links" → Find broken resources pointing to device IP/hostname

  • "Check WebSocket" → Detect WebSocket connections and generate proxy rules

  • "Check redirects" → Analyze port redirects, suggest correct onboarding ports

  • "Check network and console errors" → Find 404/500 errors, MIME type issues, bootstrap.js problems

  • "Perform curl analysis" → Detailed header analysis for Location header issues

  • "Generate final report" → Complete analysis with all rules and recommendations

Automatic detection includes:

  • Device hostname/IP pattern matching

  • Private API endpoint identification (/private-api/, /api/private/, /internal/)

  • Bootstrap.js protocol conflicts

  • MIME type mismatch patterns

  • WebSocket connection requirements

  • Redirect loop detection

  • Static resource loading failures

Perfect for OT support teams following established troubleshooting procedures. Generates actionable rewrite rules for immediate application to RA portal. Follows the exact workflow: Enable defaults → Check loading → Analyze resources → Check WebSocket → Check redirects → Network/console errors → Curl analysis.

ParametersJSON Schema
NameRequiredDescriptionDefault
thoughtYesYour current debugging step description (include device URL to start debugging)
branchIdNoBranch identifier for alternative analysis
isRevisionNoWhether this revises previous analysis
thoughtNumberYesCurrent debugging step number
totalThoughtsYesEstimated total debugging steps needed
revisesThoughtNoWhich debugging step is being reconsidered
branchFromThoughtNoBranching point step number
needsMoreThoughtsNoIf more debugging steps are needed
nextThoughtNeededYesWhether another debugging step is needed

TDQS

A3.9/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries the full burden of disclosing behavior. It clearly enumerates the 7-step sequence, the issue types detected, and that it generates production-ready rewrite rules. Some ambiguity remains about whether the tool actually executes curl/browser actions or only reasons about them, but the 'thinking tool' framing makes the intent fairly clear.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness2/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is extremely long and repetitive. The numbered workflow, trigger list, automatic-detection list, and closing recap largely restate the same information. While it is well organized with sections and bullets, it would benefit from substantial trimming; every sentence does not earn its place.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

The tool is complex, has no annotations, and no output schema, so the description must do heavy lifting. It covers purpose, workflow, triggers, detection patterns, and output type (rewrite rules). It does not explicitly describe the return structure or how the final report is delivered, which keeps it from a 5.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the baseline applies. The description adds domain context but does not provide extra meaning for the individual parameters such as thoughtNumber, totalThoughts, branchFromThought, or revisesThought. The schema already covers those adequately.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description uses a specific verb ('debugging') and a clearly defined resource ('legacy OT devices behind proxies'), and further narrows scope by describing a production support workflow. It is immediately evident what this tool is for and how it differs from a generic thinking tool.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description gives strong context for when to use the tool: debugging legacy OT devices behind proxies using the exact support-team workflow. It also provides concrete trigger phrases like 'Start debugging for http://device-url' and 'Check page loading'. It stops short of explicit when-not or alternative-tool guidance, though no sibling tools exist.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

  1. 1 tool updatev1.0.0
    • First observedlegacydevicedebugthinking

TDQS

A3.8/5.0

Scored across 1 tool

Disambiguation5/5

With exactly one tool exposed, there is no possibility of selecting between overlapping tools. The tool set is unambiguous at the selection level, even though the single tool's internal workflow is broad.

Naming Consistency3/5

The single tool name 'legacydevicedebugthinking' is one long concatenated identifier, not an action-based verb_noun name, so no naming pattern can be inferred for the server as a set. It is not inconsistent with other tools because there are none, but it is not a predictive convention.

Tool Count2/5

One tool is too few for the stated scope: the description lists eight distinct workflow stages and many issue-specific analyses that would be more naturally exposed as separate invocable operations. The monolithic design reduces flexibility for an agent that only needs to run one stage.

Completeness4/5

The tool's description covers the end-to-end debugging workflow, from enabling default rules through loading checks, resource analysis, WebSocket handling, redirects, network errors, curl analysis, and final report generation. The main gap is the lack of any separate tool to apply or verify the generated rewrite rules, and the suboperations are not independently callable.

Maintenance

ActivityInactive
ResponsivenessNo issues

Related MCP Connectors

Related MCP Servers

  • F
    license
    A
    quality
    D
    maintenance
    Intelligent HTTP/HTTPS proxy server with MCP integration for automated traffic monitoring, analysis, and browser setup.
    22
    -
  • A
    license
    A
    quality
    F
    maintenance
    An MCP server that enables AI assistants to capture and analyze HTTP/HTTPS traffic from Android devices. It supports smart searching of network requests and provides tools for detailed traffic analysis via natural language.
    11
    233
    MIT
  • A
    license
    C
    quality
    B
    maintenance
    An MCP server for JavaScript reverse engineering that enables AI to perform browser debugging, script analysis, and automated hook injection. It streamlines complex workflows like deobfuscation, network tracing, and risk assessment through direct browser integration.
    35
    21 npm
    1,020
    Apache 2.0