Skip to main content
Glama

get_rendered_component

Retrieve a rendered image of a design component from Penpot by specifying its ID, enabling AI assistants to access visual design assets for automated workflows.

Instructions

Return a rendered component image by its ID.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
component_idYes

Implementation Reference

  • Primary handler function for the 'get_rendered_component' tool. Retrieves the pre-rendered image from the in-memory cache using the component ID as key. Registered as an MCP tool when resources are exposed as tools.
    @self.mcp.tool()
    def get_rendered_component(component_id: str) -> Image:
        """Return a rendered component image by its ID."""
        if component_id in self.rendered_components:
            return self.rendered_components[component_id]
        raise Exception(f"Component with ID {component_id} not found")
  • Alternative registration of the same handler function as a dynamic MCP resource at URI 'rendered-component://{component_id}', providing image/png content. Used when resources are not exposed as tools.
    @self.mcp.resource("rendered-component://{component_id}", mime_type="image/png")
    def get_rendered_component(component_id: str) -> Image:
        """Return a rendered component image by its ID."""
        if component_id in self.rendered_components:
            return self.rendered_components[component_id]
        raise Exception(f"Component with ID {component_id} not found")
  • Helper code within the 'get_object_tree' tool that generates the rendered image using 'export_object' and stores it in the self.rendered_components cache with MD5 hash of file_id:object_id as the key. This populates the cache used by get_rendered_component.
    image_id = hashlib.md5(f"{file_id}:{object_id}".encode()).hexdigest()
    self.rendered_components[image_id] = image
    
    # Image URI preferences:
    # 1. HTTP server URL if available
    # 2. Fallback to MCP resource URI
    image_uri = f"render_component://{image_id}"
  • Supporting 'export_object' tool that performs the actual rendering/export of Penpot objects to images via the Penpot API. Called by 'get_object_tree' to generate images stored for later retrieval by 'get_rendered_component'.
    def export_object(
            file_id: str,
            page_id: str,
            object_id: str,
            export_type: str = "png",
            scale: int = 1) -> Image:
        """Export a Penpot design object as an image.
        
        Args:
            file_id: The ID of the Penpot file
            page_id: The ID of the page containing the object
            object_id: The ID of the object to export
            export_type: Image format (png, svg, etc.)
            scale: Scale factor for the exported image
        """
        temp_filename = None
        try:
            import tempfile
            temp_dir = tempfile.gettempdir()
            temp_filename = os.path.join(temp_dir, f"{object_id}.{export_type}")
            output_path = self.api.export_and_download(
                file_id=file_id,
                page_id=page_id,
                object_id=object_id,
                export_type=export_type,
                scale=scale,
                save_to_file=temp_filename
            )
            with open(output_path, "rb") as f:
                file_content = f.read()
                
            image = Image(data=file_content, format=export_type)
            
            # If HTTP server is enabled, add the image to the server
            if self.image_server and self.image_server.is_running:
                image_id = hashlib.md5(f"{file_id}:{page_id}:{object_id}".encode()).hexdigest()
                # Use the current image_server_url to ensure the correct port
                image_url = self.image_server.add_image(image_id, file_content, export_type)
                # Add HTTP URL to the image metadata
                image.http_url = image_url
                
            return image
        except Exception as e:
            if isinstance(e, CloudFlareError):
                raise Exception(f"CloudFlare Protection: {str(e)}")
            else:
                raise Exception(f"Export failed: {str(e)}")
        finally:
            if temp_filename and os.path.exists(temp_filename):
                try:
                    os.remove(temp_filename)
                except Exception as e:
                    print(f"Warning: Failed to delete temporary file {temp_filename}: {str(e)}")
    @self.mcp.tool()
  • Conditional registration logic in server constructor that determines whether to register get_rendered_component as a tool (when RESOURCES_AS_TOOLS=True) or as a resource (when False).
    if config.RESOURCES_AS_TOOLS:
        self._register_resources(resources_only=True)
        self._register_tools(include_resource_tools=True)
    else:
        self._register_resources(resources_only=False)
        self._register_tools(include_resource_tools=False)
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 burden of behavioral disclosure. It states the tool returns an image, but doesn't describe format, size, caching behavior, error handling, or authentication needs. For a tool with zero annotation coverage, this leaves critical behavioral traits unspecified.

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?

The description is a single, efficient sentence that directly states the tool's purpose. It's front-loaded with no wasted words, making it easy to parse quickly.

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

Completeness2/5

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

Given the tool's complexity (retrieving rendered images), lack of annotations, no output schema, and low parameter coverage, the description is incomplete. It doesn't address return values, error cases, or operational context, leaving the agent with insufficient information for reliable invocation.

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

Parameters2/5

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

Schema description coverage is 0%, so the description must compensate. It mentions 'component_id' but doesn't explain what a component ID is, its format, or where to find it. With one undocumented parameter, the description adds minimal value beyond the schema's basic structure.

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 clearly states the action ('Return') and resource ('rendered component image by its ID'), making the purpose understandable. However, it doesn't distinguish this tool from siblings like 'get_file' or 'get_cached_files', which might also retrieve files or images, so it lacks sibling differentiation.

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

Usage Guidelines2/5

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

No guidance is provided on when to use this tool versus alternatives. The description doesn't mention prerequisites, context, or exclusions, leaving the agent without usage instructions. This is a significant gap in helping the agent select the correct tool.

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/montevive/penpot-mcp'

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