Skip to main content
Glama

create_style

Generate visual representation rules for mathematical diagrams by defining canvas dimensions and styling properties. Use structured input to customize selectors, properties, and constraints.

Instructions

Define visual representation rules

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
canvasYes
rulesYes

Implementation Reference

  • Handler for the 'create_style' tool. Validates the input canvas dimensions and rules array, constructs a Style object with validated rules, generates a unique ID, stores it in the in-memory styles Map, and returns a confirmation message with the style ID.
    case "create_style": { const args = request.params.arguments; if (!args || typeof args !== 'object') { throw new Error('Invalid arguments'); } const { canvas, rules } = args as { canvas?: { width?: number; height?: number }; rules?: Array<any>; }; if (!canvas || typeof canvas.width !== 'number' || typeof canvas.height !== 'number') { throw new Error('Invalid style definition: requires canvas with width and height'); } if (!Array.isArray(rules)) { throw new Error('Invalid style definition: requires rules array'); } // Validate rules const validatedRules: Array<StyleRule> = rules.map(rule => { if (!rule.selector || typeof rule.selector !== 'string' || !rule.properties || typeof rule.properties !== 'object' || !Array.isArray(rule.constraints)) { throw new Error('Invalid rule: requires selector, properties object, and constraints array'); } return { selector: rule.selector, properties: rule.properties, constraints: rule.constraints.map((c: any) => String(c)) }; }); const style: Style = { canvas: { width: canvas.width, height: canvas.height }, rules: validatedRules }; const id = `style_${styles.size + 1}`; styles.set(id, style); return { content: [{ type: "text", text: `Created style: ${id}` }] }; }
  • src/index.ts:255-287 (registration)
    Tool registration for 'create_style' in the listTools handler, including name, description, and detailed input schema defining canvas (width/height) and rules (selector, properties, constraints).
    { name: "create_style", description: "Define visual representation rules", inputSchema: { type: "object", properties: { canvas: { type: "object", properties: { width: { type: "number" }, height: { type: "number" } }, required: ["width", "height"] }, rules: { type: "array", items: { type: "object", properties: { selector: { type: "string" }, properties: { type: "object" }, constraints: { type: "array", items: { type: "string" } } }, required: ["selector", "properties", "constraints"] } } }, required: ["canvas", "rules"] } },
  • TypeScript interfaces defining the structure of StyleRule and Style objects used for input validation and storage in the create_style tool handler.
    interface StyleRule { selector: string; properties: Record<string, any>; constraints: Array<string>; } interface Style { canvas: { width: number; height: number; }; rules: Array<StyleRule>; }

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