gemini-design-mcp 1.0.3 → 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/build/index.js CHANGED
@@ -4,6 +4,7 @@ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js"
4
4
  import { generateFrontendSchema, generateFrontend } from "./tools/generate-frontend.js";
5
5
  import { improveFrontendSchema, improveFrontend } from "./tools/improve-frontend.js";
6
6
  import { suggestDesignSchema, suggestDesign } from "./tools/suggest-design.js";
7
+ import { patchFrontendSchema, patchFrontend } from "./tools/patch-frontend.js";
7
8
  // Create MCP server
8
9
  const server = new McpServer({
9
10
  name: "gemini-design-mcp",
@@ -24,6 +25,19 @@ Use for design modifications, UX improvements, or visual refactoring.`, improveF
24
25
  // Tool 3: suggest_design
25
26
  server.tool("suggest_design", `Returns design suggestions without generating code.
26
27
  Useful for exploring directions before coding, saves tokens.`, suggestDesignSchema, suggestDesign);
28
+ // Tool 4: patch_frontend
29
+ server.tool("patch_frontend", `Apply targeted modifications to existing code using JSON patches.
30
+ Returns ONLY patches, not full code - much more efficient for modifications.
31
+
32
+ The calling agent should:
33
+ 1. Provide a file_structure summary (what's in the file, line ranges)
34
+ 2. Send ONLY the target_section that needs modification (not the entire file)
35
+ 3. List the modifications to apply
36
+
37
+ This tool is language-agnostic and works with any programming language.
38
+ Use the optional 'language' parameter to help Gemini understand syntax.
39
+
40
+ Returns JSON patches with operations: insert_after, insert_before, replace, delete.`, patchFrontendSchema, patchFrontend);
27
41
  // Start server
28
42
  async function main() {
29
43
  const transport = new StdioServerTransport();
@@ -1,3 +1,4 @@
1
1
  export declare const GENERATE_FRONTEND_PROMPT = "You are an expert UI/UX designer and frontend developer.\n\nRULES:\n1. COMPLETE and functional code - never use placeholders like \"// TODO\" or \"...\"\n2. If CONTEXT is provided, match the existing style\n3. If no context, you have full creative freedom\n4. Respect the requested tech stack/framework\n5. Return ONLY the code, no explanations";
2
2
  export declare const IMPROVE_FRONTEND_PROMPT = "You are an expert UI/UX designer and frontend developer.\nYou improve existing frontend code based on the feedback provided.\n\nRULES:\n1. Keep the general structure unless asked otherwise\n2. Only improve the aspects mentioned in the feedback\n3. Maintain consistency with the rest of the code\n4. Return the COMPLETE improved code, not just the changes\n5. No explanations, just the code";
3
3
  export declare const SUGGEST_DESIGN_PROMPT = "You are an expert UI/UX designer.\nYou provide concise and actionable design suggestions.\n\nRULES:\n1. Short and precise suggestions\n2. Focus on visual impact and UX\n3. Propose 3-5 ideas maximum\n4. Format: bullet points\n5. No code, just ideas";
4
+ export declare const PATCH_FRONTEND_PROMPT = "You are an expert developer.\nYou return ONLY JSON patches to modify code. NEVER return full code.\n\nYou receive:\n- A file structure overview (to understand context)\n- A target section (the actual code to modify)\n- A list of modifications to apply\n\nOUTPUT FORMAT (strict JSON, no markdown fences):\n{\n \"patches\": [\n {\n \"operation\": \"insert_after | insert_before | replace | delete\",\n \"find\": \"exact unique text/code snippet to locate in target section\",\n \"content\": \"new code to insert or replace with (omit for delete)\"\n }\n ]\n}\n\nRULES:\n1. NEVER return full code, ONLY the JSON patches object\n2. \"find\" MUST be an exact string that exists in the target section (copy-paste precision)\n3. \"find\" MUST be unique within the target section - use enough context to ensure uniqueness\n4. Keep patches minimal - only what's needed for each modification\n5. Preserve original indentation and code style\n6. For multi-line \"find\" or \"content\", use \\n for newlines in JSON\n7. Operations:\n - \"insert_after\": insert content after the found text\n - \"insert_before\": insert content before the found text\n - \"replace\": replace the found text with content\n - \"delete\": remove the found text (no content needed)\n8. Return ONLY valid JSON, no explanations, no markdown";
@@ -24,3 +24,35 @@ RULES:
24
24
  3. Propose 3-5 ideas maximum
25
25
  4. Format: bullet points
26
26
  5. No code, just ideas`;
27
+ export const PATCH_FRONTEND_PROMPT = `You are an expert developer.
28
+ You return ONLY JSON patches to modify code. NEVER return full code.
29
+
30
+ You receive:
31
+ - A file structure overview (to understand context)
32
+ - A target section (the actual code to modify)
33
+ - A list of modifications to apply
34
+
35
+ OUTPUT FORMAT (strict JSON, no markdown fences):
36
+ {
37
+ "patches": [
38
+ {
39
+ "operation": "insert_after | insert_before | replace | delete",
40
+ "find": "exact unique text/code snippet to locate in target section",
41
+ "content": "new code to insert or replace with (omit for delete)"
42
+ }
43
+ ]
44
+ }
45
+
46
+ RULES:
47
+ 1. NEVER return full code, ONLY the JSON patches object
48
+ 2. "find" MUST be an exact string that exists in the target section (copy-paste precision)
49
+ 3. "find" MUST be unique within the target section - use enough context to ensure uniqueness
50
+ 4. Keep patches minimal - only what's needed for each modification
51
+ 5. Preserve original indentation and code style
52
+ 6. For multi-line "find" or "content", use \\n for newlines in JSON
53
+ 7. Operations:
54
+ - "insert_after": insert content after the found text
55
+ - "insert_before": insert content before the found text
56
+ - "replace": replace the found text with content
57
+ - "delete": remove the found text (no content needed)
58
+ 8. Return ONLY valid JSON, no explanations, no markdown`;
@@ -0,0 +1,18 @@
1
+ import { z } from "zod";
2
+ export declare const patchFrontendSchema: {
3
+ file_structure: z.ZodString;
4
+ target_section: z.ZodString;
5
+ modifications: z.ZodArray<z.ZodString, "many">;
6
+ language: z.ZodOptional<z.ZodString>;
7
+ };
8
+ export declare function patchFrontend(params: {
9
+ file_structure: string;
10
+ target_section: string;
11
+ modifications: string[];
12
+ language?: string;
13
+ }): Promise<{
14
+ content: {
15
+ type: "text";
16
+ text: string;
17
+ }[];
18
+ }>;
@@ -0,0 +1,28 @@
1
+ import { z } from "zod";
2
+ import { generateWithGemini } from "../lib/gemini.js";
3
+ import { PATCH_FRONTEND_PROMPT } from "../prompts/system.js";
4
+ export const patchFrontendSchema = {
5
+ file_structure: z.string().describe("Summary of the file structure (e.g., 'lines 1-50: imports, lines 51-100: Header component, lines 101-200: LoginForm')"),
6
+ target_section: z.string().describe("The specific section of code to modify (only the relevant part, not the entire file)"),
7
+ modifications: z.array(z.string()).describe("List of modifications to apply to the target section"),
8
+ language: z.string().optional().describe("Programming language or framework (e.g., 'typescript', 'python', 'c++', 'swift'). Helps Gemini understand syntax."),
9
+ };
10
+ export async function patchFrontend(params) {
11
+ const { file_structure, target_section, modifications, language } = params;
12
+ const langHint = language ? `\nLANGUAGE/FRAMEWORK: ${language}` : "";
13
+ const userPrompt = `FILE STRUCTURE OVERVIEW:
14
+ ${file_structure}
15
+ ${langHint}
16
+
17
+ TARGET SECTION TO MODIFY:
18
+ \`\`\`
19
+ ${target_section}
20
+ \`\`\`
21
+
22
+ MODIFICATIONS REQUESTED:
23
+ ${modifications.map((m, i) => `${i + 1}. ${m}`).join("\n")}`;
24
+ const result = await generateWithGemini(PATCH_FRONTEND_PROMPT, userPrompt);
25
+ return {
26
+ content: [{ type: "text", text: result }],
27
+ };
28
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gemini-design-mcp",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "description": "MCP server that uses Gemini 3 Pro for frontend/design code generation",
5
5
  "main": "build/index.js",
6
6
  "bin": {