@gianpieropuleo/radix-mcp-server
Version:
A Model Context Protocol (MCP) server for Radix UI libraries (Themes, Primitives, Colors), providing AI assistants with access to component source code, installation guides, and design tokens.
49 lines (48 loc) • 3.15 kB
JavaScript
import { ComponentType, Library, Package } from "../types/results.js";
import { http } from "../utils/http.js";
const createDefaultHooks = (library) => ({
getListComponentsNote: () => "Use get-component tool with a specific component name to get detailed usage information",
getGettingStartedTitle: () => `Radix ${library.charAt(0).toUpperCase() + library.slice(1)} - Getting Started`,
getGettingStartedDescription: () => `Official getting started guide for Radix ${library.charAt(0).toUpperCase() + library.slice(1)}`,
getGettingStartedSource: () => `https://github.com/radix-ui/website/blob/main/data/${library}/docs/overview/getting-started.mdx`,
getGettingStartedNote: () => "This content is fetched directly from the official Radix UI documentation to ensure it stays up-to-date.",
});
export const libraryConfigs = {
[Library.Themes]: {
library: Library.Themes,
componentType: ComponentType.Styled,
fetchAvailableComponents: () => http.getAvailableComponents("themes"),
fetchComponentUsage: (componentName) => http.getThemesUsage(componentName),
fetchComponentSource: (componentName) => http.getThemesComponentSource(componentName),
fetchGettingStartedContent: () => http.getThemesGettingStarted(),
getPackageName: () => Package.Themes,
...createDefaultHooks(Library.Themes),
getGettingStartedSource: () => "https://github.com/radix-ui/website/blob/main/data/themes/docs/overview/getting-started.mdx",
},
[Library.Primitives]: {
library: Library.Primitives,
componentType: ComponentType.Unstyled,
fetchAvailableComponents: () => http.getAvailableComponents("primitives"),
fetchComponentUsage: (componentName) => http.getPrimitivesUsage(componentName),
fetchComponentSource: (componentName) => http.getPrimitivesComponentSource(componentName),
fetchGettingStartedContent: () => http.getPrimitivesGettingStarted(),
getPackageName: (componentName) => `${Package.Primitives}${componentName.toLowerCase()}`,
...createDefaultHooks(Library.Primitives),
getGettingStartedSource: () => "https://github.com/radix-ui/website/blob/main/data/primitives/docs/overview/getting-started.mdx",
},
[Library.Colors]: {
library: Library.Colors,
componentType: ComponentType.ColorScale,
fetchAvailableComponents: () => http.getColorsScaleNames(),
fetchComponentUsage: () => http.getColorsDocumentation(),
fetchComponentSource: async (componentName) => {
const scaleData = await http.getCompleteColorScale(componentName);
return JSON.stringify(scaleData, null, 2);
},
fetchGettingStartedContent: () => http.getColorsGettingStarted(),
getPackageName: () => Package.Colors,
...createDefaultHooks(Library.Colors),
getListComponentsNote: () => "Use get-scale tool with a specific scale name to get detailed color values and usage information",
getGettingStartedSource: () => "https://github.com/radix-ui/website/blob/main/data/colors/docs/overview/installation.mdx",
},
};