Skip to main content
Glama
grafana
by grafana
01-migration-to-grafana-ui.md34.7 kB
# Grafana UI MCP Server Specification ## Overview This document outlines the comprehensive transformation of the existing shadcn/ui MCP server to work with @grafana/ui components. The transformation creates a specialized Model Context Protocol server that provides AI assistants with rich access to Grafana's component library, documentation, and design system. ## Project Goals 1. **GitHub API Integration**: Use GitHub API to access Grafana UI components from the official repository 2. **Enhanced Component Access**: Provide richer component information through multi-file structure analysis 3. **Documentation Integration**: Access comprehensive MDX documentation and Storybook stories 4. **Design System Integration**: Include Grafana's theme tokens and design system information 5. **Performance Optimization**: Cached GitHub API access for fast response times ## Architecture Overview ### Data Source Migration **Before (shadcn/ui)**: - GitHub API requests to `shadcn-ui/ui` repository - Single `.tsx` files per component - Separate demo files - Rate-limited external API access **After (Grafana UI)**: - GitHub API requests to `grafana/grafana` repository - Multi-file component structure per component - Rich documentation and story files - Access to `/packages/grafana-ui/src/components/` path - Enhanced caching for performance ### Component Structure Analysis Each Grafana UI component follows this structure: ``` packages/grafana-ui/src/components/ComponentName/ ├── ComponentName.tsx # Main component implementation ├── ComponentName.mdx # Rich documentation with examples ├── ComponentName.story.tsx # Storybook stories and interactive examples ├── ComponentName.test.tsx # Test files showing usage patterns ├── types.ts # TypeScript type definitions ├── utils.ts # Utility functions └── styles.ts # Styling utilities (if applicable) ``` Example structures from Grafana UI: - `Button/` - Button.tsx, Button.mdx, Button.story.tsx, Button.test.tsx, ButtonGroup.tsx, FullWidthButtonContainer.tsx - `Alert/` - Alert.tsx, Alert.mdx, Alert.test.tsx, InlineBanner.story.tsx, Toast.story.tsx - `Combobox/` - Combobox.tsx, Combobox.mdx, Combobox.story.tsx, MultiCombobox.tsx, filter.ts, types.ts, utils.ts ## Tool Architecture ### Core Tools (Modified from shadcn/ui) #### `get_component` - **Input**: `{ componentName: string }` - **Output**: Main component TypeScript source code - **Implementation**: GitHub API request to `grafana/grafana` repository at `/packages/grafana-ui/src/components/{ComponentName}/{ComponentName}.tsx` - **Features**: - Syntax validation - Import analysis - Export detection #### `list_components` - **Input**: `{}` - **Output**: Array of available component names with metadata - **Implementation**: GitHub API request to list directories in `/packages/grafana-ui/src/components/` - **Features**: - Component discovery - Basic metadata extraction - Categorization by type #### `get_component_metadata` - **Input**: `{ componentName: string }` - **Output**: Component metadata including dependencies, props, and usage info - **Implementation**: Parse TypeScript files and extract metadata - **Features**: - Props interface extraction - Dependency analysis - Export information ### New Grafana-Specific Tools #### `get_component_documentation` - **Input**: `{ componentName: string }` - **Output**: Rich MDX documentation content - **Implementation**: Read and parse `.mdx` files - **Features**: - Usage guidelines - API documentation - Accessibility information - Design guidelines #### `get_component_stories` - **Input**: `{ componentName: string }` - **Output**: Storybook stories with interactive examples - **Implementation**: Parse `.story.tsx` files - **Features**: - Extract story definitions - Parse story arguments and controls - Example code extraction #### `get_component_tests` - **Input**: `{ componentName: string }` - **Output**: Test files showing usage patterns - **Implementation**: Read `.test.tsx` files - **Features**: - Usage pattern examples - Props validation examples - Edge case documentation #### `search_components` - **Input**: `{ query: string, includeDescription?: boolean }` - **Output**: Filtered list of components matching search criteria - **Implementation**: Search across component names, descriptions, and documentation - **Features**: - Fuzzy matching - Documentation content search - Tag-based filtering #### `get_theme_tokens` - **Input**: `{ category?: string }` - **Output**: Grafana design system tokens and theme information - **Implementation**: Parse theme files and extract design tokens - **Features**: - Color palette - Typography tokens - Spacing scale - Component variants #### `get_component_dependencies` - **Input**: `{ componentName: string, deep?: boolean }` - **Output**: Dependency tree analysis - **Implementation**: Parse imports and build dependency graph - **Features**: - Internal component dependencies - External package dependencies - Circular dependency detection ### Removed Tools - `get_block` / `list_blocks`: Not applicable to Grafana UI (no blocks concept) - `get_directory_structure`: Replaced with component-specific discovery ## Implementation Details ### File Structure ``` src/ ├── index.ts # CLI entry point (updated for Grafana UI) ├── handler.ts # MCP request handlers (updated schemas) ├── tools.ts # Tool implementations (completely rewritten) ├── resources.ts # Static resources ├── prompts.ts # MCP prompts ├── resource-templates.ts # Dynamic resources └── utils/ ├── axios.ts # GitHub API client with caching (updated for Grafana) ├── component-parser.ts # Parse component files and extract metadata ├── story-parser.ts # Extract examples from Storybook files ├── mdx-parser.ts # Parse MDX documentation ├── theme-extractor.ts # Extract Grafana theme information └── cache.ts # Response caching utilities ``` ### Core Utilities #### `axios.ts` GitHub API client for accessing Grafana UI components with caching: ```typescript export interface GitHubApi { // Component discovery getAvailableComponents(): Promise<string[]>; getComponentDirectories(): Promise<ComponentDirectory[]>; // File access getComponentSource(componentName: string): Promise<string>; getComponentFiles(componentName: string): Promise<ComponentFiles>; // GitHub API operations getRepositoryContents(path: string): Promise<GitHubContent[]>; getFileContent(path: string): Promise<string>; // Caching getCachedContent(key: string): string | null; setCachedContent(key: string, content: string): void; } ``` #### `component-parser.ts` TypeScript and React component analysis: ```typescript export interface ComponentMetadata { name: string; description?: string; props: PropDefinition[]; exports: ExportDefinition[]; imports: ImportDefinition[]; dependencies: string[]; hasTests: boolean; hasStories: boolean; hasDocumentation: boolean; } export interface PropDefinition { name: string; type: string; required: boolean; description?: string; defaultValue?: string; } ``` #### `story-parser.ts` Storybook story analysis and example extraction: ```typescript export interface StoryDefinition { name: string; args?: Record<string, any>; parameters?: Record<string, any>; source: string; description?: string; } export interface StorybookMeta { title: string; component: string; stories: StoryDefinition[]; argTypes?: Record<string, any>; } ``` #### `mdx-parser.ts` MDX documentation parsing: ```typescript export interface MDXContent { title: string; content: string; sections: MDXSection[]; examples: CodeExample[]; metadata: Record<string, any>; } export interface MDXSection { title: string; level: number; content: string; examples: CodeExample[]; } ``` #### `theme-extractor.ts` Grafana design system analysis: ```typescript export interface ThemeTokens { colors: ColorTokens; typography: TypographyTokens; spacing: SpacingTokens; shadows: ShadowTokens; borderRadius: BorderRadiusTokens; } export interface ColorTokens { primary: ColorScale; secondary: ColorScale; success: ColorScale; warning: ColorScale; error: ColorScale; text: TextColors; background: BackgroundColors; border: BorderColors; } ``` ## Data Flow ### Component Discovery Flow 1. GitHub API request to list `/packages/grafana-ui/src/components/` directories 2. Filter valid component directories (containing main `.tsx` file) 3. Extract basic metadata from directory structure 4. Cache results for performance ### Component Information Retrieval Flow 1. Validate component name exists 2. Check cache for existing parsed data 3. Fetch relevant files from GitHub API based on requested information type 4. Parse content using appropriate parser 5. Return structured data 6. Update cache ### Search Flow 1. Load component list with metadata 2. Apply search filters (name, description, tags) 3. Rank results by relevance 4. Return sorted results with highlighting ## Caching Strategy ### Response-based Caching - Cache GitHub API responses and parsed component metadata - Invalidate based on configurable TTL or manual refresh - Store in memory for session duration - Persist to temporary files for cross-session caching ### Cache Keys - `component:{name}:source` - Component source code - `component:{name}:metadata` - Parsed metadata - `component:{name}:stories` - Storybook stories - `component:{name}:docs` - MDX documentation - `components:list` - Available components list - `theme:tokens` - Design system tokens ## Error Handling ### GitHub API Errors - Component not found: Provide helpful suggestions - API rate limiting: Use cached data when available - Network errors: Graceful fallback to cached content - Authentication errors: Clear instructions for API key setup ### Parsing Errors - TypeScript syntax errors: Report line and column information - MDX parsing errors: Provide context and suggestions - JSON parsing errors: Validate and report specific issues ### Graceful Degradation - If story file missing: Return component source only - If documentation missing: Provide generated docs from TypeScript - If metadata extraction fails: Return basic GitHub file information ## Performance Considerations ### Lazy Loading - Fetch and parse component files on-demand - Cache GitHub API responses and parsed results aggressively - Use TTL-based cache invalidation ### Batch Operations - Bulk component listing operations via GitHub API - Parallel GitHub API requests where possible - Optimize repository content scanning ### Memory Management - Limit cache size to prevent memory leaks - Use weak references for large cached objects - Periodic cache cleanup ## Security Considerations ### GitHub API Access - Use read-only GitHub API access for public repository - Validate all GitHub paths to prevent unauthorized access - No execution of fetched content - Secure API key storage and transmission ### Input Validation - Sanitize component names and search queries - Validate GitHub repository paths before access - Limit response size processing to prevent memory exhaustion ## Migration Path ### Phase 1: Core Infrastructure ✅ COMPLETED 1.  Update package.json and project metadata 2. Update GitHub API utilities (`axios.ts`) for Grafana repository 3. Create core parsers (`component-parser.ts`, `story-parser.ts`, `mdx-parser.ts`) 4. Implement enhanced caching layer **Phase 1 Implementation Summary:** - ✅ Package renamed to `@shelldandy/grafana-ui-mcp-server` - ✅ Binary command changed to `grafana-ui-mcp` - ✅ GitHub API integration migrated to `grafana/grafana` repository - ✅ Component discovery updated for `/packages/grafana-ui/src/components/` structure - ✅ Component parser with TypeScript analysis and props extraction - ✅ Story parser for Storybook `.story.tsx` files with interactive features detection - ✅ MDX parser for documentation with section extraction and accessibility analysis - ✅ Enhanced caching layer with TTL-based invalidation and Grafana-specific cache utilities - ✅ CLI interface updated with Grafana UI branding - ✅ Removed shadcn-specific tools (blocks) not applicable to Grafana UI - ✅ All existing tools updated to work with Grafana repository structure ### Phase 2: Tool Implementation ✅ COMPLETED 1. ✅ Update existing tools to use Grafana GitHub API endpoints 2. ✅ Implement new Grafana-specific tools 3. ✅ Update request handlers and validation schemas 4. ✅ Add comprehensive error handling for GitHub API **Phase 2 Implementation Summary:** - ✅ **6 New Grafana-Specific Tools** implemented and working: - `get_component_documentation` - Rich MDX documentation parsing with sections and examples - `get_component_stories` - Storybook story analysis with interactive features detection - `get_component_tests` - Test file parsing showing usage patterns and edge cases - `search_components` - Advanced search with fuzzy matching and documentation content search - `get_theme_tokens` - Complete design system token extraction with category filtering - `get_component_dependencies` - Dependency analysis with shallow/deep tree support - ✅ **Enhanced GitHub API Integration** with 4 new methods in `axios.ts` - ✅ **New Theme Extractor Utility** (`theme-extractor.ts`) with comprehensive token parsing - ✅ **Updated Handler Validation** with Zod schemas for all new tools - ✅ **Complete TypeScript Compilation** - All tools build successfully - ✅ **Server Verification** - All 11 tools (5 existing + 6 new) working correctly - ✅ **Comprehensive Error Handling** with McpError standardization and graceful fallbacks **Tool Coverage:** - **Core Tools (5)**: `get_component`, `get_component_demo`, `list_components`, `get_component_metadata`, `get_directory_structure` - **New Grafana Tools (6)**: `get_component_documentation`, `get_component_stories`, `get_component_tests`, `search_components`, `get_theme_tokens`, `get_component_dependencies` - **Total Tools**: 11 fully functional MCP tools ### Phase 3: Documentation ✅ COMPLETED 1. ✅ Update CLI interface and help text 2. ✅ Rewrite README for Grafana UI focus **Phase 3 Implementation Summary:** - ✅ **Enhanced CLI Interface** (`src/index.ts`) - Updated help text with comprehensive tool listing (all 11 tools), improved GitHub API setup instructions, and consistent branding - ✅ **Complete README Transformation** - Full rewrite from shadcn/ui to Grafana UI focus with detailed documentation of all 11 tools, comprehensive usage examples, and updated installation instructions - ✅ **Enhanced package.json** - Improved description highlighting comprehensive Grafana UI capabilities and expanded keywords for better discoverability - ✅ **Consistent CLI Branding** - Updated version command and all CLI outputs to use "Grafana UI MCP Server" branding - ✅ **Documentation Verification** - All build systems, CLI commands, and package tests verified working correctly ### Phase 4: Prompts Migration ✅ COMPLETED 1. ✅ Migrate prompts from shadcn/ui to Grafana UI focus 2. ✅ Update all prompt handlers with Grafana-specific tools and instructions **Phase 4 Implementation Summary:** - ✅ **Complete Prompts Transformation** (`src/prompts.ts`) - All 5 prompts completely migrated from shadcn/ui to Grafana UI focus: - **Removed**: `build-shadcn-page`, `create-dashboard`, `create-auth-flow`, `optimize-shadcn-component`, `create-data-table` - **Added**: `build-grafana-dashboard`, `create-grafana-form`, `optimize-grafana-component`, `create-data-visualization`, `build-admin-interface` - ✅ **All Prompt Handlers Rewritten** - Updated with Grafana UI specific instructions, observability focus, and comprehensive tool integration - ✅ **New Helper Functions** - Added 4 new Grafana-specific helper functions: - `getDashboardTypeSpecificInstructions` - For monitoring, analytics, infrastructure, application, and business dashboards - `getFormTypeSpecificInstructions` - For authentication, settings, data-source, alert, and user-management forms - `getDataSourceSpecificInstructions` - For time-series, logs, metrics, traces, and JSON data handling - `getInterfaceTypeSpecificInstructions` - For user-management, plugin-config, org-settings, and data-sources admin interfaces - ✅ **Enhanced Optimization Instructions** - Updated `getOptimizationInstructions` with Grafana-specific theming optimization - ✅ **Complete Tool Integration** - All prompts now reference the 11 available Grafana UI MCP tools: - Core tools: `get_component`, `get_component_demo`, `list_components`, `get_component_metadata`, `get_directory_structure` - Grafana tools: `get_component_documentation`, `get_component_stories`, `get_component_tests`, `search_components`, `get_theme_tokens`, `get_component_dependencies` - ✅ **TypeScript Compilation Verified** - All new prompt code compiles successfully **Prompt Coverage:** - **Dashboard Building**: Comprehensive monitoring and analytics dashboard creation with panels, layouts, and theming - **Form Creation**: Authentication, settings, and configuration forms with validation and Grafana UI patterns - **Component Optimization**: Performance, accessibility, responsive, and theming optimizations for Grafana UI components - **Data Visualization**: Tables, charts, and visualizations for time-series, logs, metrics, traces, and JSON data - **Admin Interfaces**: User management, plugin configuration, organization settings, and data source management ### Phase 5: Resources Migration ✅ COMPLETED 1. ✅ Migrate resource-templates.ts from shadcn/ui to Grafana UI focus 2. ✅ Update resources.ts to use dynamic GitHub API integration ## Testing Strategy ### Unit Tests - GitHub API operation mocking - Parser functionality validation - Cache behavior verification - Error handling coverage ### Integration Tests - End-to-end tool functionality - Real component parsing - Performance benchmarks - Error scenario testing ### Component Coverage Tests - Verify all Grafana UI components are discoverable - Test parsing of complex component structures - Validate metadata extraction accuracy ## Future Enhancements ### Advanced Features - Component usage analytics - Cross-component relationship mapping - Automated component API documentation generation - Integration with Grafana's Storybook deployment ### AI Integration - Semantic search across component descriptions - Component recommendation engine - Usage pattern analysis - Automated example generation ### Developer Experience - VS Code extension integration - Interactive component explorer - Real-time component validation - Component dependency visualization ## Success Metrics ### Performance Metrics - Component discovery time < 100ms - Individual component access time < 50ms - Memory usage < 100MB for full component set - Cache hit ratio > 90% ### Functionality Metrics - 100% component coverage for discovery - 95% success rate for metadata extraction - 90% success rate for story parsing - 85% success rate for MDX parsing ### User Experience Metrics - Maintained GitHub API key configuration for optimal performance - Cached response times for faster subsequent requests - More comprehensive component information - Better error messages and debugging information ## Conclusion This transformation creates a specialized MCP server optimized for Grafana UI development, providing AI assistants with comprehensive access to one of the most mature React component libraries in the ecosystem. The GitHub API approach maintains reliable access to the latest Grafana components while providing richer information through multi-file component analysis. The new architecture supports advanced features like design system integration, comprehensive documentation access, and interactive example extraction, making it a powerful tool for AI-assisted Grafana UI development. --- ## Implementation Log ### Phase 1 Completion - January 2025 ✅ **Completed Tasks:** - ✅ Package renamed to `@shelldandy/grafana-ui-mcp-server` v1.0.0 - ✅ Binary command changed from `shadcn-mcp` to `grafana-ui-mcp` - ✅ GitHub API integration migrated from `shadcn-ui/ui` to `grafana/grafana` - ✅ Component discovery updated for Grafana's `/packages/grafana-ui/src/components/` structure - ✅ Implemented `component-parser.ts` with TypeScript analysis and props extraction - ✅ Implemented `story-parser.ts` for Storybook `.story.tsx` files with interactive features detection - ✅ Implemented `mdx-parser.ts` for documentation with section extraction and accessibility analysis - ✅ Enhanced caching layer with TTL-based invalidation and Grafana-specific cache utilities - ✅ CLI interface updated with Grafana UI branding and help text - ✅ Removed shadcn-specific tools (blocks) not applicable to Grafana UI - ✅ All existing tools (`get_component`, `get_component_demo`, `list_components`, `get_component_metadata`, `get_directory_structure`) updated to work with Grafana repository structure - ✅ Build system verified and working - ✅ Project successfully compiles and runs **Architecture Changes:** - Repository constants updated from shadcn to Grafana - Component paths changed from single files to multi-file directories - Tool descriptions updated to reflect Grafana UI components - Cache keys redesigned for Grafana component structure - Enhanced error handling for GitHub API interactions **Files Created/Modified:** - `package.json` - Updated metadata and naming - `src/index.ts` - Updated CLI interface and branding - `src/tools.ts` - Updated tool definitions for Grafana UI - `src/utils/axios.ts` - Migrated to Grafana repository endpoints - `src/utils/component-parser.ts` - **NEW** - TypeScript component analysis - `src/utils/story-parser.ts` - **NEW** - Storybook story parsing - `src/utils/mdx-parser.ts` - **NEW** - MDX documentation parsing - `src/utils/cache.ts` - Enhanced with Grafana-specific utilities ### Phase 2 Completion - January 2025 ✅ **Completed Tasks:** - ✅ **6 New Grafana-Specific Tools** implemented with full functionality: - `get_component_documentation` - MDX documentation parsing with section extraction, examples, and metadata - `get_component_stories` - Storybook story parsing with interactive features and example extraction - `get_component_tests` - Test file analysis showing usage patterns and test case descriptions - `search_components` - Advanced component search with fuzzy matching and optional documentation content search - `get_theme_tokens` - Complete Grafana design system token extraction with category filtering - `get_component_dependencies` - Dependency tree analysis with shallow and deep analysis options - ✅ **Theme Extractor Utility** (`theme-extractor.ts`) - Brand new comprehensive utility for parsing Grafana design system tokens including colors, typography, spacing, shadows, border radius, z-index, and breakpoints - ✅ **Enhanced GitHub API Integration** - Added 4 new methods to `axios.ts`: `getComponentTests`, `searchComponents`, `getThemeFiles`, `getComponentDependencies` - ✅ **Updated Handler Validation** - Added Zod validation schemas for all new tools in `handler.ts` - ✅ **Complete Error Handling** - Comprehensive McpError integration with graceful fallbacks and detailed error messages - ✅ **TypeScript Compilation** - All new code compiles successfully with strict TypeScript settings - ✅ **Server Integration** - All 11 tools are properly registered and accessible through the MCP server - ✅ **Build and Runtime Verification** - Server starts successfully and lists all tools correctly **Architecture Enhancements:** - Extended GitHub API client with theme file parsing capabilities - Added comprehensive design system token extraction with pattern matching - Implemented advanced search functionality with relevance scoring - Enhanced dependency analysis with circular dependency detection - Integrated MDX and Storybook parsing with existing infrastructure - Maintained backward compatibility with all existing Phase 1 tools **Files Created/Modified in Phase 2:** - `src/utils/theme-extractor.ts` - **NEW** - Comprehensive design system token extraction (670+ lines) - `src/utils/axios.ts` - **ENHANCED** - Added 4 new GitHub API methods for Phase 2 tools - `src/tools.ts` - **ENHANCED** - Added 6 new tool implementations with MCP server integration - `src/handler.ts` - **ENHANCED** - Added validation schemas for all new tools - All new functionality tested and verified working **Performance & Quality:** - All new tools follow established error handling patterns - Comprehensive input validation with Zod schemas - Efficient GitHub API usage with caching integration - Memory-conscious implementation with proper TypeScript types - Graceful degradation when files are missing or unavailable ### Phase 3 Completion - January 2025 ✅ **Completed Tasks:** - ✅ **Enhanced CLI Interface and Help Text** (`src/index.ts`): - Updated help text to showcase all 11 available tools (5 core + 6 Grafana-specific) - Added comprehensive tool descriptions and categorization - Enhanced GitHub API setup instructions with clear rate limit information - Updated package name references to `@shelldandy/grafana-ui-mcp-server` - Improved version command with consistent "Grafana UI MCP Server" branding - ✅ **Complete README.md Transformation**: - Full rewrite from shadcn/ui to Grafana UI focus - Comprehensive documentation of all 11 tools with detailed examples - Updated installation instructions and package references - Added extensive tool usage examples for all new Grafana-specific tools - Enhanced GitHub API setup section specifically for Grafana repository access - Improved troubleshooting and configuration sections - Updated badges, links, and project metadata - ✅ **Enhanced package.json Configuration**: - Improved description to highlight comprehensive Grafana UI capabilities - Expanded keywords to include Grafana-specific terms (storybook, observability, monitoring, design-tokens, etc.) - Maintained consistency with project transformation goals - ✅ **CLI Branding and Version Consistency**: - Updated all CLI outputs to use "Grafana UI MCP Server" branding - Enhanced version command display format - Consistent professional presentation across all user-facing text **Quality Verification:** - ✅ TypeScript compilation successful with all changes - ✅ CLI help text displays correctly with all 11 tools listed - ✅ Version command shows proper Grafana UI branding - ✅ Package tests pass completely with new documentation - ✅ Build artifacts ready for distribution **Documentation Architecture:** - **Comprehensive Tool Coverage**: All 11 tools documented with examples - **User-Focused**: Clear installation, setup, and usage instructions - **Professional Presentation**: Consistent branding and formatting - **Complete Transformation**: All references updated from shadcn/ui to Grafana UI **Files Modified in Phase 3:** - `src/index.ts` - **ENHANCED** - Updated CLI interface, help text, and version branding - `README.md` - **COMPLETE REWRITE** - Full transformation to Grafana UI focus with comprehensive tool documentation - `package.json` - **ENHANCED** - Improved description and expanded keyword coverage ### Phase 4 Completion - January 2025 ✅ **Completed Tasks:** - ✅ **Complete Prompts Migration** (`src/prompts.ts`) - Full transformation from shadcn/ui to Grafana UI focus: - Replaced all 5 shadcn/ui prompts with 5 new Grafana UI specific prompts - `build-grafana-dashboard` - Create monitoring/observability dashboards with panels, charts, and metrics - `create-grafana-form` - Build forms for authentication, settings, and configuration using Grafana UI patterns - `optimize-grafana-component` - Optimize Grafana UI components with performance/accessibility focus - `create-data-visualization` - Create data tables, charts, and visualizations using Grafana UI components - `build-admin-interface` - Create admin interfaces following Grafana's design patterns - ✅ **Comprehensive Prompt Handler Rewrite** - All 5 prompt handlers completely rewritten: - Updated tool references from shadcn/ui blocks to Grafana UI MCP tools - Added observability and monitoring focus throughout all instructions - Integrated comprehensive usage of all 11 available MCP tools - Added Grafana-specific development patterns and best practices - ✅ **New Helper Functions Implementation** - 4 new Grafana-specific helper functions: - `getDashboardTypeSpecificInstructions` - Tailored instructions for monitoring, analytics, infrastructure, application, and business dashboards - `getFormTypeSpecificInstructions` - Specialized guidance for authentication, settings, data-source, alert, and user-management forms - `getDataSourceSpecificInstructions` - Data handling patterns for time-series, logs, metrics, traces, and JSON data - `getInterfaceTypeSpecificInstructions` - Admin interface patterns for user management, plugin config, org settings, and data sources - ✅ **Enhanced Optimization Instructions** - Updated `getOptimizationInstructions` with Grafana-specific patterns: - Added theming optimization category for Grafana's design system - Enhanced performance patterns for monitoring and data visualization contexts - Updated accessibility guidelines for dashboard and admin interfaces - Improved responsive design patterns for observability interfaces **Architecture Enhancements:** - Complete migration from shadcn/ui ecosystem to Grafana UI ecosystem - All prompts now leverage the full suite of 11 Grafana UI MCP tools - Enhanced focus on observability, monitoring, and data visualization use cases - Comprehensive integration with Grafana's design system and theming - Professional prompt structure optimized for AI-assisted Grafana UI development **Quality Verification:** - ✅ TypeScript compilation successful with all prompt changes - ✅ All 11 MCP tools properly referenced in prompt instructions - ✅ No references to non-existent tools (shadcn/ui blocks removed) - ✅ Comprehensive coverage of Grafana UI development scenarios - ✅ Professional prompt structure aligned with MCP best practices **Files Modified in Phase 4:** - `src/prompts.ts` - **COMPLETE REWRITE** - Full transformation to Grafana UI focus with 5 new prompts and 4 new helper functions - All prompts now provide comprehensive guidance for Grafana UI development workflows ### Phase 5 Completion - January 2025 ✅ **Completed Tasks:** - ✅ **Complete Resource Templates Migration** (`src/resource-templates.ts`) - Full transformation from shadcn/ui to Grafana UI focus: - **Removed**: `get_install_script_for_component` (shadcn/ui CLI commands), `get_installation_guide` (framework-specific shadcn/ui setup) - **Added**: `get_grafana_ui_setup_script` (React + @grafana/ui integration), `get_component_usage_example` (Grafana UI component usage patterns) - Updated all installation templates to use `npm install @grafana/ui` instead of `npx shadcn@latest add` - Added comprehensive Grafana UI setup instructions with ThemeProvider configuration - Created component usage examples with TypeScript support for Button, Alert, Input, Card, Table components - ✅ **Complete Resources Migration** (`src/resources.ts`) - Dynamic integration with GitHub API: - **Removed**: Hardcoded list of 40+ shadcn/ui components (`accordion`, `alert-dialog`, `badge`, etc.) - **Added**: `get_grafana_components` (dynamic GitHub API integration), `get_grafana_ui_info` (comprehensive library information) - Integrated with existing `axios.getAvailableComponents()` for real-time component discovery - Added fallback component list for API rate limiting scenarios - Enhanced resource responses with metadata including total count, source repository, and last updated timestamps - ✅ **Enhanced Resource Architecture** - Complete alignment with existing infrastructure: - Leveraged existing GitHub API utilities and caching layer - Maintained consistency with all 11 MCP tools - Updated resource URIs and descriptions to reflect Grafana UI focus - Added comprehensive error handling with graceful degradation **Architecture Enhancements:** - Complete migration from static shadcn/ui patterns to dynamic Grafana UI integration - All resources now use GitHub API for real-time data instead of hardcoded lists - Enhanced resource templates focus on React + @grafana/ui development workflows - Comprehensive integration with existing caching and error handling infrastructure - Professional resource structure optimized for AI-assisted Grafana UI development **Quality Verification:** - ✅ TypeScript compilation successful with all resource changes - ✅ Build system verified and package tests pass completely - ✅ Server starts successfully with updated resource definitions - ✅ Dynamic component discovery working through GitHub API integration - ✅ Resource templates generate proper Grafana UI setup instructions **Files Modified in Phase 5:** - `src/resource-templates.ts` - **COMPLETE REWRITE** - Full transformation to Grafana UI setup patterns with 2 new resource templates - `src/resources.ts` - **COMPLETE REWRITE** - Dynamic GitHub API integration with 2 new resources replacing static shadcn/ui list - All resources now provide comprehensive guidance for Grafana UI development workflows **Final Architecture:** - **Total MCP Tools**: 11 fully functional tools - **Total Resources**: 2 dynamic resources with GitHub API integration - **Total Resource Templates**: 2 Grafana UI focused templates - **Total Prompts**: 5 comprehensive Grafana UI development prompts - **Complete Transformation**: 100% migration from shadcn/ui to Grafana UI ecosystem **Project Status: COMPLETE TRANSFORMATION** ✅ The Grafana UI MCP Server transformation is now fully complete with all components migrated from shadcn/ui to Grafana UI focus. The server provides comprehensive access to Grafana's component library through 11 tools, dynamic resources, and specialized prompts optimized for observability and monitoring UI development.

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/grafana/grafana-ui-mcp-server'

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