Skip to main content
Glama

create_style

Define visual representation rules for mathematical diagrams by specifying canvas dimensions and styling rules with selectors, properties, and constraints.

Instructions

Define visual representation rules

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
canvasYes
rulesYes

Implementation Reference

  • The main handler logic for the 'create_style' tool. It validates the input arguments (canvas with width/height and array of rules), constructs a Style object with validated rules, generates a unique ID, stores it in the global 'styles' Map, and returns a success message with the 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)
    The tool registration entry in the listTools response, including the name, description, and detailed inputSchema for validation.
    { 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"] } },
  • The input schema definition for the 'create_style' tool, specifying the structure for canvas (width, height) and rules array (selector, properties, constraints).
    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"] }

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