get_component
Retrieve a component's JSON definition including source provenance, props, and variants. Use this to reuse existing components rather than recreating them.
Instructions
Look up a specific component by name. Read-only, no side effects. Returns JSON with source provenance, props, and variants, or an error listing available components if not found. Use this when you need implementation details for a known component to reuse it rather than recreate it. For a list of all component names, use get_design_context with category 'components' instead.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes |
Implementation Reference
- src/mcp/server.ts:232-250 (registration)Registration of the 'get_component' tool with input schema, description, and handler via server.registerTool()
this.server.registerTool( "get_component", { description: "Look up a specific component by name. Read-only, no side effects. Returns JSON with source provenance, props, and variants, or an error listing available components if not found. Use this when you need implementation details for a known component to reuse it rather than recreate it. For a list of all component names, use get_design_context with category 'components' instead.", inputSchema: { name: z.string() } }, async (args) => { if (!this.contract) return this.noContract() const component = this.contract.components[args.name] if (!component) { const available = Object.keys(this.contract.components).join(", ") return this.err(`Component '${args.name}' not found. Available: ${available}`) } return this.json(component) } ) - src/mcp/server.ts:241-249 (handler)Handler function (lines 241-249) that looks up a component by name from the contract. Returns the component JSON with source provenance, props, and variants, or an error with available component names if not found.
async (args) => { if (!this.contract) return this.noContract() const component = this.contract.components[args.name] if (!component) { const available = Object.keys(this.contract.components).join(", ") return this.err(`Component '${args.name}' not found. Available: ${available}`) } return this.json(component) } - src/mcp/server.ts:234-239 (schema)Input schema for 'get_component': expects a single 'name' field of type z.string()
{ description: "Look up a specific component by name. Read-only, no side effects. Returns JSON with source provenance, props, and variants, or an error listing available components if not found. Use this when you need implementation details for a known component to reuse it rather than recreate it. For a list of all component names, use get_design_context with category 'components' instead.", inputSchema: { name: z.string() } - src/mcp/server.ts:111-113 (helper)Helper method `json()` used by the handler to serialize the component data to a JSON text response
private json(v: unknown) { return this.text(JSON.stringify(v, null, 2)) } - src/mcp/server.ts:115-117 (helper)Helper method `err()` used by the handler to return an error response when component is not found
private err(msg: string) { return { content: [{ type: "text" as const, text: msg }], isError: true as const } }