jsx-analyzer

jsx-analyzer

Analyzes JSX component prop usage in React/JSX codebases, enabling detection of specific props, missing props, and substring matching for prop values.

Category
访问服务器

README

JSX Component Prop Analyzer

A powerful tool for analyzing JSX component prop usage in React/JSX codebases. Now available as both a CLI tool and an MCP (Model Context Protocol) server!

Features

  • Recursive file scanning - Analyzes .js, .jsx, .ts, and .tsx files
  • Component detection - Finds JSX components by name
  • Prop analysis - Searches for specific props and their values
  • Missing prop detection - Identifies components missing required props
  • Substring matching - Search for prop values containing specific strings
  • Detailed output - Shows file paths, line numbers, and prop values

Installation

npm install

Usage

CLI Mode

Use the traditional command-line interface:

# Basic usage - find components with specific prop
./cli.js <rootDir> <componentName> <propName> [propValue]

# Find Button components with className prop
./cli.js ./src Button className

# Find Button components with specific className value
./cli.js ./src Button className "btn-primary"

# Find components missing a required prop
./cli.js ./src Button onClick --find-missing

# Verbose output showing all props
./cli.js ./src Button className --verbose

# Substring matching
./cli.js ./src Button className "primary" --includes

CLI Options:

  • --find-missing, -m: Find components missing the specified prop
  • --verbose, -v: Include all props of matching components in output
  • --includes, -i: Substring match for prop values

MCP Server Mode

The project now also works as an MCP server, exposing three tools:

Installation for VS Code / Cursor

You have two options for installing this MCP server:

Option 1: Local Installation

For VS Code with Roo/Cline:

  1. Open the MCP settings file: ~/Library/Application Support/Code/User/globalStorage/rooveterinaryinc.roo-cline/settings/mcp_settings.json
  2. Add the jsx-analyzer server to the mcpServers object:
{
  "mcpServers": {
    "jsx-analyzer": {
      "command": "node",
      "args": ["/absolute/path/to/your/project/mcp-server.js"],
      "disabled": false,
      "alwaysAllow": []
    }
  }
}

For Cursor with Claude/Cline:

  1. Open the MCP settings file: ~/Library/Application Support/Cursor/User/globalStorage/rooveterinaryinc.roo-cline/settings/mcp_settings.json
  2. Add the same configuration as above

Local Installation Notes:

  • Replace /absolute/path/to/your/project/mcp-server.js with the actual absolute path to your mcp-server.js file
  • Make sure you've run npm install in the project directory first
  • Restart VS Code/Cursor after modifying the settings file
Option 2: NPX Installation (if published to npm)

If this package is published to npm, you can use npx for easier installation:

For VS Code with Roo/Cline:

 "jsx-analyzer": {
      "command": "npx",
      "args": ["-y", "my-component-prop-analyzer"],
      "disabled": false
    }

For Cursor with Claude/Cline: Use the same configuration as above.

NPX Installation Benefits:

  • No need to clone the repository locally
  • Always uses the latest published version
  • Simpler configuration (no absolute paths required)
  • Automatic dependency management

Publishing to NPM (for package maintainers): To enable npx installation, publish the package:

# Update package name in package.json if needed
npm login
npm publish

Then users can reference it via npx using the published package name.

General Notes:

  • Restart VS Code/Cursor after modifying the settings file
  • The server will automatically start when you begin a new conversation

Verification

After installation, you should see "jsx-analyzer" listed in the Connected MCP Servers section when you start a new conversation.

Tools Available:

  1. analyze_jsx_props - General JSX prop analysis

    • rootDir: Directory or file to analyze
    • componentName: JSX component name to search for
    • propName: Prop name to search for
    • propValue (optional): Expected prop value
    • findMissing (optional): Find missing props
    • verbose (optional): Include all props in output
    • includes (optional): Substring matching
  2. find_missing_props - Find components missing required props

    • rootDir: Directory or file to analyze
    • componentName: JSX component name
    • propName: Required prop name
    • verbose (optional): Include all props in output
  3. search_prop_values - Search prop values with substring matching

    • rootDir: Directory or file to analyze
    • componentName: JSX component name
    • propName: Prop name to search
    • searchValue: String to search for within prop values
    • verbose (optional): Include all props in output

The MCP server has been automatically configured and is ready to use!

Project Structure

├── analyzer.js     # Core analysis logic
├── cli.js          # CLI interface
├── mcp-server.js   # MCP server interface
├── package.json    # Dependencies and scripts
└── README.md       # This file

Examples

CLI Examples

# Find all Button components with onClick prop
./cli.js ./src Button onClick

# Find Button components missing onClick prop
./cli.js ./src Button onClick --find-missing

# Find Input components with type="password"
./cli.js ./src Input type "password"

# Find components with className containing "primary"
./cli.js ./src Button className "primary" --includes --verbose

MCP Examples

When using through an MCP client, you can invoke tools like:

  • Analyze Button components for className prop in ./src directory
  • Find Input components missing the required 'name' prop
  • Search for components with className values containing 'btn-'

Output Format

CLI Output

--- JSX Prop Analysis Results ---

[1] src/components/Button.jsx:15
  Props: {
    "className": "btn btn-primary"
  }

[2] src/pages/Home.jsx:42
  Props: {
    "className": "btn btn-secondary"
  }

MCP Output

{
  "summary": {
    "totalMatches": 2,
    "searchCriteria": {
      "component": "Button",
      "prop": "className",
      "value": null,
      "mode": "existing props"
    }
  },
  "matches": [
    {
      "filePath": "src/components/Button.jsx",
      "lineNumber": 15,
      "props": {
        "className": "btn btn-primary"
      }
    }
  ]
}

Supported File Types

  • .js - JavaScript files
  • .jsx - React JSX files
  • .ts - TypeScript files
  • .tsx - TypeScript JSX files

Excluded Directories

The analyzer automatically skips:

  • node_modules
  • .git
  • dist
  • build
  • .next

Your JSX prop analyzer is now ready to use in both CLI and MCP modes! 🚀

推荐服务器

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

官方
精选