create_domain
Define domain-specific languages for mathematical diagrams by specifying types and predicates to create visual representation rules.
Instructions
Create domain-specific language (DSL) definitions
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | Domain name | |
| types | Yes |
Implementation Reference
- src/index.ts:308-351 (handler)Main execution logic for the 'create_domain' tool. Validates input arguments, constructs and stores a Domain object in the in-memory 'domains' Map, and returns a confirmation 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}` }] }; }
- src/index.ts:175-211 (schema)JSON Schema defining the expected input structure for the 'create_domain' tool, including domain name and array of types with 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)Tool registration in the ListTools response, specifying name, description, and input schema for 'create_domain'.{ 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"] } },
- src/index.ts:23-34 (schema)TypeScript type definitions for DomainType and Domain, used to type-check and structure the data created by the tool.interface DomainType { name: string; predicates?: Array<{ name: string; args: Array<string>; }>; } interface Domain { name: string; types: Array<DomainType>; }