Skip to main content
Glama
bmorphism

Penrose MCP Server

create_substance

Define mathematical objects and relationships to create visual diagrams using Penrose's domain-specific languages, enabling natural language specification of types and representation rules.

Instructions

Define mathematical objects and relationships

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
domainYesReference to domain
declarationsYes
statementsYes

Implementation Reference

  • Handler for 'create_substance' tool: validates arguments, checks referenced domain exists, parses declarations and statements, stores Substance in memory map, returns confirmation message.
    case "create_substance": {
      const args = request.params.arguments;
      if (!args || typeof args !== 'object') {
        throw new Error('Invalid arguments');
      }
    
      const { domain: domainName, declarations, statements } = args as {
        domain?: string;
        declarations?: Array<any>;
        statements?: Array<any>;
      };
    
      if (!domainName || !Array.isArray(declarations) || !Array.isArray(statements)) {
        throw new Error('Invalid substance definition: requires domain, declarations array, and statements array');
      }
    
      // Validate domain exists
      if (!domains.has(domainName)) {
        throw new Error(`Domain ${domainName} not found`);
      }
    
      // Validate declarations
      const validatedDeclarations: Array<Declaration> = declarations.map(decl => {
        if (!decl.type || !Array.isArray(decl.objects)) {
          throw new Error('Invalid declaration: requires type and objects array');
        }
        return {
          type: String(decl.type),
          objects: decl.objects.map((obj: any) => String(obj))
        };
      });
    
      // Validate statements
      const validatedStatements: Array<Statement> = statements.map(stmt => {
        if (!stmt.predicate || !Array.isArray(stmt.args)) {
          throw new Error('Invalid statement: requires predicate and args array');
        }
        return {
          predicate: String(stmt.predicate),
          args: stmt.args.map((arg: any) => String(arg))
        };
      });
    
      const substance: Substance = {
        domain: domainName,
        declarations: validatedDeclarations,
        statements: validatedStatements
      };
    
      substances.set(domainName, substance);
      return {
        content: [{
          type: "text",
          text: `Created substance for domain: ${domainName}`
        }]
      };
    }
  • JSON Schema defining the input parameters for the 'create_substance' tool: domain reference, array of declarations (type and objects), array of statements (predicate and args).
    inputSchema: {
      type: "object",
      properties: {
        domain: {
          type: "string",
          description: "Reference to domain"
        },
        declarations: {
          type: "array",
          items: {
            type: "object",
            properties: {
              type: { type: "string" },
              objects: {
                type: "array",
                items: { type: "string" }
              }
            },
            required: ["type", "objects"]
          }
        },
        statements: {
          type: "array",
          items: {
            type: "object",
            properties: {
              predicate: { type: "string" },
              args: {
                type: "array",
                items: { type: "string" }
              }
            },
            required: ["predicate", "args"]
          }
        }
      },
      required: ["domain", "declarations", "statements"]
    }
  • src/index.ts:213-254 (registration)
    Registration of the 'create_substance' tool in the ListTools response, including name, description, and input schema.
    {
      name: "create_substance",
      description: "Define mathematical objects and relationships",
      inputSchema: {
        type: "object",
        properties: {
          domain: {
            type: "string",
            description: "Reference to domain"
          },
          declarations: {
            type: "array",
            items: {
              type: "object",
              properties: {
                type: { type: "string" },
                objects: {
                  type: "array",
                  items: { type: "string" }
                }
              },
              required: ["type", "objects"]
            }
          },
          statements: {
            type: "array",
            items: {
              type: "object",
              properties: {
                predicate: { type: "string" },
                args: {
                  type: "array",
                  items: { type: "string" }
                }
              },
              required: ["predicate", "args"]
            }
          }
        },
        required: ["domain", "declarations", "statements"]
      }
    },
  • TypeScript interface defining the structure of a Substance used by the create_substance tool.
    interface Substance {
      domain: string;
      declarations: Array<Declaration>;
      statements: Array<Statement>;
    }
  • TypeScript interfaces for Declaration and Statement, components of Substance.
    interface Declaration {
      type: string;
      objects: Array<string>;
    }
    
    interface Statement {
      predicate: string;
      args: Array<string>;
    }
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the tool defines objects and relationships, implying a write operation, but doesn't disclose critical traits like whether it's idempotent, requires specific permissions, handles errors, or what happens on success/failure. For a tool with 3 required parameters and no annotation coverage, this is a significant gap in transparency.

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 extremely concise with a single, front-loaded sentence: 'Define mathematical objects and relationships.' It wastes no words and directly states the core purpose, making it easy for an agent to parse quickly. Every part of the sentence earns its place by conveying essential information.

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 (3 required parameters, no annotations, no output schema, and low schema coverage), the description is incomplete. It doesn't explain what the tool returns, how to interpret results, or provide enough context for safe and effective use. For a definition tool with significant parameter details, more information is needed to guide the agent adequately.

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 low at 33%, with only the 'domain' parameter having a description ('Reference to domain'). The description 'Define mathematical objects and relationships' adds minimal semantic context, hinting that 'declarations' might define objects and 'statements' might define relationships, but it doesn't explain parameter formats, constraints, or examples. This insufficiently compensates for the schema's lack of detail.

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 'Define mathematical objects and relationships' clearly states the tool's purpose with a specific verb ('define') and resource ('mathematical objects and relationships'). It distinguishes from siblings like 'create_domain' or 'generate_diagram' by focusing on mathematical definitions rather than domains, styles, or diagrams. However, it doesn't explicitly differentiate from 'create_style' which might also involve definitions, leaving some ambiguity.

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, context, or exclusions, such as whether it's for initial setup or ongoing updates, or how it relates to sibling tools like 'create_domain' or 'create_style'. This lack of usage context leaves the agent to infer appropriate scenarios.

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