Skip to main content
Glama
ceorkm

ReactBits MCP Server

by ceorkm

get_component_demo

Retrieve demo code and usage examples for specific ReactBits components to simplify integration and implementation in React projects.

Instructions

Get usage example and demo code for a ReactBits component

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYesName of the component

Implementation Reference

  • The primary handler function that implements the get_component_demo tool logic: fetches the component source code and wraps it in a complete demo React component with usage example.
    async getComponentDemo(componentName: string): Promise<string> { const component = await this.getComponent(componentName); // Extract component name from the code const componentNameMatch = component.match(/(?:export\s+default\s+function|const)\s+(\w+)/); const extractedName = componentNameMatch ? componentNameMatch[1] : componentName.replace(/\s+/g, ''); // Create a demo wrapper return `// Demo for ${componentName} import React from 'react'; ${component} // Usage Example: export default function Demo() { return ( <div className="min-h-screen bg-gray-100 p-8"> <h1 className="text-2xl font-bold mb-4">${componentName} Demo</h1> <${extractedName} /> </div> ); }`; }
  • MCP server dispatch handler for the 'get_component_demo' tool call, validates input and delegates to ReactBitsService.getComponentDemo.
    case 'get_component_demo': { const componentName = args?.name as string; if (!componentName) { throw new Error('Component name is required'); } const demo = await reactBitsService.getComponentDemo(componentName); return { content: [ { type: 'text', text: demo, }, ], };
  • src/index.ts:91-104 (registration)
    Tool registration in the MCP tools array, defining name, description, and input schema for get_component_demo.
    { name: 'get_component_demo', description: 'Get usage example and demo code for a ReactBits component', inputSchema: { type: 'object', properties: { name: { type: 'string', description: 'Name of the component', }, }, required: ['name'], }, },
  • Input schema definition for the get_component_demo tool, specifying the required 'name' parameter.
    inputSchema: { type: 'object', properties: { name: { type: 'string', description: 'Name of the component', }, }, required: ['name'], },

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/ceorkm/reactbits-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server