@nuxtjs/mcp-toolkit 0.6.1 → 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 +93 -49
- 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/providers/cloudflare.js +6 -3
- package/dist/runtime/server/mcp/utils.js +1 -1
- package/dist/runtime/server/types.server.d.ts +11 -4
- package/package.json +18 -14
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -1,13 +1,78 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { logger, createResolver, defineNuxtModule, addComponent, addServerHandler, addServerTemplate, addServerImports } from '@nuxt/kit';
|
|
3
|
-
import { defu } from 'defu';
|
|
1
|
+
import { logger, createResolver, defineNuxtModule, addComponent, addServerTemplate, addServerHandler, addServerImports } from '@nuxt/kit';
|
|
4
2
|
import { loadAllDefinitions } from '../dist/runtime/server/mcp/loaders/index.js';
|
|
5
|
-
import { defaultMcpConfig } from '../dist/runtime/server/mcp/config.js';
|
|
3
|
+
import { defaultMcpConfig, getMcpConfig } from '../dist/runtime/server/mcp/config.js';
|
|
6
4
|
import { ROUTES } from '../dist/runtime/server/mcp/constants.js';
|
|
7
5
|
import { addDevToolsCustomTabs } from '../dist/runtime/server/mcp/devtools/index.js';
|
|
6
|
+
import { execSync } from 'node:child_process';
|
|
7
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
8
|
+
import { homedir } from 'node:os';
|
|
9
|
+
import { join } from 'node:path';
|
|
10
|
+
|
|
11
|
+
const IDE_CONFIGS = {
|
|
12
|
+
cursor: { name: "Cursor" },
|
|
13
|
+
vscode: { name: "VS Code" }
|
|
14
|
+
};
|
|
15
|
+
function terminalLink(text, url) {
|
|
16
|
+
return `\x1B]8;;${url}\x07${text}\x1B]8;;\x07`;
|
|
17
|
+
}
|
|
18
|
+
function isMCPInstalled(mcpJson, mcpUrl) {
|
|
19
|
+
if (!mcpJson.mcpServers) return false;
|
|
20
|
+
return Object.values(mcpJson.mcpServers).some((server) => server.url === mcpUrl);
|
|
21
|
+
}
|
|
22
|
+
function detectIDE() {
|
|
23
|
+
const env = process.env;
|
|
24
|
+
if (env.__CFBundleIdentifier === "com.todesktop.230313mzl4w4u92") return "cursor";
|
|
25
|
+
if (env.__CFBundleIdentifier === "com.microsoft.VSCode") return "vscode";
|
|
26
|
+
if (env.CURSOR_TRACE_ID) return "cursor";
|
|
27
|
+
const ipc = env.VSCODE_IPC_HOOK || "";
|
|
28
|
+
if (ipc.includes("/Cursor/")) return "cursor";
|
|
29
|
+
if (ipc.includes("/Code/")) return "vscode";
|
|
30
|
+
try {
|
|
31
|
+
let pid = process.ppid;
|
|
32
|
+
for (let i = 0; i < 10 && pid > 1; i++) {
|
|
33
|
+
const name = execSync(`ps -o comm= -p ${pid}`, { stdio: ["pipe", "pipe", "ignore"] }).toString().toLowerCase();
|
|
34
|
+
if (name.includes("cursor")) return "cursor";
|
|
35
|
+
if (name.includes("code helper") || name.includes("code.app")) return "vscode";
|
|
36
|
+
pid = Number.parseInt(execSync(`ps -o ppid= -p ${pid}`, { stdio: ["pipe", "pipe", "ignore"] }).toString().trim());
|
|
37
|
+
}
|
|
38
|
+
} catch {
|
|
39
|
+
}
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
function getMCPConfigPaths(ide, rootDir) {
|
|
43
|
+
return [
|
|
44
|
+
{
|
|
45
|
+
path: join(rootDir, `.${ide}/mcp.json`),
|
|
46
|
+
displayPath: `.${ide}/mcp.json`
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
path: join(homedir(), `.${ide}/mcp.json`),
|
|
50
|
+
displayPath: `~/.${ide}/mcp.json`
|
|
51
|
+
}
|
|
52
|
+
];
|
|
53
|
+
}
|
|
54
|
+
function findInstalledMCPConfig(ide, rootDir, mcpUrl) {
|
|
55
|
+
const configPaths = getMCPConfigPaths(ide, rootDir);
|
|
56
|
+
for (const config of configPaths) {
|
|
57
|
+
if (existsSync(config.path)) {
|
|
58
|
+
try {
|
|
59
|
+
const mcpJson = JSON.parse(readFileSync(config.path, "utf8"));
|
|
60
|
+
if (isMCPInstalled(mcpJson, mcpUrl)) {
|
|
61
|
+
return config;
|
|
62
|
+
}
|
|
63
|
+
} catch {
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return null;
|
|
68
|
+
}
|
|
69
|
+
function generateDeeplinkUrl(baseUrl, route, ide, serverName) {
|
|
70
|
+
const mcpName = `local-${serverName.toLowerCase().replace(/\s+/g, "-")}`;
|
|
71
|
+
return `${baseUrl}${route}/deeplink?ide=${ide}&name=${encodeURIComponent(mcpName)}`;
|
|
72
|
+
}
|
|
8
73
|
|
|
9
74
|
const name = "@nuxtjs/mcp-toolkit";
|
|
10
|
-
const version = "0.6.
|
|
75
|
+
const version = "0.6.3";
|
|
11
76
|
|
|
12
77
|
const log = logger.withTag("@nuxtjs/mcp-toolkit");
|
|
13
78
|
const { resolve } = createResolver(import.meta.url);
|
|
@@ -26,17 +91,7 @@ const module$1 = defineNuxtModule({
|
|
|
26
91
|
return;
|
|
27
92
|
}
|
|
28
93
|
const resolver = createResolver(import.meta.url);
|
|
29
|
-
|
|
30
|
-
nuxt.options.runtimeConfig.mcp,
|
|
31
|
-
{
|
|
32
|
-
enabled: options.enabled,
|
|
33
|
-
route: options.route,
|
|
34
|
-
browserRedirect: options.browserRedirect,
|
|
35
|
-
name: options.name,
|
|
36
|
-
version: options.version,
|
|
37
|
-
dir: options.dir
|
|
38
|
-
}
|
|
39
|
-
);
|
|
94
|
+
const mcpConfig = getMcpConfig(options);
|
|
40
95
|
if (!options.enabled) {
|
|
41
96
|
return;
|
|
42
97
|
}
|
|
@@ -44,7 +99,11 @@ const module$1 = defineNuxtModule({
|
|
|
44
99
|
name: "InstallButton",
|
|
45
100
|
filePath: resolver.resolve("runtime/components/InstallButton.vue")
|
|
46
101
|
});
|
|
47
|
-
|
|
102
|
+
addServerTemplate({
|
|
103
|
+
filename: "#nuxt-mcp-toolkit/config.mjs",
|
|
104
|
+
getContents: () => `export default ${JSON.stringify(mcpConfig)}`
|
|
105
|
+
});
|
|
106
|
+
const mcpDir = mcpConfig.dir;
|
|
48
107
|
const paths = {
|
|
49
108
|
tools: [`${mcpDir}/tools`],
|
|
50
109
|
resources: [`${mcpDir}/resources`],
|
|
@@ -83,11 +142,17 @@ const module$1 = defineNuxtModule({
|
|
|
83
142
|
if (!mcpSummary) return;
|
|
84
143
|
const ide = detectIDE();
|
|
85
144
|
if (ide) {
|
|
86
|
-
const ideName = ide === "cursor" ? "Cursor" : "VS Code";
|
|
87
|
-
const mcpName = `local-${(options.name || "mcp-server").toLowerCase().replace(/\s+/g, "-")}`;
|
|
88
145
|
const baseUrl = listener.url.replace(/\/$/, "");
|
|
89
|
-
const
|
|
90
|
-
|
|
146
|
+
const mcpUrl = `${baseUrl}${options.route}`;
|
|
147
|
+
const installedConfig = findInstalledMCPConfig(ide, nuxt.options.rootDir, mcpUrl);
|
|
148
|
+
if (installedConfig) {
|
|
149
|
+
log.success(`\`${options.route}\` enabled with ${mcpSummary} \xB7 MCP server already installed in \`${installedConfig.displayPath}\``);
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
const ideName = IDE_CONFIGS[ide].name;
|
|
153
|
+
const deeplinkUrl = generateDeeplinkUrl(baseUrl, options.route, ide, options.name || "mcp-server");
|
|
154
|
+
log.info(`${ideName} detected. ${terminalLink("Install Nuxt MCP server", deeplinkUrl)}`);
|
|
155
|
+
log.success(`\`${options.route}\` enabled with ${mcpSummary}`);
|
|
91
156
|
} else {
|
|
92
157
|
log.success(`\`${options.route}\` enabled with ${mcpSummary}`);
|
|
93
158
|
}
|
|
@@ -102,12 +167,14 @@ const module$1 = defineNuxtModule({
|
|
|
102
167
|
nuxt.options.nitro.typescript.tsConfig.include ??= [];
|
|
103
168
|
nuxt.options.nitro.typescript.tsConfig.include.push(resolver.resolve("runtime/server/types.server.d.ts"));
|
|
104
169
|
let isCloudflare = false;
|
|
105
|
-
nuxt.
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
170
|
+
if (!nuxt.options.dev) {
|
|
171
|
+
nuxt.hook("nitro:config", (nitroConfig) => {
|
|
172
|
+
const preset = nitroConfig.preset || process.env.NITRO_PRESET || "";
|
|
173
|
+
isCloudflare = preset.includes("cloudflare");
|
|
174
|
+
});
|
|
175
|
+
}
|
|
109
176
|
addServerTemplate({
|
|
110
|
-
filename: "#nuxt-mcp/transport.mjs",
|
|
177
|
+
filename: "#nuxt-mcp-toolkit/transport.mjs",
|
|
111
178
|
getContents: () => {
|
|
112
179
|
const provider = isCloudflare ? "cloudflare" : "node";
|
|
113
180
|
return `export { default } from '${resolver.resolve(`runtime/server/mcp/providers/${provider}`)}'`;
|
|
@@ -139,28 +206,5 @@ const module$1 = defineNuxtModule({
|
|
|
139
206
|
addDevToolsCustomTabs(nuxt, options);
|
|
140
207
|
}
|
|
141
208
|
});
|
|
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
209
|
|
|
166
210
|
export { module$1 as default, resolve };
|
|
@@ -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,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
|
|
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);
|
|
@@ -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.
|
|
64
|
-
"@nuxt/test-utils": "^3.
|
|
67
|
+
"@nuxt/schema": "^4.3.0",
|
|
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"
|