Skip to main content
Glama
bmorphism

Penrose MCP Server

generate_diagram

Create mathematical diagrams by defining domain concepts, substance relationships, and visual style rules using Penrose's domain-specific languages.

Instructions

Generate diagram from domain/substance/style

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
domainYes
substanceYes
styleYes
variationNo

Implementation Reference

  • The handler function for the 'generate_diagram' tool. It validates the existence of the specified domain, substance, and style resources, generates a static SVG diagram depicting two objects 'A' and 'B' with a subset relationship arrow, and returns the SVG as a base64-encoded data URI.
        case "generate_diagram": {
          const { domain: domainName, substance: substanceName, style: styleName } = request.params.arguments as {
            domain: string;
            substance: string;
            style: string;
          };
    
          // Validate all components exist
          const domain = domains.get(domainName);
          if (!domain) throw new Error(`Domain ${domainName} not found`);
    
          const substance = substances.get(substanceName);
          if (!substance) throw new Error(`Substance ${substanceName} not found`);
    
          const style = styles.get(styleName);
          if (!style) throw new Error(`Style ${styleName} not found`);
    
          // Generate SVG diagram with proper XML declaration and formatting
          const svg = `<?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
    <svg width="${style.canvas.width}" height="${style.canvas.height}" xmlns="http://www.w3.org/2000/svg" version="1.1">
      <rect width="100%" height="100%" fill="white"/>
      <text x="10" y="20" font-family="Arial">Domain: ${domain.name}</text>
      <text x="10" y="40" font-family="Arial">Substance: ${substanceName}</text>
      <text x="10" y="60" font-family="Arial">Style: ${styleName}</text>
      
      <!-- Set visualization -->
      <circle cx="150" cy="150" r="50" fill="#e0e0e0" stroke="black"/>
      <text x="150" y="150" text-anchor="middle" font-family="Arial">A</text>
      
      <circle cx="250" cy="150" r="50" fill="#e0e0e0" stroke="black"/>
      <text x="250" y="150" text-anchor="middle" font-family="Arial">B</text>
      
      <!-- Subset relationship -->
      <defs>
        <marker id="arrowhead" markerWidth="10" markerHeight="7" 
        refX="9" refY="3.5" orient="auto">
          <polygon points="0 0, 10 3.5, 0 7" fill="black"/>
        </marker>
      </defs>
      <path d="M 190 150 L 210 150" stroke="black" marker-end="url(#arrowhead)"/>
    </svg>`;
    
          // Convert SVG to base64 with proper data URI format
          const svgBase64 = `data:image/svg+xml;base64,${Buffer.from(svg).toString('base64')}`;
    
          return {
            content: [{
              type: "text",
              text: svgBase64
            }]
          };
        }
  • src/index.ts:288-301 (registration)
    Registration of the 'generate_diagram' tool in the list of available tools, including its description and input schema definition.
    {
      name: "generate_diagram",
      description: "Generate diagram from domain/substance/style",
      inputSchema: {
        type: "object",
        properties: {
          domain: { type: "string" },
          substance: { type: "string" },
          style: { type: "string" },
          variation: { type: "string" }
        },
        required: ["domain", "substance", "style"]
      }
    }
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 'Generate diagram' but doesn't explain what this entails—e.g., whether it's a read-only operation, if it modifies data, requires authentication, has rate limits, or what the output looks like. This is a significant gap for a tool with no annotation coverage.

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 with no wasted words. It's appropriately sized and front-loaded, clearly stating the tool's basic function without unnecessary elaboration.

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 complexity (4 parameters, no annotations, no output schema), the description is incomplete. It lacks details on behavior, parameter meanings, output format, and usage context, making it inadequate for an agent to understand how to effectively invoke the tool beyond a superficial level.

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 schema provides no parameter details. The description mentions 'domain/substance/style' as inputs, which maps to three of the four parameters (domain, substance, style), but it omits 'variation' and doesn't explain what these parameters mean, their formats, or how they influence diagram generation, failing to compensate for the coverage gap.

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

Purpose3/5

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

The description 'Generate diagram from domain/substance/style' states the basic action (generate) and resources (diagram from three inputs), but it's vague about what kind of diagram or how it's generated. It doesn't distinguish from siblings like 'create_domain', which suggests different operations, but the purpose lacks specificity beyond the basic verb+resource combination.

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?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites, exclusions, or relationships to sibling tools like 'create_domain', 'create_style', or 'create_substance', leaving the agent with no context for tool selection.

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/bmorphism/penrose-mcp'

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