@nuxtjs/mcp-toolkit 0.5.0 → 0.5.1
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 +1 -1
- package/dist/module.mjs +40 -11
- package/dist/runtime/server/mcp/deeplink.js +1 -1
- package/package.json +1 -1
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { execSync } from 'node:child_process';
|
|
1
2
|
import { logger, createResolver, defineNuxtModule, addComponent, addServerHandler, addServerImports } from '@nuxt/kit';
|
|
2
3
|
import { defu } from 'defu';
|
|
3
4
|
import { loadAllDefinitions } from '../dist/runtime/server/mcp/loaders/index.js';
|
|
@@ -6,7 +7,7 @@ import { ROUTES } from '../dist/runtime/server/mcp/constants.js';
|
|
|
6
7
|
import { addDevToolsCustomTabs } from '../dist/runtime/server/mcp/devtools/index.js';
|
|
7
8
|
|
|
8
9
|
const name = "@nuxtjs/mcp-toolkit";
|
|
9
|
-
const version = "0.5.
|
|
10
|
+
const version = "0.5.1";
|
|
10
11
|
|
|
11
12
|
const log = logger.withTag("@nuxtjs/mcp-toolkit");
|
|
12
13
|
const { resolve } = createResolver(import.meta.url);
|
|
@@ -46,6 +47,7 @@ const module$1 = defineNuxtModule({
|
|
|
46
47
|
prompts: [`${mcpDir}/prompts`],
|
|
47
48
|
handlers: [mcpDir]
|
|
48
49
|
};
|
|
50
|
+
let mcpSummary = null;
|
|
49
51
|
nuxt.hook("modules:done", async () => {
|
|
50
52
|
try {
|
|
51
53
|
await nuxt.callHook("mcp:definitions:paths", paths);
|
|
@@ -64,16 +66,7 @@ const module$1 = defineNuxtModule({
|
|
|
64
66
|
if (result.resources.count > 0) summary.push(`${result.resources.count} resource${result.resources.count > 1 ? "s" : ""}`);
|
|
65
67
|
if (result.prompts.count > 0) summary.push(`${result.prompts.count} prompt${result.prompts.count > 1 ? "s" : ""}`);
|
|
66
68
|
if (result.handlers.count > 0) summary.push(`${result.handlers.count} handler${result.handlers.count > 1 ? "s" : ""}`);
|
|
67
|
-
|
|
68
|
-
if (options.name) {
|
|
69
|
-
boxContent.push(`${options.name}`);
|
|
70
|
-
}
|
|
71
|
-
boxContent.push(`Route: ${options.route}`);
|
|
72
|
-
boxContent.push(`Definitions: ${summary.join(", ")}`);
|
|
73
|
-
log.box({
|
|
74
|
-
title: "MCP Server",
|
|
75
|
-
message: boxContent.join("\n")
|
|
76
|
-
});
|
|
69
|
+
mcpSummary = summary.join(", ");
|
|
77
70
|
}
|
|
78
71
|
} catch (error) {
|
|
79
72
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
@@ -82,6 +75,19 @@ const module$1 = defineNuxtModule({
|
|
|
82
75
|
throw error;
|
|
83
76
|
}
|
|
84
77
|
});
|
|
78
|
+
nuxt.hook("listen", (_, listener) => {
|
|
79
|
+
if (!mcpSummary) return;
|
|
80
|
+
const ide = detectIDE();
|
|
81
|
+
if (ide) {
|
|
82
|
+
const ideName = ide === "cursor" ? "Cursor" : "VS Code";
|
|
83
|
+
const mcpName = `local-${(options.name || "mcp-server").toLowerCase().replace(/\s+/g, "-")}`;
|
|
84
|
+
const baseUrl = listener.url.replace(/\/$/, "");
|
|
85
|
+
const deeplinkUrl = `${baseUrl}${options.route}/deeplink?ide=${ide}&name=${encodeURIComponent(mcpName)}`;
|
|
86
|
+
log.success(`\`${options.route}\` enabled with ${mcpSummary} \xB7 ${terminalLink(`Install local MCP in ${ideName}`, deeplinkUrl)}`);
|
|
87
|
+
} else {
|
|
88
|
+
log.success(`\`${options.route}\` enabled with ${mcpSummary}`);
|
|
89
|
+
}
|
|
90
|
+
});
|
|
85
91
|
nuxt.hook("prepare:types", ({ references }) => {
|
|
86
92
|
references.push({
|
|
87
93
|
path: resolver.resolve("runtime/server/types.server.d.ts")
|
|
@@ -117,5 +123,28 @@ const module$1 = defineNuxtModule({
|
|
|
117
123
|
addDevToolsCustomTabs(nuxt, options);
|
|
118
124
|
}
|
|
119
125
|
});
|
|
126
|
+
function terminalLink(text, url) {
|
|
127
|
+
return `\x1B]8;;${url}\x07${text}\x1B]8;;\x07`;
|
|
128
|
+
}
|
|
129
|
+
function detectIDE() {
|
|
130
|
+
const env = process.env;
|
|
131
|
+
if (env.__CFBundleIdentifier === "com.todesktop.230313mzl4w4u92") return "cursor";
|
|
132
|
+
if (env.__CFBundleIdentifier === "com.microsoft.VSCode") return "vscode";
|
|
133
|
+
if (env.CURSOR_TRACE_ID) return "cursor";
|
|
134
|
+
const ipc = env.VSCODE_IPC_HOOK || "";
|
|
135
|
+
if (ipc.includes("/Cursor/")) return "cursor";
|
|
136
|
+
if (ipc.includes("/Code/")) return "vscode";
|
|
137
|
+
try {
|
|
138
|
+
let pid = process.ppid;
|
|
139
|
+
for (let i = 0; i < 10 && pid > 1; i++) {
|
|
140
|
+
const name2 = execSync(`ps -o comm= -p ${pid}`, { stdio: ["pipe", "pipe", "ignore"] }).toString().toLowerCase();
|
|
141
|
+
if (name2.includes("cursor")) return "cursor";
|
|
142
|
+
if (name2.includes("code helper") || name2.includes("code.app")) return "vscode";
|
|
143
|
+
pid = Number.parseInt(execSync(`ps -o ppid= -p ${pid}`, { stdio: ["pipe", "pipe", "ignore"] }).toString().trim());
|
|
144
|
+
}
|
|
145
|
+
} catch {
|
|
146
|
+
}
|
|
147
|
+
return null;
|
|
148
|
+
}
|
|
120
149
|
|
|
121
150
|
export { module$1 as default, resolve };
|
|
@@ -33,7 +33,7 @@ export default defineEventHandler((event) => {
|
|
|
33
33
|
setHeader(event, "Location", "/");
|
|
34
34
|
return new Response(null, { status: 302 });
|
|
35
35
|
}
|
|
36
|
-
const serverName = runtimeConfig.name || "mcp-server";
|
|
36
|
+
const serverName = query.name || runtimeConfig.name || "mcp-server";
|
|
37
37
|
const mcpUrl = `${requestUrl.origin}${runtimeConfig.route || "/mcp"}`;
|
|
38
38
|
const deeplink = ideConfig.generateDeeplink(serverName, mcpUrl);
|
|
39
39
|
const htmlDeeplink = escapeHtmlAttr(deeplink);
|
package/package.json
CHANGED