npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

react-mcp-tools

v0.3.0

Published

Generate MCP tools from React components to enable AI code generation and component usage

Readme

react-mcp-tools

A powerful npm package that transforms React components into AI-accessible tools using the Model Context Protocol (MCP). This enables AI assistants like Claude Code to understand and generate code with your custom React components.

🚀 Features

  • Smart Component Detection: Automatically scans React/TypeScript projects for annotated components
  • TypeScript Integration: Full TypeScript support with intelligent prop type extraction
  • MCP Server: Built-in MCP server for seamless AI integration
  • Flexible Annotations: Support for // @mcp and // @ai-tool markers
  • Props Analysis: Extracts component props, types, and optional parameters
  • Code Generation: AI assistants can generate proper component usage code

📦 Installation

# Global installation (recommended)
npm install -g react-mcp-tools

# Or per project
npm install react-mcp-tools

🏁 Quick Start

1. Annotate Your Components

Add // @mcp or // @ai-tool comments above your React components:

// @mcp
export function Button({ text, onClick }: { text: string; onClick: () => void }) {
  return <button onClick={onClick}>{text}</button>;
}

// @ai-tool  
const Card: React.FC<CardProps> = ({ title, content, isVisible = true }) => {
  return isVisible ? <div><h2>{title}</h2><p>{content}</p></div> : null;
}

2. Generate Tools Manifest

react-mcp-tools --verbose

3. Start MCP Server

react-mcp-server

4. Configure Your AI Assistant

See SETUP.md for detailed Claude Code integration.

🎯 How It Works

The package performs static analysis on your React/TypeScript project:

  1. Scan: Recursively searches for .jsx, .tsx, .js, .ts files
  2. Detect: Identifies components marked with // @mcp or // @ai-tool annotations
  3. Analyze: Uses TypeScript compiler API to extract component metadata:
    • Component name and props
    • TypeScript types and interfaces
    • Required vs optional parameters
    • Import paths
  4. Generate: Creates MCP-compatible JSON manifest
  5. Serve: MCP server exposes components as AI-accessible tools

📝 CLI Usage

# Generate manifest in current directory
react-mcp-tools

# Scan specific directory
react-mcp-tools -d /path/to/project

# Custom output file
react-mcp-tools -o my-manifest.json

# Verbose output
react-mcp-tools --verbose

# Start MCP server
react-mcp-server

🔧 Supported Component Patterns

// Function components
// @mcp
export function MyComponent({ prop1, prop2 }: Props) { ... }

// Arrow function components  
// @ai-tool
export const MyComponent = ({ prop1, prop2 }: Props) => { ... }

// React.FC components
// @mcp
const MyComponent: React.FC<Props> = ({ prop1, prop2 }) => { ... }

// With interfaces
interface Props {
  title: string;
  count?: number;
}

// With type aliases
type Props = {
  title: string;
  count?: number;
}

📋 Example Output

Generated manifest structure:

{
  "tools": [
    {
      "name": "Component.Button",
      "description": "A Button React component", 
      "parameters": {
        "type": "object",
        "properties": {
          "text": {
            "type": "string",
            "description": "The text property of type string"
          },
          "onClick": {
            "type": "function", 
            "description": "The onClick property of type function"
          }
        },
        "required": ["text", "onClick"]
      },
      "code_example": "<Button text=\"Click me\" onClick={() => console.log('clicked')} />",
      "import_path": "@/components/Button"
    }
  ]
}

🤖 AI Integration

Once configured, AI assistants can:

  • Understand your component APIs
  • Generate proper component usage code
  • Respect TypeScript types and required props
  • Use appropriate import paths

Example AI interaction:

You: "Create a stats card showing sales data"
AI: Uses Component.StatsCard tool to generate:
     <StatsCard title="Sales" value={1000} variant="green" />

🔗 Links

📄 License

ISC License