Class: DaisyUI::McpServer
- Inherits:
-
Object
- Object
- DaisyUI::McpServer
- Defined in:
- lib/daisy_ui/mcp_server.rb
Overview
MCP (Model Context Protocol) server for DaisyUI components. Provides component information to AI assistants via JSON-RPC over stdio.
Constant Summary collapse
- PROTOCOL_VERSION =
"2024-11-05"- SERVER_NAME =
"daisyui"- SERVER_VERSION =
DaisyUI::VERSION
- TOOLS =
[ { name: "list_components", description: "List all available DaisyUI Ruby/Phlex components with their CSS classes and modifiers", inputSchema: { type: "object", properties: {}, required: [] } }, { name: "get_component", description: "Get detailed information about a specific DaisyUI component including all modifiers and usage examples", inputSchema: { type: "object", properties: { component: { type: "string", description: "Component name (e.g., 'Button', 'Card', 'Modal')" } }, required: ["component"] } }, { name: "search_components", description: "Search for components by name or modifier", inputSchema: { type: "object", properties: { query: { type: "string", description: "Search query (component name or modifier)" } }, required: ["query"] } } ].freeze
- EXCLUDED_CONSTANTS =
%i[Base Configurable Configuration Modifiers VERSION UPDATED_AT McpServer].freeze
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.run ⇒ Object
46 47 48 |
# File 'lib/daisy_ui/mcp_server.rb', line 46 def run new.run end |
Instance Method Details
#run ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/daisy_ui/mcp_server.rb', line 51 def run warn "DaisyUI MCP Server v#{SERVER_VERSION} starting..." loop do line = $stdin.gets break if line.nil? request = JSON.parse(line) response = handle_request(request) $stdout.puts JSON.generate(response) $stdout.flush rescue JSON::ParserError => e warn "JSON parse error: #{e.}" end end |