gemini-design-mcp 3.7.1 → 3.8.0
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 +87 -4
- package/package.json +8 -3
package/build/index.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
3
3
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
4
|
+
import { SSEServerTransport } from "@modelcontextprotocol/sdk/server/sse.js";
|
|
5
|
+
import express from "express";
|
|
6
|
+
import cors from "cors";
|
|
4
7
|
import { createFrontendSchema, createFrontend } from "./tools/create-frontend.js";
|
|
5
8
|
import { modifyFrontendSchema, modifyFrontend } from "./tools/modify-frontend.js";
|
|
6
9
|
import { snippetFrontendSchema, snippetFrontend } from "./tools/snippet-frontend.js";
|
|
@@ -8,7 +11,7 @@ import { generateVibesSchema, generateVibes } from "./tools/generate-vibes.js";
|
|
|
8
11
|
// Create MCP server
|
|
9
12
|
const server = new McpServer({
|
|
10
13
|
name: "gemini-design-mcp",
|
|
11
|
-
version: "3.
|
|
14
|
+
version: "3.8.0",
|
|
12
15
|
});
|
|
13
16
|
// =============================================================================
|
|
14
17
|
// TOOL 1: CREATE_FRONTEND
|
|
@@ -279,9 +282,89 @@ Keywords: minimal, whitespace, gallery, clean, sophisticated`, generateVibesSche
|
|
|
279
282
|
// START SERVER
|
|
280
283
|
// =============================================================================
|
|
281
284
|
async function main() {
|
|
282
|
-
const
|
|
283
|
-
|
|
284
|
-
|
|
285
|
+
const transportType = process.env.TRANSPORT || "stdio";
|
|
286
|
+
|
|
287
|
+
if (transportType === "sse") {
|
|
288
|
+
// SSE/HTTP mode for remote connections
|
|
289
|
+
const app = express();
|
|
290
|
+
|
|
291
|
+
app.use(cors({
|
|
292
|
+
origin: "*",
|
|
293
|
+
methods: ["GET", "POST", "OPTIONS"],
|
|
294
|
+
allowedHeaders: ["Content-Type", "Authorization", "mcp-session-id"],
|
|
295
|
+
credentials: true,
|
|
296
|
+
}));
|
|
297
|
+
app.use(express.json());
|
|
298
|
+
|
|
299
|
+
// Store active transports by session
|
|
300
|
+
const transports = new Map();
|
|
301
|
+
|
|
302
|
+
// Health check endpoint
|
|
303
|
+
app.get("/health", (req, res) => {
|
|
304
|
+
res.json({
|
|
305
|
+
status: "ok",
|
|
306
|
+
service: "gemini-design-mcp",
|
|
307
|
+
version: "3.8.0",
|
|
308
|
+
transport: "sse",
|
|
309
|
+
timestamp: Date.now(),
|
|
310
|
+
});
|
|
311
|
+
});
|
|
312
|
+
|
|
313
|
+
// SSE endpoint - establishes connection
|
|
314
|
+
app.get("/sse", async (req, res) => {
|
|
315
|
+
const authHeader = req.headers.authorization;
|
|
316
|
+
const apiKey = authHeader?.replace("Bearer ", "");
|
|
317
|
+
|
|
318
|
+
if (!apiKey || !apiKey.startsWith("gd_")) {
|
|
319
|
+
return res.status(401).json({
|
|
320
|
+
error: "Missing or invalid API key. Use Authorization: Bearer gd_xxx",
|
|
321
|
+
});
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
// Set API_KEY env var for this request (tools read from process.env)
|
|
325
|
+
process.env.API_KEY = apiKey;
|
|
326
|
+
|
|
327
|
+
// Create SSE transport
|
|
328
|
+
const transport = new SSEServerTransport("/messages", res);
|
|
329
|
+
const sessionId = `sess_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;
|
|
330
|
+
transports.set(sessionId, transport);
|
|
331
|
+
|
|
332
|
+
// Send session ID to client
|
|
333
|
+
res.setHeader("mcp-session-id", sessionId);
|
|
334
|
+
|
|
335
|
+
// Clean up on disconnect
|
|
336
|
+
res.on("close", () => {
|
|
337
|
+
transports.delete(sessionId);
|
|
338
|
+
});
|
|
339
|
+
|
|
340
|
+
await server.connect(transport);
|
|
341
|
+
});
|
|
342
|
+
|
|
343
|
+
// Messages endpoint - receives JSON-RPC from client
|
|
344
|
+
app.post("/messages", async (req, res) => {
|
|
345
|
+
const sessionId = req.query.sessionId || req.headers["mcp-session-id"];
|
|
346
|
+
const transport = transports.get(sessionId);
|
|
347
|
+
|
|
348
|
+
if (!transport) {
|
|
349
|
+
return res.status(400).json({ error: "Invalid or expired session" });
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
await transport.handlePostMessage(req, res);
|
|
353
|
+
});
|
|
354
|
+
|
|
355
|
+
const port = parseInt(process.env.PORT || "3000", 10);
|
|
356
|
+
app.listen(port, "0.0.0.0", () => {
|
|
357
|
+
console.log(`gemini-design-mcp v3.8.0 running on SSE transport`);
|
|
358
|
+
console.log(` SSE endpoint: http://0.0.0.0:${port}/sse`);
|
|
359
|
+
console.log(` Messages endpoint: http://0.0.0.0:${port}/messages`);
|
|
360
|
+
console.log(` Health check: http://0.0.0.0:${port}/health`);
|
|
361
|
+
});
|
|
362
|
+
} else {
|
|
363
|
+
// Stdio mode (default, for local IDE usage)
|
|
364
|
+
const transport = new StdioServerTransport();
|
|
365
|
+
await server.connect(transport);
|
|
366
|
+
console.error("gemini-design-mcp v3.8.0 running on stdio");
|
|
367
|
+
}
|
|
285
368
|
}
|
|
286
369
|
main().catch((error) => {
|
|
287
370
|
console.error("Fatal error:", error);
|
package/package.json
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gemini-design-mcp",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.8.0",
|
|
4
4
|
"description": "MCP server that uses Gemini 3 Pro for frontend/design code generation",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"bin": {
|
|
7
|
-
"gemini-design-mcp": "
|
|
7
|
+
"gemini-design-mcp": "build/index.js"
|
|
8
8
|
},
|
|
9
9
|
"type": "module",
|
|
10
10
|
"scripts": {
|
|
11
11
|
"build": "tsc",
|
|
12
12
|
"dev": "tsc --watch",
|
|
13
13
|
"start": "node build/index.js",
|
|
14
|
+
"start:sse": "TRANSPORT=sse node build/index.js",
|
|
14
15
|
"prepublishOnly": "echo 'Publishing...'"
|
|
15
16
|
},
|
|
16
17
|
"keywords": [
|
|
@@ -28,10 +29,14 @@
|
|
|
28
29
|
"dependencies": {
|
|
29
30
|
"@modelcontextprotocol/sdk": "^1.0.0",
|
|
30
31
|
"@google/genai": "^1.33.0",
|
|
31
|
-
"zod": "^3.23.0"
|
|
32
|
+
"zod": "^3.23.0",
|
|
33
|
+
"express": "^4.21.0",
|
|
34
|
+
"cors": "^2.8.5"
|
|
32
35
|
},
|
|
33
36
|
"devDependencies": {
|
|
34
37
|
"@types/node": "^20.0.0",
|
|
38
|
+
"@types/express": "^4.17.21",
|
|
39
|
+
"@types/cors": "^2.8.17",
|
|
35
40
|
"typescript": "^5.0.0"
|
|
36
41
|
},
|
|
37
42
|
"engines": {
|