Skip to main content
Glama
AlexCruzGargallo

ui-react-mcp

ui-react-mcp

An MCP server that gives AI assistants accurate, up-to-date documentation for @alexcruzgargallo/ui-react, my React component library.

Why

When an AI assistant writes code with a component library it doesn't know, it guesses: it invents props, variants that don't exist, or wrong import paths. This server lets the assistant ask the library directly which components exist, which props they take and which values are allowed, so the code it writes actually works.

Related MCP server: Components Build MCP

Tools

Tool

What it does

list_components

Lists every component with a short description.

search_components

Finds components for a need, e.g. "loading" or "form field".

get_component

Full docs for one component: import, props, allowed values, defaults and an example.

get_usage_example

Generates JSX for a component and validates the props: an invalid value like size="huge" is reported with the allowed options instead of being used.

Example of what the assistant gets back from get_usage_example with { "name": "Badge", "props": { "variant": "success", "size": "huge" } }:

```tsx
import { Badge } from "@alexcruzgargallo/ui-react";

<Badge variant="success">
  Badge content
</Badge>
```

Warnings:
- Invalid value "huge" for "size". Allowed values: small, medium.

How it works

ui-react                                   ui-react-mcp
─────────                                  ────────────
lib/components/*/index.tsx
   │  (TypeScript types + JSDoc)
   ▼
scripts/generate-metadata.ts
   │  react-docgen-typescript
   ▼
lib/metadata/components.json  ──sync──▶  data/components.json
                                               │
                                               ▼
                                         Catalog (search, docs, examples)
                                               │
                                               ▼
                                         MCP tools over stdio  ◀──  AI assistant
  • The component docs come from the library's own TypeScript types and JSDoc comments, so there is a single source of truth: change a prop in ui-react, regenerate the metadata, and the assistant sees the change.

  • src/catalog.ts holds all the logic (lookup, search ranking, docs, example generation and validation) with no dependency on MCP, so it is easy to test.

  • src/server.ts registers the tools with the official MCP TypeScript SDK and uses zod to validate their input.

  • src/index.ts connects the server over stdio.

Getting started

Requires Node.js 20 or later.

git clone https://github.com/AlexCruzGargallo/ui-react-mcp.git
cd ui-react-mcp
npm install
npm run build

Then add it to your AI client, replacing the path with the absolute path to your clone.

Claude Code

claude mcp add ui-react -- node /absolute/path/to/ui-react-mcp/dist/src/index.js

Claude Desktop, Cursor and other clients (mcpServers config)

{
  "mcpServers": {
    "ui-react": {
      "command": "node",
      "args": ["/absolute/path/to/ui-react-mcp/dist/src/index.js"]
    }
  }
}

VS Code (.vscode/mcp.json)

{
  "servers": {
    "ui-react": {
      "type": "stdio",
      "command": "node",
      "args": ["/absolute/path/to/ui-react-mcp/dist/src/index.js"]
    }
  }
}

Now ask your assistant something like "Build a login form with ui-react" and it will look up the components before writing the code.

To use a local checkout of ui-react instead of the bundled metadata, set UI_REACT_METADATA to the path of its lib/metadata/components.json.

Development

npm test               # build and run the tests (node:test)
npm run inspect        # open the server in the MCP Inspector
npm run sync-metadata  # pull the latest components.json from ui-react

The tests cover the catalog logic and run the real MCP client against the server through an in-memory transport.

License

MIT

Available Tools

4 tools
get_componentGet component documentationA

Returns the full documentation of a component: import statement, props with their allowed values and defaults, and a usage example. Use it before writing code with the component.

ParametersJSON Schema
NameRequiredDescriptionDefault
nameYesComponent name, e.g. Button

TDQS

A4/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries the full behavioral burden. It does disclose the return shape and implies a read-only lookup, but says nothing about what happens for an unknown component name, whether names are case-sensitive, or any error/permission behavior.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Two sentences, zero filler, and the returned content is front-loaded before the usage cue. Every clause earns its place.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

No output schema exists, so the description must (and does) describe the return value: import statement, props with defaults, and an example. The only gap is failure behavior for invalid component names, which is minor for a documentation lookup.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100% and the single parameter already documents itself with an example ('Button'), so the baseline is 3. The description adds no syntax, casing, or naming-convention detail beyond the schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a specific verb ('Returns') and resource ('documentation of a component'), then enumerates the exact payload: import statement, props with allowed values and defaults, and a usage example. This lets an agent distinguish it from list_components and search_components, though the overlap with get_usage_example is left for the reader to resolve.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

'Use it before writing code with the component' gives a concrete trigger condition for calling the tool. It stops short of naming alternatives (e.g., get_usage_example for example-only lookups) or stating when not to use it, so it is clear context without exclusions.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

get_usage_exampleGet usage exampleA

Generates a JSX example for a component. Optional props are validated against the library, so invalid variants or sizes are reported instead of silently used.

ParametersJSON Schema
NameRequiredDescriptionDefault
nameYesComponent name, e.g. Button
propsNoProps to include, e.g. { "variant": "danger", "size": "small" }

TDQS

A3.7/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries the full behavioral burden. It usefully discloses that optional props are validated against the library and that invalid variants/sizes are reported rather than silently used, but says nothing about error shape on invalid input, or whether the call is side-effect free.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Two tight sentences with zero filler, and the core action ('Generates a JSX example') is front-loaded before the validation caveat.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

No output schema exists, but the description characterizes the return value as a JSX example and explains the validation behavior for the nested props object. Close to complete for a two-parameter generator; only error/return details are left implicit.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so the baseline is 3, and the description goes slightly beyond it by clarifying that the props parameter is validated against the library's accepted variants/sizes rather than passed through verbatim.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a specific verb and artifact: 'Generates a JSX example for a component.' This is clearly distinguishable from the read-oriented siblings (list_components, get_component, search_components), though it never names them explicitly to sharpen the contrast.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Usage is implied by the verb 'Generates' – an agent can infer this is the tool for getting example code – but there is no explicit when-to-use statement, no when-not, and no routing to or away from the sibling tools.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

list_componentsList componentsA

Lists every component available in @alexcruzgargallo/ui-react with a short description.

ParametersJSON Schema
NameRequiredDescriptionDefault

No parameters

TDQS

A3.7/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden. It does convey that results include a short description per component, but says nothing about ordering, pagination, or read-only nature (only implied by 'Lists'). Adequate but thin for a tool with zero structured behavior hints.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

A single front-loaded sentence with no wasted words; the package scope and return content are stated up front.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a parameterless listing tool with no output schema, the description tells the agent what it will get (all components plus short descriptions). It could mention ordering or result size, but is essentially complete for the operation's simplicity.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The tool takes no parameters, so the baseline is 4. There is nothing to document and the description does not misrepresent any input.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description names a specific verb (Lists) and resource (every component in @alexcruzgargallo/ui-react) and clarifies the return shape ('with a short description'). It distinguishes itself from get_component by implying a bulk listing, but never explicitly contrasts with search_components.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Usage is only implied: 'every component' suggests an overview/browse scenario. There is no explicit when-to-use, when-not-to-use, or reference to search_components as the alternative, so an agent must infer the selection criteria.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

search_componentsSearch componentsA

Finds components that match what the user wants to build, e.g. 'loading', 'form field' or 'status label'.

ParametersJSON Schema
NameRequiredDescriptionDefault
queryYesWhat you are looking for, in a few words

TDQS

A3.5/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full behavioral burden, yet it discloses nothing about ranking, result limits, whether it returns full component data or just matches, or any auth context. It only restates purpose.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

A single front-loaded sentence that states the action and its scope, with examples in-line. Nothing wasted, nothing buried.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a one-parameter search with no output schema, the description is nearly sufficient. It could say what comes back (component list/summaries vs full details) and how it relates to get_component, but the core need is covered.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100% with a single well-described 'query' param, so baseline is 3. The examples ('loading', 'form field', 'status label') go beyond the schema's 'a few words' by showing the granularity and type of query expected, adding real value.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

Clear verb+resource ('Finds components') with a concrete articulation of scope ('that match what the user wants to build') plus examples. It distinguishes itself from list_components by implying intent-based matching, but never names the sibling explicitly.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Usage is implied — search by user intent — but there is no explicit when-to-use vs list_components, get_component, or get_usage_example. An agent can infer the intent-matching case but gets no routing guidance.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

  1. 4 tool updatesv1.0.0
    • First observedget_component
    • First observedget_usage_example
    • First observedlist_components
    • First observedsearch_components

TDQS

A3.7/5.0

Scored across 4 tools

Disambiguation3/5

list_components and search_components partly overlap (both surface components), though enumerate-vs-filter is a meaningful distinction. More problematic is that get_component already returns a usage example while get_usage_example separately generates a JSX example, so an agent may be unsure which to call for examples.

Naming Consistency5/5

All four tools follow a clean verb_noun snake_case pattern (list_components, get_component, search_components, get_usage_example). The singular/plural difference reflects the actual semantics (one component vs many), not inconsistent convention.

Tool Count4/5

Four tools is reasonable for a read-only component documentation server covering enumerate, fetch, search, and example generation. It is slightly thin — no category/browse or prop-lookup tool — but nothing is redundant at the count level.

Completeness4/5

The surface covers the core documentation lifecycle: discover (list/search), inspect (get_component), and apply (get_usage_example). Minor gaps like listing component categories or searching by prop are workarounds an agent can handle.

Maintenance

ActivityMaintained
ResponsivenessNo issues

Related MCP Connectors

Related MCP Servers