mirror of
https://github.com/penpot/penpot-mcp.git
synced 2026-04-25 11:18:37 +00:00
Remove obsolete tool: PrintTextTool
This commit is contained in:
parent
4cbce1e009
commit
0b9404e2a2
@ -59,16 +59,6 @@ export interface PluginTaskResponse<T> {
|
||||
data?: T;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parameters for the printText task.
|
||||
*/
|
||||
export interface PrintTextTaskParams {
|
||||
/**
|
||||
* The text to be displayed in Penpot.
|
||||
*/
|
||||
text: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parameters for the executeCode task.
|
||||
*/
|
||||
|
||||
@ -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<any>[] = [
|
||||
new PrintTextTool(this),
|
||||
new ExecuteCodeTool(this),
|
||||
new HighLevelOverviewTool(this),
|
||||
new PenpotApiInfoTool(this, this.apiDocs),
|
||||
|
||||
@ -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<PrintTextTaskParams, PluginTaskResult<any>> {
|
||||
/**
|
||||
* Creates a new print text task.
|
||||
*
|
||||
* @param params - The parameters containing the text to print
|
||||
*/
|
||||
constructor(params: PrintTextTaskParams) {
|
||||
super("printText", params);
|
||||
}
|
||||
}
|
||||
@ -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<PrintTextArgs> {
|
||||
/**
|
||||
* 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<ToolResponse> {
|
||||
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.`);
|
||||
}
|
||||
}
|
||||
@ -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 });
|
||||
|
||||
|
||||
@ -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<PrintTextTaskParams> {
|
||||
readonly taskType = "printText";
|
||||
|
||||
async handle(task: Task<PrintTextTaskParams>): Promise<void> {
|
||||
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");
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user