@nuxtjs/mcp-toolkit 0.5.0 → 0.5.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 +1 -1
- package/dist/module.mjs +44 -11
- package/dist/runtime/server/mcp/deeplink.js +1 -1
- package/dist/runtime/server/mcp/definitions/tools.d.ts +1 -1
- package/dist/runtime/server/mcp/definitions/tools.js +9 -26
- package/dist/runtime/server/mcp/loaders/utils.js +1 -1
- package/package.json +7 -7
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.2";
|
|
10
11
|
|
|
11
12
|
const log = logger.withTag("@nuxtjs/mcp-toolkit");
|
|
12
13
|
const { resolve } = createResolver(import.meta.url);
|
|
@@ -20,6 +21,10 @@ const module$1 = defineNuxtModule({
|
|
|
20
21
|
},
|
|
21
22
|
defaults: defaultMcpConfig,
|
|
22
23
|
async setup(options, nuxt) {
|
|
24
|
+
if (nuxt.options.nitro.static || nuxt.options._generate) {
|
|
25
|
+
log.warn("@nuxtjs/mcp-toolkit is not compatible with `nuxt generate` as it needs a server to run.");
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
23
28
|
const resolver = createResolver(import.meta.url);
|
|
24
29
|
nuxt.options.runtimeConfig.mcp = defu(
|
|
25
30
|
nuxt.options.runtimeConfig.mcp,
|
|
@@ -46,6 +51,7 @@ const module$1 = defineNuxtModule({
|
|
|
46
51
|
prompts: [`${mcpDir}/prompts`],
|
|
47
52
|
handlers: [mcpDir]
|
|
48
53
|
};
|
|
54
|
+
let mcpSummary = null;
|
|
49
55
|
nuxt.hook("modules:done", async () => {
|
|
50
56
|
try {
|
|
51
57
|
await nuxt.callHook("mcp:definitions:paths", paths);
|
|
@@ -64,16 +70,7 @@ const module$1 = defineNuxtModule({
|
|
|
64
70
|
if (result.resources.count > 0) summary.push(`${result.resources.count} resource${result.resources.count > 1 ? "s" : ""}`);
|
|
65
71
|
if (result.prompts.count > 0) summary.push(`${result.prompts.count} prompt${result.prompts.count > 1 ? "s" : ""}`);
|
|
66
72
|
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
|
-
});
|
|
73
|
+
mcpSummary = summary.join(", ");
|
|
77
74
|
}
|
|
78
75
|
} catch (error) {
|
|
79
76
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
@@ -82,6 +79,19 @@ const module$1 = defineNuxtModule({
|
|
|
82
79
|
throw error;
|
|
83
80
|
}
|
|
84
81
|
});
|
|
82
|
+
nuxt.hook("listen", (_, listener) => {
|
|
83
|
+
if (!mcpSummary) return;
|
|
84
|
+
const ide = detectIDE();
|
|
85
|
+
if (ide) {
|
|
86
|
+
const ideName = ide === "cursor" ? "Cursor" : "VS Code";
|
|
87
|
+
const mcpName = `local-${(options.name || "mcp-server").toLowerCase().replace(/\s+/g, "-")}`;
|
|
88
|
+
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)}`);
|
|
91
|
+
} else {
|
|
92
|
+
log.success(`\`${options.route}\` enabled with ${mcpSummary}`);
|
|
93
|
+
}
|
|
94
|
+
});
|
|
85
95
|
nuxt.hook("prepare:types", ({ references }) => {
|
|
86
96
|
references.push({
|
|
87
97
|
path: resolver.resolve("runtime/server/types.server.d.ts")
|
|
@@ -117,5 +127,28 @@ const module$1 = defineNuxtModule({
|
|
|
117
127
|
addDevToolsCustomTabs(nuxt, options);
|
|
118
128
|
}
|
|
119
129
|
});
|
|
130
|
+
function terminalLink(text, url) {
|
|
131
|
+
return `\x1B]8;;${url}\x07${text}\x1B]8;;\x07`;
|
|
132
|
+
}
|
|
133
|
+
function detectIDE() {
|
|
134
|
+
const env = process.env;
|
|
135
|
+
if (env.__CFBundleIdentifier === "com.todesktop.230313mzl4w4u92") return "cursor";
|
|
136
|
+
if (env.__CFBundleIdentifier === "com.microsoft.VSCode") return "vscode";
|
|
137
|
+
if (env.CURSOR_TRACE_ID) return "cursor";
|
|
138
|
+
const ipc = env.VSCODE_IPC_HOOK || "";
|
|
139
|
+
if (ipc.includes("/Cursor/")) return "cursor";
|
|
140
|
+
if (ipc.includes("/Code/")) return "vscode";
|
|
141
|
+
try {
|
|
142
|
+
let pid = process.ppid;
|
|
143
|
+
for (let i = 0; i < 10 && pid > 1; i++) {
|
|
144
|
+
const name2 = execSync(`ps -o comm= -p ${pid}`, { stdio: ["pipe", "pipe", "ignore"] }).toString().toLowerCase();
|
|
145
|
+
if (name2.includes("cursor")) return "cursor";
|
|
146
|
+
if (name2.includes("code helper") || name2.includes("code.app")) return "vscode";
|
|
147
|
+
pid = Number.parseInt(execSync(`ps -o ppid= -p ${pid}`, { stdio: ["pipe", "pipe", "ignore"] }).toString().trim());
|
|
148
|
+
}
|
|
149
|
+
} catch {
|
|
150
|
+
}
|
|
151
|
+
return null;
|
|
152
|
+
}
|
|
120
153
|
|
|
121
154
|
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);
|
|
@@ -37,7 +37,7 @@ export interface McpToolDefinition<InputSchema extends ZodRawShape | undefined =
|
|
|
37
37
|
* Register a tool from a McpToolDefinition
|
|
38
38
|
* @internal
|
|
39
39
|
*/
|
|
40
|
-
export declare function registerToolFromDefinition
|
|
40
|
+
export declare function registerToolFromDefinition(server: McpServer, tool: McpToolDefinition): import("@modelcontextprotocol/sdk/server/mcp.js").RegisteredTool;
|
|
41
41
|
/**
|
|
42
42
|
* Define an MCP tool that will be automatically registered.
|
|
43
43
|
*
|
|
@@ -19,32 +19,15 @@ export function registerToolFromDefinition(server, tool) {
|
|
|
19
19
|
cacheOptions
|
|
20
20
|
);
|
|
21
21
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
_meta: tool._meta
|
|
32
|
-
},
|
|
33
|
-
handler
|
|
34
|
-
);
|
|
35
|
-
} else {
|
|
36
|
-
return server.registerTool(
|
|
37
|
-
name,
|
|
38
|
-
{
|
|
39
|
-
title,
|
|
40
|
-
description: tool.description,
|
|
41
|
-
outputSchema: tool.outputSchema,
|
|
42
|
-
annotations: tool.annotations,
|
|
43
|
-
_meta: tool._meta
|
|
44
|
-
},
|
|
45
|
-
handler
|
|
46
|
-
);
|
|
47
|
-
}
|
|
22
|
+
const options = {
|
|
23
|
+
title,
|
|
24
|
+
description: tool.description,
|
|
25
|
+
inputSchema: tool.inputSchema,
|
|
26
|
+
outputSchema: tool.outputSchema,
|
|
27
|
+
annotations: tool.annotations,
|
|
28
|
+
_meta: tool._meta
|
|
29
|
+
};
|
|
30
|
+
return server.registerTool(name, options, handler);
|
|
48
31
|
}
|
|
49
32
|
export function defineMcpTool(definition) {
|
|
50
33
|
return definition;
|
|
@@ -127,7 +127,7 @@ export async function loadDefinitionFiles(paths, options = {}) {
|
|
|
127
127
|
const layerFiles = await glob(layerPatterns, {
|
|
128
128
|
absolute: true,
|
|
129
129
|
onlyFiles: true,
|
|
130
|
-
ignore: options.excludePatterns
|
|
130
|
+
ignore: [...options.excludePatterns || [], "**/*.d.ts"]
|
|
131
131
|
});
|
|
132
132
|
const filteredFiles = options.filter ? layerFiles.filter(options.filter) : layerFiles;
|
|
133
133
|
for (const filePath of filteredFiles) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nuxtjs/mcp-toolkit",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.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.
|
|
36
|
+
"@modelcontextprotocol/sdk": "^1.24.3",
|
|
37
37
|
"@nuxt/kit": "^4.2.1",
|
|
38
38
|
"automd": "^0.4.2",
|
|
39
39
|
"chokidar": "^4.0.3",
|
|
@@ -53,18 +53,18 @@
|
|
|
53
53
|
}
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
|
-
"@nuxt/devtools": "^3.1.
|
|
57
|
-
"@nuxt/eslint-config": "^1.
|
|
56
|
+
"@nuxt/devtools": "^3.1.1",
|
|
57
|
+
"@nuxt/eslint-config": "^1.11.0",
|
|
58
58
|
"@nuxt/module-builder": "^1.0.2",
|
|
59
59
|
"@nuxt/schema": "^4.2.1",
|
|
60
|
-
"@nuxt/test-utils": "^3.
|
|
60
|
+
"@nuxt/test-utils": "^3.21.0",
|
|
61
61
|
"@types/node": "latest",
|
|
62
62
|
"changelogen": "^0.6.2",
|
|
63
63
|
"eslint": "^9.39.1",
|
|
64
64
|
"nuxt": "^4.2.1",
|
|
65
65
|
"typescript": "~5.9.3",
|
|
66
|
-
"vitest": "^4.0.
|
|
67
|
-
"vue-tsc": "^3.1.
|
|
66
|
+
"vitest": "^4.0.15",
|
|
67
|
+
"vue-tsc": "^3.1.7"
|
|
68
68
|
},
|
|
69
69
|
"publishConfig": {
|
|
70
70
|
"access": "public"
|