Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
168 changes: 144 additions & 24 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"author": "serafim@21st.dev",
"license": "ISC",
"dependencies": {
"@modelcontextprotocol/sdk": "^1.8.0",
"@modelcontextprotocol/sdk": "^1.25.1",
"@types/cors": "^2.8.17",
"@types/express": "^5.0.0",
"cors": "^2.8.5",
Expand Down
7 changes: 6 additions & 1 deletion src/tools/create-ui.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import open from "open";
import { z } from "zod";
import { BaseTool } from "../utils/base-tool.js";
import { BaseTool, ToolAnnotations } from "../utils/base-tool.js";
import { CallbackServer } from "../utils/callback-server.js";
import { config } from "../utils/config.js";
import { git } from "../utils/git-operations.js";
Expand All @@ -19,6 +19,11 @@ interface CreateUiResponse {
export class CreateUiTool extends BaseTool {
name = UI_TOOL_NAME;
description = UI_TOOL_DESCRIPTION;
annotations: ToolAnnotations = {
title: "Create UI Component",
destructiveHint: true,
openWorldHint: true,
};

schema = z.object({
message: z.string().describe("Full users message"),
Expand Down
7 changes: 6 additions & 1 deletion src/tools/fetch-ui.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { z } from "zod";
import { BaseTool } from "../utils/base-tool.js";
import { BaseTool, ToolAnnotations } from "../utils/base-tool.js";
import { twentyFirstClient } from "../utils/http-client.js";

const FETCH_UI_TOOL_NAME = "21st_magic_component_inspiration";
Expand All @@ -15,6 +15,11 @@ interface FetchUiResponse {
export class FetchUiTool extends BaseTool {
name = FETCH_UI_TOOL_NAME;
description = FETCH_UI_TOOL_DESCRIPTION;
annotations: ToolAnnotations = {
title: "Fetch UI Inspiration",
readOnlyHint: true,
openWorldHint: true,
};

schema = z.object({
message: z.string().describe("Full users message"),
Expand Down
7 changes: 6 additions & 1 deletion src/tools/logo-search.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { z } from "zod";
import { promises as fs } from "fs";
import { BaseTool } from "../utils/base-tool.js";
import { BaseTool, ToolAnnotations } from "../utils/base-tool.js";

// Types for SVGL API responses
interface ThemeOptions {
Expand Down Expand Up @@ -49,6 +49,11 @@ Each result includes:
export class LogoSearchTool extends BaseTool {
name = LOGO_TOOL_NAME;
description = LOGO_TOOL_DESCRIPTION;
annotations: ToolAnnotations = {
title: "Search Logos",
destructiveHint: true,
openWorldHint: true,
};

schema = z.object({
queries: z
Expand Down
7 changes: 6 additions & 1 deletion src/tools/refine-ui.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { z } from "zod";
import { BaseTool } from "../utils/base-tool.js";
import { BaseTool, ToolAnnotations } from "../utils/base-tool.js";
import { twentyFirstClient } from "../utils/http-client.js";
import { getContentOfFile } from "../utils/get-content-of-file.js";

Expand All @@ -17,6 +17,11 @@ interface RefineUiResponse {
export class RefineUiTool extends BaseTool {
name = REFINE_UI_TOOL_NAME;
description = REFINE_UI_TOOL_DESCRIPTION;
annotations: ToolAnnotations = {
title: "Refine UI Component",
destructiveHint: true,
openWorldHint: true,
};

schema = z.object({
userMessage: z.string().describe("Full user's message about UI refinement"),
Expand Down
5 changes: 5 additions & 0 deletions src/utils/base-tool.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import { ToolAnnotations } from "@modelcontextprotocol/sdk/types.js";
import { z } from "zod";

export { ToolAnnotations };

export abstract class BaseTool {
abstract name: string;
abstract description: string;
abstract schema: z.ZodObject<any>;
abstract annotations: ToolAnnotations;

register(server: McpServer) {
server.tool(
this.name,
this.description,
this.schema.shape,
this.annotations,
this.execute.bind(this)
);
}
Expand Down