Skip to main content
Glama

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

TableJSON Schema
NameRequiredDescriptionDefault
nameYes

Implementation Reference

  • 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)
      }
    )
  • 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)
    }
  • 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()
      }
  • 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))
    }
  • 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 }
    }
Behavior4/5

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

Describes no side effects, read-only nature, and return value (JSON with provenance, props, variants, or error with suggestions). No annotations present, so description carries full burden; it is transparent but lacks details like permissions or rate limits, which are less critical for a simple read tool.

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?

Three sentences, front-loaded with primary action, no wasted words. Clearly structured.

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

Completeness5/5

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

For a simple lookup tool with one parameter and no output schema, the description sufficiently explains input, output, and behavior. No missing critical information.

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 has 0% description coverage for the 'name' parameter. The description adds meaning by stating the parameter is the component name and that an error lists available components if not found. However, it does not specify name format or matching behavior.

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?

The description clearly states the tool looks up a specific component by name, is read-only, and returns JSON with details. It also distinguishes from sibling tool get_design_context for listing all components.

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

Usage Guidelines5/5

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

Explicitly says when to use: 'when you need implementation details for a known component to reuse it rather than recreate it.' Also provides alternative: 'For a list of all component names, use get_design_context with category components instead.'

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

Install Server

Other Tools

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/AI-by-design/primitiv'

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