@nuxtjs/mcp-toolkit 0.6.1 → 0.6.2

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/dist/module.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nuxtjs/mcp-toolkit",
3
- "version": "0.6.1",
3
+ "version": "0.6.2",
4
4
  "configKey": "mcp",
5
5
  "docs": "https://mcp-toolkit.nuxt.dev/getting-started/installation",
6
6
  "mcp": "https://mcp-toolkit.nuxt.dev/mcp",
package/dist/module.mjs CHANGED
@@ -1,13 +1,79 @@
1
- import { execSync } from 'node:child_process';
2
1
  import { logger, createResolver, defineNuxtModule, addComponent, addServerHandler, addServerTemplate, addServerImports } from '@nuxt/kit';
3
2
  import { defu } from 'defu';
4
3
  import { loadAllDefinitions } from '../dist/runtime/server/mcp/loaders/index.js';
5
4
  import { defaultMcpConfig } from '../dist/runtime/server/mcp/config.js';
6
5
  import { ROUTES } from '../dist/runtime/server/mcp/constants.js';
7
6
  import { addDevToolsCustomTabs } from '../dist/runtime/server/mcp/devtools/index.js';
7
+ import { execSync } from 'node:child_process';
8
+ import { existsSync, readFileSync } from 'node:fs';
9
+ import { homedir } from 'node:os';
10
+ import { join } from 'node:path';
11
+
12
+ const IDE_CONFIGS = {
13
+ cursor: { name: "Cursor" },
14
+ vscode: { name: "VS Code" }
15
+ };
16
+ function terminalLink(text, url) {
17
+ return `\x1B]8;;${url}\x07${text}\x1B]8;;\x07`;
18
+ }
19
+ function isMCPInstalled(mcpJson, mcpUrl) {
20
+ if (!mcpJson.mcpServers) return false;
21
+ return Object.values(mcpJson.mcpServers).some((server) => server.url === mcpUrl);
22
+ }
23
+ function detectIDE() {
24
+ const env = process.env;
25
+ if (env.__CFBundleIdentifier === "com.todesktop.230313mzl4w4u92") return "cursor";
26
+ if (env.__CFBundleIdentifier === "com.microsoft.VSCode") return "vscode";
27
+ if (env.CURSOR_TRACE_ID) return "cursor";
28
+ const ipc = env.VSCODE_IPC_HOOK || "";
29
+ if (ipc.includes("/Cursor/")) return "cursor";
30
+ if (ipc.includes("/Code/")) return "vscode";
31
+ try {
32
+ let pid = process.ppid;
33
+ for (let i = 0; i < 10 && pid > 1; i++) {
34
+ const name = execSync(`ps -o comm= -p ${pid}`, { stdio: ["pipe", "pipe", "ignore"] }).toString().toLowerCase();
35
+ if (name.includes("cursor")) return "cursor";
36
+ if (name.includes("code helper") || name.includes("code.app")) return "vscode";
37
+ pid = Number.parseInt(execSync(`ps -o ppid= -p ${pid}`, { stdio: ["pipe", "pipe", "ignore"] }).toString().trim());
38
+ }
39
+ } catch {
40
+ }
41
+ return null;
42
+ }
43
+ function getMCPConfigPaths(ide, rootDir) {
44
+ return [
45
+ {
46
+ path: join(rootDir, `.${ide}/mcp.json`),
47
+ displayPath: `.${ide}/mcp.json`
48
+ },
49
+ {
50
+ path: join(homedir(), `.${ide}/mcp.json`),
51
+ displayPath: `~/.${ide}/mcp.json`
52
+ }
53
+ ];
54
+ }
55
+ function findInstalledMCPConfig(ide, rootDir, mcpUrl) {
56
+ const configPaths = getMCPConfigPaths(ide, rootDir);
57
+ for (const config of configPaths) {
58
+ if (existsSync(config.path)) {
59
+ try {
60
+ const mcpJson = JSON.parse(readFileSync(config.path, "utf8"));
61
+ if (isMCPInstalled(mcpJson, mcpUrl)) {
62
+ return config;
63
+ }
64
+ } catch {
65
+ }
66
+ }
67
+ }
68
+ return null;
69
+ }
70
+ function generateDeeplinkUrl(baseUrl, route, ide, serverName) {
71
+ const mcpName = `local-${serverName.toLowerCase().replace(/\s+/g, "-")}`;
72
+ return `${baseUrl}${route}/deeplink?ide=${ide}&name=${encodeURIComponent(mcpName)}`;
73
+ }
8
74
 
