diff --git a/common/src/types.ts b/common/src/types.ts index 31e2b14..cd7fd99 100644 --- a/common/src/types.ts +++ b/common/src/types.ts @@ -59,16 +59,6 @@ export interface PluginTaskResponse { data?: T; } -/** - * Parameters for the printText task. - */ -export interface PrintTextTaskParams { - /** - * The text to be displayed in Penpot. - */ - text: string; -} - /** * Parameters for the executeCode task. */ diff --git a/mcp-server/src/PenpotMcpServer.ts b/mcp-server/src/PenpotMcpServer.ts index d5dde23..1d75cf6 100644 --- a/mcp-server/src/PenpotMcpServer.ts +++ b/mcp-server/src/PenpotMcpServer.ts @@ -1,7 +1,6 @@ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; import { SSEServerTransport } from "@modelcontextprotocol/sdk/server/sse.js"; import { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/streamableHttp.js"; -import { PrintTextTool } from "./tools/PrintTextTool"; import { ExecuteCodeTool } from "./tools/ExecuteCodeTool"; import { PluginBridge } from "./PluginBridge"; import { ConfigurationLoader } from "./ConfigurationLoader"; @@ -61,7 +60,6 @@ export class PenpotMcpServer { private registerTools(): void { const toolInstances: Tool[] = [ - new PrintTextTool(this), new ExecuteCodeTool(this), new HighLevelOverviewTool(this), new PenpotApiInfoTool(this, this.apiDocs), diff --git a/mcp-server/src/tasks/PrintTextPluginTask.ts b/mcp-server/src/tasks/PrintTextPluginTask.ts deleted file mode 100644 index 345f4e3..0000000 --- a/mcp-server/src/tasks/PrintTextPluginTask.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { PluginTask } from "../PluginTask"; -import { PrintTextTaskParams, PluginTaskResult } from "@penpot-mcp/common"; - -/** - * Task for printing/creating text in Penpot. - * - * This task instructs the plugin to create a text element - * at the viewport center and select it. - */ -export class PrintTextPluginTask extends PluginTask> { - /** - * Creates a new print text task. - * - * @param params - The parameters containing the text to print - */ - constructor(params: PrintTextTaskParams) { - super("printText", params); - } -} diff --git a/mcp-server/src/tools/PrintTextTool.ts b/mcp-server/src/tools/PrintTextTool.ts deleted file mode 100644 index 9700266..0000000 --- a/mcp-server/src/tools/PrintTextTool.ts +++ /dev/null @@ -1,54 +0,0 @@ -import { z } from "zod"; -import { Tool } from "../Tool"; -import type { ToolResponse } from "../ToolResponse"; -import { TextResponse } from "../ToolResponse"; -import "reflect-metadata"; -import { PenpotMcpServer } from "../PenpotMcpServer"; -import { PrintTextPluginTask } from "../tasks/PrintTextPluginTask"; -import { PrintTextTaskParams } from "@penpot-mcp/common"; - -/** - * Arguments class for the PrintText tool with validation decorators. - */ -export class PrintTextArgs { - static schema = { - text: z.string().min(1, "Text cannot be empty"), - }; - - /** - * The text to create in Penpot. - */ - text!: string; -} - -/** - * Tool for creating text elements in Penpot via WebSocket communication. - * - * This tool sends a PluginTaskPrintText to connected plugin instances, - * instructing them to create and position text elements in the canvas. - */ -export class PrintTextTool extends Tool { - /** - * Creates a new PrintText tool instance. - * - * @param mcpServer - The MCP server instance - */ - constructor(mcpServer: PenpotMcpServer) { - super(mcpServer, PrintTextArgs.schema); - } - - public getToolName(): string { - return "print_text"; - } - - public getToolDescription(): string { - return "Creates text in Penpot at the viewport center and selects it"; - } - - protected async executeCore(args: PrintTextArgs): Promise { - const taskParams: PrintTextTaskParams = { text: args.text }; - const task = new PrintTextPluginTask(taskParams); - await this.mcpServer.pluginBridge.executePluginTask(task); - return new TextResponse(`Successfully created text "${args.text}" in Penpot.`); - } -} diff --git a/penpot-plugin/src/plugin.ts b/penpot-plugin/src/plugin.ts index e254878..7f3a81c 100644 --- a/penpot-plugin/src/plugin.ts +++ b/penpot-plugin/src/plugin.ts @@ -1,11 +1,10 @@ -import { PrintTextTaskHandler } from "./task-handlers/PrintTextTaskHandler"; import { ExecuteCodeTaskHandler } from "./task-handlers/ExecuteCodeTaskHandler"; import { Task, TaskHandler } from "./TaskHandler"; /** * Registry of all available task handlers. */ -const taskHandlers: TaskHandler[] = [new PrintTextTaskHandler(), new ExecuteCodeTaskHandler()]; +const taskHandlers: TaskHandler[] = [new ExecuteCodeTaskHandler()]; penpot.ui.open("Penpot MCP Plugin", `?theme=${penpot.theme}`, { width: 400, height: 300 }); diff --git a/penpot-plugin/src/task-handlers/PrintTextTaskHandler.ts b/penpot-plugin/src/task-handlers/PrintTextTaskHandler.ts deleted file mode 100644 index 3db37e2..0000000 --- a/penpot-plugin/src/task-handlers/PrintTextTaskHandler.ts +++ /dev/null @@ -1,31 +0,0 @@ -import { Task, TaskHandler } from "../TaskHandler"; -import { PrintTextTaskParams } from "../../../common/src"; - -/** - * Task handler for printing text to Penpot. - */ -export class PrintTextTaskHandler extends TaskHandler { - readonly taskType = "printText"; - - async handle(task: Task): Promise { - if (!task.params.text) { - throw new Error("printText task requires 'text' parameter"); - } - - const text = penpot.createText(task.params.text); - - if (text) { - // Center the text in the viewport - text.x = penpot.viewport.center.x; - text.y = penpot.viewport.center.y; - - // Select the newly created text - penpot.selection = [text]; - - console.log("Successfully created text:", task.params.text); - task.sendSuccess({ textId: text.id }); - } else { - throw new Error("Failed to create text element"); - } - } -}