Skip to main content
Glama

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>; }

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