9
75
  const name = "@nuxtjs/mcp-toolkit";
10
- const version = "0.6.1";
76
+ const version = "0.6.2";
11
77
 
12
78
  const log = logger.withTag("@nuxtjs/mcp-toolkit");
13
79
  const { resolve } = createResolver(import.meta.url);
@@ -83,11 +149,17 @@ const module$1 = defineNuxtModule({
83
149
  if (!mcpSummary) return;
84
150
  const ide = detectIDE();
85
151
  if (ide) {
86
- const ideName = ide === "cursor" ? "Cursor" : "VS Code";
87
- const mcpName = `local-${(options.name || "mcp-server").toLowerCase().replace(/\s+/g, "-")}`;
88
152
  const baseUrl = listener.url.replace(/\/$/, "");
89
- const deeplinkUrl = `${baseUrl}${options.route}/deeplink?ide=${ide}&name=${encodeURIComponent(mcpName)}`;
90
- log.success(`\`${options.route}\` enabled with ${mcpSummary} \xB7 ${terminalLink(`Install local MCP in ${ideName}`, deeplinkUrl)}`);
153
+ const mcpUrl = `${baseUrl}${options.route}`;
154
+ const installedConfig = findInstalledMCPConfig(ide, nuxt.options.rootDir, mcpUrl);
155
+ if (installedConfig) {
156
+ log.success(`\`${options.route}\` enabled with ${mcpSummary} \xB7 MCP server already installed in \`${installedConfig.displayPath}\``);
157
+ return;
158
+ }
159
+ const ideName = IDE_CONFIGS[ide].name;
160
+ const deeplinkUrl = generateDeeplinkUrl(baseUrl, options.route, ide, options.name || "mcp-server");
161
+ log.info(`${ideName} detected. ${terminalLink("Install Nuxt MCP server", deeplinkUrl)}`);
162
+ log.success(`\`${options.route}\` enabled with ${mcpSummary}`);
91
163
  } else {
92
164
  log.success(`\`${options.route}\` enabled with ${mcpSummary}`);
93
165
  }
@@ -102,10 +174,12 @@ const module$1 = defineNuxtModule({
102
174
  nuxt.options.nitro.typescript.tsConfig.include ??= [];
103
175
  nuxt.options.nitro.typescript.tsConfig.include.push(resolver.resolve("runtime/server/types.server.d.ts"));
104
176
  let isCloudflare = false;
105
- nuxt.hook("nitro:config", (nitroConfig) => {
106
- const preset = nitroConfig.preset || process.env.NITRO_PRESET || "";
107
- isCloudflare = preset.includes("cloudflare");
108
- });
177
+ if (!nuxt.options.dev) {
178
+ nuxt.hook("nitro:config", (nitroConfig) => {
179
+ const preset = nitroConfig.preset || process.env.NITRO_PRESET || "";
180
+ isCloudflare = preset.includes("cloudflare");
181
+ });
182
+ }
109
183
  addServerTemplate({
110
184
  filename: "#nuxt-mcp/transport.mjs",
111
185
  getContents: () => {
@@ -139,28 +213,5 @@ const module$1 = defineNuxtModule({
139
213
  addDevToolsCustomTabs(nuxt, options);
140
214
  }
141
215
  });
142
- function terminalLink(text, url) {
143
- return `\x1B]8;;${url}\x07${text}\x1B]8;;\x07`;
144
- }
145
- function detectIDE() {
146
- const env = process.env;
147
- if (env.__CFBundleIdentifier === "com.todesktop.230313mzl4w4u92") return "cursor";
148
- if (env.__CFBundleIdentifier === "com.microsoft.VSCode") return "vscode";
149
- if (env.CURSOR_TRACE_ID) return "cursor";
150
- const ipc = env.VSCODE_IPC_HOOK || "";
151
- if (ipc.includes("/Cursor/")) return "cursor";
152
- if (ipc.includes("/Code/")) return "vscode";
153
- try {
154
- let pid = process.ppid;
155
- for (let i = 0; i < 10 && pid > 1; i++) {
156
- const name2 = execSync(`ps -o comm= -p ${pid}`, { stdio: ["pipe", "pipe", "ignore"] }).toString().toLowerCase();
157
- if (name2.includes("cursor")) return "cursor";
158
- if (name2.includes("code helper") || name2.includes("code.app")) return "vscode";
159
- pid = Number.parseInt(execSync(`ps -o ppid= -p ${pid}`, { stdio: ["pipe", "pipe", "ignore"] }).toString().trim());
160
- }
161
- } catch {
162
- }
163
- return null;
164
- }
165
216
 
166
217
  export { module$1 as default, resolve };
@@ -1,4 +1,3 @@
1
- import { createMcpHandler } from "agents/mcp";
2
1
  import { toWebRequest } from "h3";
3
2
  import { createMcpTransportHandler } from "./types.js";
4
3
  const fallbackCtx = {
@@ -7,8 +6,12 @@ const fallbackCtx = {
7
6
  passThroughOnException: () => {
8
7
  }
9
8
  };
10
- export default createMcpTransportHandler((server, event) => {
11
- const handler = createMcpHandler(server);
9
+ export default createMcpTransportHandler(async (server, event) => {
10
+ const { createMcpHandler } = await import("agents/mcp");
11
+ const handler = createMcpHandler(server, {
12
+ route: ""
13
+ // allow any route
14
+ });
12
15
  const request = toWebRequest(event);
13
16
  const cf = event.context.cloudflare;
14
17
  return handler(request, cf?.env ?? {}, cf?.ctx ?? fallbackCtx);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nuxtjs/mcp-toolkit",
3
- "version": "0.6.1",
3
+ "version": "0.6.2",
4
4
  "description": "Create MCP servers directly in your Nuxt application. Define tools, resources, and prompts with a simple and intuitive API.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -33,7 +33,7 @@
33
33
  ],
34
34
  "dependencies": {
35
35
  "@clack/prompts": "^0.11.0",
36
- "@modelcontextprotocol/sdk": "^1.25.1",
36
+ "@modelcontextprotocol/sdk": "^1.25.2",
37
37
  "@nuxt/kit": "^4.2.2",
38
38
  "automd": "^0.4.2",
39
39
  "chokidar": "^5.0.0",
@@ -61,14 +61,14 @@
61
61
  "@nuxt/eslint-config": "^1.12.1",
62
62
  "@nuxt/module-builder": "^1.0.2",
63
63
  "@nuxt/schema": "^4.2.2",
64
- "@nuxt/test-utils": "^3.21.0",
64
+ "@nuxt/test-utils": "^3.23.0",
65
65
  "@types/node": "latest",
66
66
  "changelogen": "^0.6.2",
67
67
  "eslint": "^9.39.2",
68
68
  "nuxt": "^4.2.2",
69
69
  "typescript": "~5.9.3",
70
70
  "vitest": "^4.0.16",
71
- "vue-tsc": "^3.2.1"
71
+ "vue-tsc": "^3.2.2"
72
72
  },
73
73
  "publishConfig": {
74
74
  "access": "public"