Skip to main content
Glama

create_domain

Define domain-specific language (DSL) structures by specifying domain names, types, and predicates for creating mathematical diagrams in the Penrose MCP Server.

Instructions

Create domain-specific language (DSL) definitions

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYesDomain name
typesYes

Implementation Reference

  • The handler logic for the 'create_domain' tool. It parses and validates the input arguments (name and types with optional predicates), constructs a Domain object, stores it in a Map called 'domains', and returns a success message.
    case "create_domain": { const args = request.params.arguments; if (!args || typeof args !== 'object') { throw new Error('Invalid arguments'); } const { name, types } = args as { name?: string; types?: Array<any> }; if (!name || !Array.isArray(types)) { throw new Error('Invalid domain definition: requires name and types array'); } // Validate types const validatedTypes: Array<DomainType> = types.map(type => { if (!type.name || typeof type.name !== 'string') { throw new Error('Invalid type definition: requires name'); } const validatedType: DomainType = { name: type.name }; if (type.predicates) { if (!Array.isArray(type.predicates)) { throw new Error('Invalid predicates: must be an array'); } validatedType.predicates = type.predicates.map((pred: any) => { if (!pred.name || !Array.isArray(pred.args)) { throw new Error('Invalid predicate: requires name and args array'); } return { name: String(pred.name), args: pred.args.map((arg: any) => String(arg)) }; }); } return validatedType; }); const domain: Domain = { name, types: validatedTypes }; domains.set(name, domain); return { content: [{ type: "text", text: `Created domain: ${name}` }] }; }
  • The JSON schema defining the input structure for the 'create_domain' tool, including required 'name' (string) and 'types' array of objects with 'name' and optional 'predicates'.
    inputSchema: { type: "object", properties: { name: { type: "string", description: "Domain name" }, types: { type: "array", items: { type: "object", properties: { name: { type: "string", description: "Type name" }, predicates: { type: "array", items: { type: "object", properties: { name: { type: "string" }, args: { type: "array", items: { type: "string" } } }, required: ["name", "args"] } } }, required: ["name"] } } }, required: ["name", "types"] }
  • src/index.ts:172-212 (registration)
    The registration of the 'create_domain' tool in the tools list returned by the ListTools handler, including name, description, and inputSchema.
    { name: "create_domain", description: "Create domain-specific language (DSL) definitions", inputSchema: { type: "object", properties: { name: { type: "string", description: "Domain name" }, types: { type: "array", items: { type: "object", properties: { name: { type: "string", description: "Type name" }, predicates: { type: "array", items: { type: "object", properties: { name: { type: "string" }, args: { type: "array", items: { type: "string" } } }, required: ["name", "args"] } } }, required: ["name"] } } }, required: ["name", "types"] } },

Other Tools

Related 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