@nuxtjs/mcp-toolkit 0.6.2 → 0.6.3
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 +10 -17
- package/dist/runtime/server/mcp/deeplink.js +3 -4
- package/dist/runtime/server/mcp/devtools/index.js +35 -36
- package/dist/runtime/server/mcp/handler.js +6 -9
- package/dist/runtime/server/mcp/loaders/index.js +8 -8
- package/dist/runtime/server/mcp/utils.js +1 -1
- package/dist/runtime/server/types.server.d.ts +11 -4
- package/package.json +17 -13
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { logger, createResolver, defineNuxtModule, addComponent,
|
|
2
|
-
import { defu } from 'defu';
|
|
1
|
+
import { logger, createResolver, defineNuxtModule, addComponent, addServerTemplate, addServerHandler, addServerImports } from '@nuxt/kit';
|
|
3
2
|
import { loadAllDefinitions } from '../dist/runtime/server/mcp/loaders/index.js';
|
|
4
|
-
import { defaultMcpConfig } from '../dist/runtime/server/mcp/config.js';
|
|
3
|
+
import { defaultMcpConfig, getMcpConfig } from '../dist/runtime/server/mcp/config.js';
|
|
5
4
|
import { ROUTES } from '../dist/runtime/server/mcp/constants.js';
|
|
6
5
|
import { addDevToolsCustomTabs } from '../dist/runtime/server/mcp/devtools/index.js';
|
|
7
6
|
import { execSync } from 'node:child_process';
|
|
@@ -73,7 +72,7 @@ function generateDeeplinkUrl(baseUrl, route, ide, serverName) {
|
|
|
73
72
|
}
|
|
74
73
|
|
|
75
74
|
const name = "@nuxtjs/mcp-toolkit";
|
|
76
|
-
const version = "0.6.
|
|
75
|
+
const version = "0.6.3";
|
|
77
76
|
|
|
78
77
|
const log = logger.withTag("@nuxtjs/mcp-toolkit");
|
|
79
78
|
const { resolve } = createResolver(import.meta.url);
|
|
@@ -92,17 +91,7 @@ const module$1 = defineNuxtModule({
|
|
|
92
91
|
return;
|
|
93
92
|
}
|
|
94
93
|
const resolver = createResolver(import.meta.url);
|
|
95
|
-
|
|
96
|
-
nuxt.options.runtimeConfig.mcp,
|
|
97
|
-
{
|
|
98
|
-
enabled: options.enabled,
|
|
99
|
-
route: options.route,
|
|
100
|
-
browserRedirect: options.browserRedirect,
|
|
101
|
-
name: options.name,
|
|
102
|
-
version: options.version,
|
|
103
|
-
dir: options.dir
|
|
104
|
-
}
|
|
105
|
-
);
|
|
94
|
+
const mcpConfig = getMcpConfig(options);
|
|
106
95
|
if (!options.enabled) {
|
|
107
96
|
return;
|
|
108
97
|
}
|
|
@@ -110,7 +99,11 @@ const module$1 = defineNuxtModule({
|
|
|
110
99
|
name: "InstallButton",
|
|
111
100
|
filePath: resolver.resolve("runtime/components/InstallButton.vue")
|
|
112
101
|
});
|
|
113
|
-
|
|
102
|
+
addServerTemplate({
|
|
103
|
+
filename: "#nuxt-mcp-toolkit/config.mjs",
|
|
104
|
+
getContents: () => `export default ${JSON.stringify(mcpConfig)}`
|
|
105
|
+
});
|
|
106
|
+
const mcpDir = mcpConfig.dir;
|
|
114
107
|
const paths = {
|
|
115
108
|
tools: [`${mcpDir}/tools`],
|
|
116
109
|
resources: [`${mcpDir}/resources`],
|
|
@@ -181,7 +174,7 @@ const module$1 = defineNuxtModule({
|
|
|
181
174
|
});
|
|
182
175
|
}
|
|
183
176
|
addServerTemplate({
|
|
184
|
-
filename: "#nuxt-mcp/transport.mjs",
|
|
177
|
+
filename: "#nuxt-mcp-toolkit/transport.mjs",
|
|
185
178
|
getContents: () => {
|
|
186
179
|
const provider = isCloudflare ? "cloudflare" : "node";
|
|
187
180
|
return `export { default } from '${resolver.resolve(`runtime/server/mcp/providers/${provider}`)}'`;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { defineEventHandler, getRequestURL, getQuery, setHeader } from "h3";
|
|
2
|
-
import
|
|
2
|
+
import mcpConfig from "#nuxt-mcp-toolkit/config.mjs";
|
|
3
3
|
const IDE_CONFIGS = {
|
|
4
4
|
cursor: {
|
|
5
5
|
name: "Cursor",
|
|
@@ -24,7 +24,6 @@ function escapeJs(str) {
|
|
|
24
24
|
return str.replace(/\\/g, "\\\\").replace(/"/g, '\\"').replace(/'/g, "\\'").replace(/</g, "\\u003c").replace(/>/g, "\\u003e");
|
|
25
25
|
}
|
|
26
26
|
export default defineEventHandler((event) => {
|
|
27
|
-
const runtimeConfig = useRuntimeConfig(event).mcp;
|
|
28
27
|
const requestUrl = getRequestURL(event);
|
|
29
28
|
const query = getQuery(event);
|
|
30
29
|
const ide = query.ide || "cursor";
|
|
@@ -33,8 +32,8 @@ export default defineEventHandler((event) => {
|
|
|
33
32
|
setHeader(event, "Location", "/");
|
|
34
33
|
return new Response(null, { status: 302 });
|
|
35
34
|
}
|
|
36
|
-
const serverName = query.name ||
|
|
37
|
-
const mcpUrl = `${requestUrl.origin}${
|
|
35
|
+
const serverName = query.name || mcpConfig.name || "mcp-server";
|
|
36
|
+
const mcpUrl = `${requestUrl.origin}${mcpConfig.route || "/mcp"}`;
|
|
38
37
|
const deeplink = ideConfig.generateDeeplink(serverName, mcpUrl);
|
|
39
38
|
const htmlDeeplink = escapeHtmlAttr(deeplink);
|
|
40
39
|
const jsDeeplink = escapeJs(deeplink);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { logger } from "@nuxt/kit";
|
|
2
|
+
import { addCustomTab } from "@nuxt/devtools-kit";
|
|
2
3
|
import { spawn } from "node:child_process";
|
|
3
4
|
const log = logger.withTag("@nuxtjs/mcp-toolkit");
|
|
4
5
|
const INSPECTOR_TIMEOUT = 15e3;
|
|
@@ -300,43 +301,41 @@ function stopMcpInspector() {
|
|
|
300
301
|
}
|
|
301
302
|
}
|
|
302
303
|
export function addDevToolsCustomTabs(nuxt, options) {
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
promise = promise || launchMcpInspector(nuxt, options).finally(() => {
|
|
324
|
-
promise = null;
|
|
325
|
-
});
|
|
326
|
-
return promise;
|
|
327
|
-
}
|
|
328
|
-
},
|
|
329
|
-
...inspectorProcess ? [{
|
|
330
|
-
label: "Stop Inspector",
|
|
331
|
-
handle() {
|
|
332
|
-
stopMcpInspector();
|
|
304
|
+
if (!options.enabled) {
|
|
305
|
+
return;
|
|
306
|
+
}
|
|
307
|
+
addCustomTab(() => ({
|
|
308
|
+
category: "server",
|
|
309
|
+
name: "mcp-inspector",
|
|
310
|
+
title: "MCP Inspector",
|
|
311
|
+
icon: "i-lucide-circuit-board",
|
|
312
|
+
view: isReady && inspectorUrl ? {
|
|
313
|
+
type: "iframe",
|
|
314
|
+
src: inspectorUrl
|
|
315
|
+
} : {
|
|
316
|
+
type: "launch",
|
|
317
|
+
description: "Launch MCP Inspector to test/debug your MCP server",
|
|
318
|
+
actions: [
|
|
319
|
+
{
|
|
320
|
+
label: promise ? "Starting..." : "Launch Inspector",
|
|
321
|
+
pending: !!promise,
|
|
322
|
+
handle() {
|
|
323
|
+
promise = promise || launchMcpInspector(nuxt, options).finally(() => {
|
|
333
324
|
promise = null;
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
325
|
+
});
|
|
326
|
+
return promise;
|
|
327
|
+
}
|
|
328
|
+
},
|
|
329
|
+
...inspectorProcess ? [{
|
|
330
|
+
label: "Stop Inspector",
|
|
331
|
+
handle() {
|
|
332
|
+
stopMcpInspector();
|
|
333
|
+
promise = null;
|
|
334
|
+
}
|
|
335
|
+
}] : []
|
|
336
|
+
]
|
|
337
|
+
}
|
|
338
|
+
}), nuxt);
|
|
340
339
|
nuxt.hook("close", () => {
|
|
341
340
|
stopMcpInspector();
|
|
342
341
|
});
|
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
import { getRouterParam } from "h3";
|
|
2
|
-
import
|
|
3
|
-
import { tools } from "#nuxt-mcp/tools.mjs";
|
|
4
|
-
import { resources } from "#nuxt-mcp/resources.mjs";
|
|
5
|
-
import { prompts } from "#nuxt-mcp/prompts.mjs";
|
|
6
|
-
import { handlers } from "#nuxt-mcp/handlers.mjs";
|
|
7
|
-
import { defaultHandler } from "#nuxt-mcp/default-handler.mjs";
|
|
2
|
+
import config from "#nuxt-mcp-toolkit/config.mjs";
|
|
3
|
+
import { tools } from "#nuxt-mcp-toolkit/tools.mjs";
|
|
4
|
+
import { resources } from "#nuxt-mcp-toolkit/resources.mjs";
|
|
5
|
+
import { prompts } from "#nuxt-mcp-toolkit/prompts.mjs";
|
|
6
|
+
import { handlers } from "#nuxt-mcp-toolkit/handlers.mjs";
|
|
7
|
+
import { defaultHandler } from "#nuxt-mcp-toolkit/default-handler.mjs";
|
|
8
8
|
import { createMcpHandler } from "./utils.js";
|
|
9
|
-
import { getMcpConfig } from "./config.js";
|
|
10
9
|
export default createMcpHandler((event) => {
|
|
11
|
-
const runtimeConfig = useRuntimeConfig(event).mcp;
|
|
12
|
-
const config = getMcpConfig(runtimeConfig);
|
|
13
10
|
const handlerName = getRouterParam(event, "handler");
|
|
14
11
|
if (handlerName) {
|
|
15
12
|
const handlerDef = handlers.find(
|
|
@@ -37,7 +37,7 @@ async function loadHandlers(paths = []) {
|
|
|
37
37
|
try {
|
|
38
38
|
if (paths.length === 0) {
|
|
39
39
|
addServerTemplate({
|
|
40
|
-
filename: "#nuxt-mcp/handlers.mjs",
|
|
40
|
+
filename: "#nuxt-mcp-toolkit/handlers.mjs",
|
|
41
41
|
getContents: () => `export const handlers = []
|
|
42
42
|
`
|
|
43
43
|
});
|
|
@@ -54,7 +54,7 @@ async function loadHandlers(paths = []) {
|
|
|
54
54
|
}
|
|
55
55
|
});
|
|
56
56
|
addServerTemplate({
|
|
57
|
-
filename: "#nuxt-mcp/handlers.mjs",
|
|
57
|
+
filename: "#nuxt-mcp-toolkit/handlers.mjs",
|
|
58
58
|
getContents: () => {
|
|
59
59
|
if (result.count === 0) {
|
|
60
60
|
return `export const handlers = []
|
|
@@ -77,20 +77,20 @@ async function loadHandlers(paths = []) {
|
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
79
|
export async function loadTools(paths) {
|
|
80
|
-
return loadMcpDefinitions("tools", "#nuxt-mcp/tools.mjs", paths);
|
|
80
|
+
return loadMcpDefinitions("tools", "#nuxt-mcp-toolkit/tools.mjs", paths);
|
|
81
81
|
}
|
|
82
82
|
export async function loadResources(paths) {
|
|
83
|
-
return loadMcpDefinitions("resources", "#nuxt-mcp/resources.mjs", paths);
|
|
83
|
+
return loadMcpDefinitions("resources", "#nuxt-mcp-toolkit/resources.mjs", paths);
|
|
84
84
|
}
|
|
85
85
|
export async function loadPrompts(paths) {
|
|
86
|
-
return loadMcpDefinitions("prompts", "#nuxt-mcp/prompts.mjs", paths);
|
|
86
|
+
return loadMcpDefinitions("prompts", "#nuxt-mcp-toolkit/prompts.mjs", paths);
|
|
87
87
|
}
|
|
88
88
|
export { loadHandlers };
|
|
89
89
|
async function loadDefaultHandler(paths = []) {
|
|
90
90
|
try {
|
|
91
91
|
const indexFile = await findIndexFile(paths);
|
|
92
92
|
addServerTemplate({
|
|
93
|
-
filename: "#nuxt-mcp/default-handler.mjs",
|
|
93
|
+
filename: "#nuxt-mcp-toolkit/default-handler.mjs",
|
|
94
94
|
getContents: () => {
|
|
95
95
|
if (!indexFile) {
|
|
96
96
|
return `export const defaultHandler = null
|
|
@@ -106,7 +106,7 @@ export const defaultHandler = handler
|
|
|
106
106
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
107
107
|
log.error(`Failed to load default handler: ${errorMessage}`);
|
|
108
108
|
addServerTemplate({
|
|
109
|
-
filename: "#nuxt-mcp/default-handler.mjs",
|
|
109
|
+
filename: "#nuxt-mcp-toolkit/default-handler.mjs",
|
|
110
110
|
getContents: () => `export const defaultHandler = null
|
|
111
111
|
`
|
|
112
112
|
});
|
|
@@ -142,7 +142,7 @@ export async function loadAllDefinitions(paths) {
|
|
|
142
142
|
}
|
|
143
143
|
export async function getHandlerRoutes() {
|
|
144
144
|
try {
|
|
145
|
-
const handlersModule = await import("#nuxt-mcp/handlers.mjs");
|
|
145
|
+
const handlersModule = await import("#nuxt-mcp-toolkit/handlers.mjs");
|
|
146
146
|
const handlers = handlersModule.handlers;
|
|
147
147
|
return handlers.map((h) => ({ name: h.name, route: h.route }));
|
|
148
148
|
} catch {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
2
|
import { sendRedirect, getHeader, defineEventHandler } from "h3";
|
|
3
3
|
import { registerToolFromDefinition, registerResourceFromDefinition, registerPromptFromDefinition } from "./definitions/index.js";
|
|
4
|
-
import handleMcpRequest from "#nuxt-mcp/transport.mjs";
|
|
4
|
+
import handleMcpRequest from "#nuxt-mcp-toolkit/transport.mjs";
|
|
5
5
|
export { createMcpTransportHandler } from "./providers/types.js";
|
|
6
6
|
function resolveConfig(config, event) {
|
|
7
7
|
return typeof config === "function" ? config(event) : config;
|
|
@@ -1,19 +1,26 @@
|
|
|
1
1
|
import type { McpToolDefinition, McpResourceDefinition, McpPromptDefinition } from './mcp/definitions'
|
|
2
2
|
import './types/hooks'
|
|
3
3
|
|
|
4
|
-
declare module '#nuxt-mcp/tools.mjs' {
|
|
4
|
+
declare module '#nuxt-mcp-toolkit/tools.mjs' {
|
|
5
5
|
export const tools: McpToolDefinition[]
|
|
6
6
|
}
|
|
7
7
|
|
|
8
|
-
declare module '#nuxt-mcp/resources.mjs' {
|
|
8
|
+
declare module '#nuxt-mcp-toolkit/resources.mjs' {
|
|
9
9
|
export const resources: McpResourceDefinition[]
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
declare module '#nuxt-mcp/prompts.mjs' {
|
|
12
|
+
declare module '#nuxt-mcp-toolkit/prompts.mjs' {
|
|
13
13
|
export const prompts: McpPromptDefinition[]
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
declare module '#nuxt-mcp/
|
|
16
|
+
declare module '#nuxt-mcp-toolkit/config.mjs' {
|
|
17
|
+
import type { McpConfig } from './mcp/config'
|
|
18
|
+
|
|
19
|
+
const config: McpConfig
|
|
20
|
+
export default config
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
declare module '#nuxt-mcp-toolkit/transport.mjs' {
|
|
17
24
|
import type { McpTransportHandler } from './mcp/providers/types'
|
|
18
25
|
|
|
19
26
|
const handleMcpRequest: McpTransportHandler
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nuxtjs/mcp-toolkit",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.3",
|
|
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",
|
|
@@ -17,6 +17,10 @@
|
|
|
17
17
|
".": {
|
|
18
18
|
"types": "./dist/types.d.mts",
|
|
19
19
|
"import": "./dist/module.mjs"
|
|
20
|
+
},
|
|
21
|
+
"./server": {
|
|
22
|
+
"types": "./dist/runtime/server/mcp/definitions/index.d.ts",
|
|
23
|
+
"import": "./dist/runtime/server/mcp/definitions/index.js"
|
|
20
24
|
}
|
|
21
25
|
},
|
|
22
26
|
"main": "./dist/module.mjs",
|
|
@@ -24,6 +28,9 @@
|
|
|
24
28
|
"*": {
|
|
25
29
|
".": [
|
|
26
30
|
"./dist/types.d.mts"
|
|
31
|
+
],
|
|
32
|
+
"server": [
|
|
33
|
+
"./dist/runtime/server/mcp/definitions/index.d.ts"
|
|
27
34
|
]
|
|
28
35
|
}
|
|
29
36
|
},
|
|
@@ -32,21 +39,18 @@
|
|
|
32
39
|
"dist"
|
|
33
40
|
],
|
|
34
41
|
"dependencies": {
|
|
35
|
-
"@
|
|
36
|
-
"@
|
|
37
|
-
"@nuxt/kit": "^4.2.2",
|
|
38
|
-
"automd": "^0.4.2",
|
|
39
|
-
"chokidar": "^5.0.0",
|
|
42
|
+
"@modelcontextprotocol/sdk": "^1.25.3",
|
|
43
|
+
"@nuxt/kit": "^4.3.0",
|
|
40
44
|
"defu": "^6.1.4",
|
|
41
45
|
"ms": "^2.1.3",
|
|
42
46
|
"pathe": "^2.0.3",
|
|
43
|
-
"satori": "^0.
|
|
47
|
+
"satori": "^0.19.1",
|
|
44
48
|
"scule": "^1.3.0",
|
|
45
49
|
"tinyglobby": "^0.2.15"
|
|
46
50
|
},
|
|
47
51
|
"peerDependencies": {
|
|
48
52
|
"zod": "^4.1.13",
|
|
49
|
-
"agents": ">=0.3.
|
|
53
|
+
"agents": ">=0.3.6"
|
|
50
54
|
},
|
|
51
55
|
"peerDependenciesMeta": {
|
|
52
56
|
"zod": {
|
|
@@ -58,17 +62,17 @@
|
|
|
58
62
|
},
|
|
59
63
|
"devDependencies": {
|
|
60
64
|
"@nuxt/devtools": "^3.1.1",
|
|
61
|
-
"@nuxt/eslint-config": "^1.
|
|
65
|
+
"@nuxt/eslint-config": "^1.13.0",
|
|
62
66
|
"@nuxt/module-builder": "^1.0.2",
|
|
63
|
-
"@nuxt/schema": "^4.
|
|
67
|
+
"@nuxt/schema": "^4.3.0",
|
|
64
68
|
"@nuxt/test-utils": "^3.23.0",
|
|
65
69
|
"@types/node": "latest",
|
|
66
70
|
"changelogen": "^0.6.2",
|
|
67
71
|
"eslint": "^9.39.2",
|
|
68
|
-
"nuxt": "^4.
|
|
72
|
+
"nuxt": "^4.3.0",
|
|
69
73
|
"typescript": "~5.9.3",
|
|
70
|
-
"vitest": "^4.0.
|
|
71
|
-
"vue-tsc": "^3.2.
|
|
74
|
+
"vitest": "^4.0.18",
|
|
75
|
+
"vue-tsc": "^3.2.4"
|
|
72
76
|
},
|
|
73
77
|
"publishConfig": {
|
|
74
78
|
"access": "public"
|