@nuxtjs/mcp-toolkit 0.6.2 → 0.6.4

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.2",
3
+ "version": "0.6.4",
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,7 +1,6 @@
1
- import { logger, createResolver, defineNuxtModule, addComponent, addServerHandler, addServerTemplate, addServerImports } from '@nuxt/kit';
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.2";
75
+ const version = "0.6.4";
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
- nuxt.options.runtimeConfig.mcp = defu(
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
- const mcpDir = options.dir ?? defaultMcpConfig.dir;
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 { useRuntimeConfig } from "#imports";
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 || runtimeConfig.name || "mcp-server";
37
- const mcpUrl = `${requestUrl.origin}${runtimeConfig.route || "/mcp"}`;
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 { refreshCustomTabs } 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;
@@ -134,12 +135,13 @@ async function launchMcpInspector(nuxt, options) {
134
135
  inspectorProcess = spawn("npx", [
135
136
  "-y",
136
137
  "@modelcontextprotocol/inspector",
137
- "streamable-http",
138
+ "--transport",
139
+ "http",
140
+ "--server-url",
138
141
  mcpServerUrl
139
142
  ], {
140
143
  stdio: ["ignore", "pipe", "pipe"],
141
- env,
142
- shell: true
144
+ env
143
145
  });
144
146
  const childProcess = inspectorProcess;
145
147
  let stdoutBuffer = "";
@@ -300,10 +302,10 @@ function stopMcpInspector() {
300
302
  }
301
303
  }
302
304
  export function addDevToolsCustomTabs(nuxt, options) {
305
+ if (!options.enabled) {
306
+ return;
307
+ }
303
308
  nuxt.hook("devtools:customTabs", (tabs) => {
304
- if (!options.enabled) {
305
- return;
306
- }
307
309
  tabs.push({
308
310
  category: "server",
309
311
  name: "mcp-inspector",
@@ -320,7 +322,9 @@ export function addDevToolsCustomTabs(nuxt, options) {
320
322
  label: promise ? "Starting..." : "Launch Inspector",
321
323
  pending: !!promise,
322
324
  handle() {
323
- promise = promise || launchMcpInspector(nuxt, options).finally(() => {
325
+ promise = promise || launchMcpInspector(nuxt, options).then(() => {
326
+ refreshCustomTabs(nuxt);
327
+ }).finally(() => {
324
328
  promise = null;
325
329
  });
326
330
  return promise;
@@ -1,15 +1,12 @@
1
1
  import { getRouterParam } from "h3";
2
- import { useRuntimeConfig } from "#imports";
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/transport.mjs' {
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.2",
3
+ "version": "0.6.4",
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
- "@clack/prompts": "^0.11.0",
36
- "@modelcontextprotocol/sdk": "^1.25.2",
37
- "@nuxt/kit": "^4.2.2",
38
- "automd": "^0.4.2",
39
- "chokidar": "^5.0.0",
42
+ "@modelcontextprotocol/sdk": "^1.26.0",
43
+ "@nuxt/kit": "^4.3.1",
40
44
  "defu": "^6.1.4",
41
45
  "ms": "^2.1.3",
42
46
  "pathe": "^2.0.3",
43
- "satori": "^0.18.3",
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.3"
53
+ "agents": ">=0.4.0"
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.12.1",
65
+ "@nuxt/eslint-config": "^1.15.1",
62
66
  "@nuxt/module-builder": "^1.0.2",
63
- "@nuxt/schema": "^4.2.2",
67
+ "@nuxt/schema": "^4.3.1",
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.2.2",
72
+ "nuxt": "^4.3.1",
69
73
  "typescript": "~5.9.3",
70
- "vitest": "^4.0.16",
71
- "vue-tsc": "^3.2.2"
74
+ "vitest": "^4.0.18",
75
+ "vue-tsc": "^3.2.4"
72
76
  },
73
77
  "publishConfig": {
74
78
  "access": "public"