Skip to main content
Glama
petalframework

petal-components-mcp

Official

get_component

Retrieve the full schema for a specified petal_components component, including attrs, slots, defaults, allowed values, and a HEEx usage example to validate Phoenix LiveView markup.

Instructions

Get the full schema for a single petal_components component — attrs, slots, defaults, allowed values, and a HEEx usage example. Call this any time you're about to write a Phoenix LiveView component reference like <.pc_button> or <.input>, to ensure the attrs and slots match the real library.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYesComponent function name (e.g. 'button', 'modal', 'input'). Get the full list via list_components.

Implementation Reference

  • The request handler for the 'get_component' tool. It parses the component name from input, calls getComponent() from schemas, and returns the rendered schema or an error if not found.
    if (name === "get_component") {
      const { name: componentName } = GetComponentInput.parse(args);
      const component = getComponent(componentName);
    
      if (!component) {
        return {
          content: [
            {
              type: "text",
              text: `No component named "${componentName}" exists in petal_components v${schemas.version}. Call list_components to see what's available.`,
            },
          ],
          isError: true,
        };
      }
    
      return {
        content: [{ type: "text", text: renderComponent(component) }],
      };
    }
  • The getComponent() helper that looks up a component by name in the schemas JSON data and returns the Component or null.
    export function getComponent(name: string): Component | null {
      return schemas.components.find((c) => c.name === name) ?? null;
    }
  • src/mcp.ts:39-55 (registration)
    Tool registration/definition for 'get_component' in the ListToolsRequestSchema handler, including its name, description, and inputSchema.
    {
      name: "get_component",
      description:
        "Get the full schema for a single petal_components component — attrs, slots, defaults, allowed values, and a HEEx usage example. Call this any time you're about to write a Phoenix LiveView component reference like <.pc_button> or <.input>, to ensure the attrs and slots match the real library.",
      inputSchema: {
        type: "object",
        properties: {
          name: {
            type: "string",
            description:
              "Component function name (e.g. 'button', 'modal', 'input'). Get the full list via list_components.",
          },
        },
        required: ["name"],
        additionalProperties: false,
      },
    },
  • Zod schema (GetComponentInput) used to validate the 'name' argument for the get_component tool handler.
    const GetComponentInput = z.object({ name: z.string() });
Behavior3/5

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

With no annotations, the description explains the return content but doesn't explicitly state read-only behavior or potential error conditions. Adequate but could be more transparent about side-effect-free nature.

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, both essential and front-loaded with the primary purpose. No extraneous words.

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?

Given the simple single-parameter tool with no output schema, the description covers what the tool returns and how it relates to the sibling, making it fully adequate.

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 already describes the 'name' parameter; description adds useful cross-reference to 'list_components' for obtaining valid names, enhancing the value 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?

The description clearly states the tool retrieves the full schema for a single petal_components component, listing specific details (attrs, slots, defaults, etc.) and contrasting with sibling list_components.

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?

Explicitly advises calling when writing a Phoenix LiveView component reference to ensure attrs and slots match, providing strong when-to-use guidance. Does not explicitly state when not to use it, but the context implies it.

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/petalframework/petal-components-mcp'

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