@nuxtjs/mcp-toolkit 0.1.0 → 0.2.0
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/README.md +4 -6
- package/dist/module.json +1 -1
- package/dist/module.mjs +1 -1
- package/dist/runtime/server/mcp/definitions/prompts.d.ts +3 -2
- package/dist/runtime/server/mcp/definitions/resources.d.ts +4 -4
- package/dist/runtime/server/mcp/definitions/resources.js +2 -1
- package/dist/runtime/server/mcp/definitions/tools.d.ts +3 -2
- package/dist/runtime/server/mcp/loaders/utils.d.ts +4 -0
- package/dist/runtime/server/mcp/loaders/utils.js +22 -13
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -39,20 +39,18 @@ Or install manually:
|
|
|
39
39
|
|
|
40
40
|
```bash
|
|
41
41
|
# npm
|
|
42
|
-
npm install -D @nuxtjs/mcp-toolkit zod
|
|
42
|
+
npm install -D @nuxtjs/mcp-toolkit zod
|
|
43
43
|
|
|
44
44
|
# yarn
|
|
45
|
-
yarn add -D @nuxtjs/mcp-toolkit zod
|
|
45
|
+
yarn add -D @nuxtjs/mcp-toolkit zod
|
|
46
46
|
|
|
47
47
|
# pnpm
|
|
48
|
-
pnpm add -D @nuxtjs/mcp-toolkit zod
|
|
48
|
+
pnpm add -D @nuxtjs/mcp-toolkit zod
|
|
49
49
|
|
|
50
50
|
# bun
|
|
51
|
-
bun add -D @nuxtjs/mcp-toolkit zod
|
|
51
|
+
bun add -D @nuxtjs/mcp-toolkit zod
|
|
52
52
|
```
|
|
53
53
|
|
|
54
|
-
> **Note:** Zod v3 is required. Zod v4 is not yet compatible with the MCP SDK.
|
|
55
|
-
|
|
56
54
|
<!-- /automd -->
|
|
57
55
|
|
|
58
56
|
## 📖 Quick Start
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -6,7 +6,7 @@ import { ROUTES } from '../dist/runtime/server/mcp/constants.js';
|
|
|
6
6
|
import { addDevToolsCustomTabs } from '../dist/runtime/server/mcp/devtools/index.js';
|
|
7
7
|
|
|
8
8
|
const name = "@nuxtjs/mcp-toolkit";
|
|
9
|
-
const version = "0.
|
|
9
|
+
const version = "0.2.0";
|
|
10
10
|
|
|
11
11
|
const log = logger.withTag("@nuxtjs/mcp-toolkit");
|
|
12
12
|
const { resolve } = createResolver(import.meta.url);
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ZodRawShape } from 'zod';
|
|
2
2
|
import type { GetPromptResult, ServerRequest, ServerNotification } from '@modelcontextprotocol/sdk/types.js';
|
|
3
3
|
import type { RequestHandlerExtra } from '@modelcontextprotocol/sdk/shared/protocol.js';
|
|
4
4
|
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
5
|
+
import type { ShapeOutput } from '@modelcontextprotocol/sdk/server/zod-compat.js';
|
|
5
6
|
/**
|
|
6
7
|
* Callback type for MCP prompts, matching the SDK's PromptCallback type
|
|
7
8
|
*/
|
|
8
|
-
export type McpPromptCallback<Args extends ZodRawShape | undefined = undefined> = Args extends ZodRawShape ? (args:
|
|
9
|
+
export type McpPromptCallback<Args extends ZodRawShape | undefined = undefined> = Args extends ZodRawShape ? (args: ShapeOutput<Args>, extra: RequestHandlerExtra<ServerRequest, ServerNotification>) => GetPromptResult | Promise<GetPromptResult> : (extra: RequestHandlerExtra<ServerRequest, ServerNotification>) => GetPromptResult | Promise<GetPromptResult>;
|
|
9
10
|
/**
|
|
10
11
|
* Definition of an MCP prompt
|
|
11
12
|
* Uses `inputSchema` for consistency with tools, which is mapped to `argsSchema` when registering with the SDK
|
|
@@ -15,6 +15,7 @@ export interface McpResourceAnnotations {
|
|
|
15
15
|
export interface StandardMcpResourceDefinition {
|
|
16
16
|
name?: string;
|
|
17
17
|
title?: string;
|
|
18
|
+
description?: string;
|
|
18
19
|
uri: string | ResourceTemplate;
|
|
19
20
|
metadata?: ResourceMetadata & {
|
|
20
21
|
annotations?: McpResourceAnnotations;
|
|
@@ -29,6 +30,7 @@ export interface StandardMcpResourceDefinition {
|
|
|
29
30
|
export interface FileMcpResourceDefinition {
|
|
30
31
|
name?: string;
|
|
31
32
|
title?: string;
|
|
33
|
+
description?: string;
|
|
32
34
|
uri?: string;
|
|
33
35
|
metadata?: ResourceMetadata & {
|
|
34
36
|
annotations?: McpResourceAnnotations;
|
|
@@ -65,9 +67,9 @@ export declare function registerResourceFromDefinition(server: McpServer, resour
|
|
|
65
67
|
* export default defineMcpResource({
|
|
66
68
|
* name: 'readme',
|
|
67
69
|
* title: 'README',
|
|
70
|
+
* description: 'Project README file',
|
|
68
71
|
* uri: 'file:///project/README.md',
|
|
69
72
|
* metadata: {
|
|
70
|
-
* description: 'Project README file',
|
|
71
73
|
* mimeType: 'text/markdown'
|
|
72
74
|
* },
|
|
73
75
|
* handler: async (uri) => {
|
|
@@ -88,10 +90,8 @@ export declare function registerResourceFromDefinition(server: McpServer, resour
|
|
|
88
90
|
* // Simpler file-based resource
|
|
89
91
|
* export default defineMcpResource({
|
|
90
92
|
* name: 'readme',
|
|
93
|
+
* description: 'Project README file',
|
|
91
94
|
* file: 'README.md', // Automatically handles reading file and setting URI
|
|
92
|
-
* metadata: {
|
|
93
|
-
* description: 'Project README file'
|
|
94
|
-
* }
|
|
95
95
|
* })
|
|
96
96
|
* ```
|
|
97
97
|
*
|
|
@@ -43,7 +43,8 @@ export function registerResourceFromDefinition(server, resource) {
|
|
|
43
43
|
let handler = resource.handler;
|
|
44
44
|
const metadata = {
|
|
45
45
|
...resource.metadata,
|
|
46
|
-
title: resource.title || resource.metadata?.title || title
|
|
46
|
+
title: resource.title || resource.metadata?.title || title,
|
|
47
|
+
description: resource.description || resource.metadata?.description
|
|
47
48
|
};
|
|
48
49
|
if ("file" in resource && resource.file) {
|
|
49
50
|
const filePath = resolve(process.cwd(), resource.file);
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ZodRawShape } from 'zod';
|
|
2
2
|
import type { CallToolResult, ServerRequest, ServerNotification, ToolAnnotations } from '@modelcontextprotocol/sdk/types.js';
|
|
3
3
|
import type { RequestHandlerExtra } from '@modelcontextprotocol/sdk/shared/protocol.js';
|
|
4
4
|
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
5
|
+
import type { ShapeOutput } from '@modelcontextprotocol/sdk/server/zod-compat.js';
|
|
5
6
|
/**
|
|
6
7
|
* Callback type for MCP tools, matching the SDK's ToolCallback type
|
|
7
8
|
*/
|
|
8
|
-
export type McpToolCallback<Args extends ZodRawShape | undefined = ZodRawShape> = Args extends ZodRawShape ? (args:
|
|
9
|
+
export type McpToolCallback<Args extends ZodRawShape | undefined = ZodRawShape> = Args extends ZodRawShape ? (args: ShapeOutput<Args>, extra: RequestHandlerExtra<ServerRequest, ServerNotification>) => CallToolResult | Promise<CallToolResult> : (extra: RequestHandlerExtra<ServerRequest, ServerNotification>) => CallToolResult | Promise<CallToolResult>;
|
|
9
10
|
/**
|
|
10
11
|
* Definition of an MCP tool matching the SDK's registerTool signature
|
|
11
12
|
* This structure is identical to what you'd pass to server.registerTool()
|
|
@@ -4,6 +4,10 @@ export interface LoadResult {
|
|
|
4
4
|
overriddenCount: number;
|
|
5
5
|
}
|
|
6
6
|
export declare function createFilePatterns(paths: string[], extensions?: string[]): string[];
|
|
7
|
+
/**
|
|
8
|
+
* Create file patterns for a specific layer
|
|
9
|
+
*/
|
|
10
|
+
export declare function createLayerFilePatterns(layerServer: string, paths: string[], extensions?: string[]): string[];
|
|
7
11
|
export declare function createExcludePatterns(paths: string[], subdirs: string[]): string[];
|
|
8
12
|
export declare function toIdentifier(filename: string): string;
|
|
9
13
|
export declare function createTemplateContent(type: string, entries: Array<[string, string]>): string;
|
|
@@ -69,6 +69,11 @@ export function createFilePatterns(paths, extensions = ["ts", "js", "mts", "mjs"
|
|
|
69
69
|
)
|
|
70
70
|
);
|
|
71
71
|
}
|
|
72
|
+
export function createLayerFilePatterns(layerServer, paths, extensions = ["ts", "js", "mts", "mjs"]) {
|
|
73
|
+
return paths.flatMap(
|
|
74
|
+
(pathPattern) => extensions.map((ext) => resolvePath(layerServer, `${pathPattern}/*.${ext}`))
|
|
75
|
+
);
|
|
76
|
+
}
|
|
72
77
|
export function createExcludePatterns(paths, subdirs) {
|
|
73
78
|
const layerDirectories = getLayerDirectories();
|
|
74
79
|
return layerDirectories.flatMap(
|
|
@@ -113,22 +118,26 @@ export async function loadDefinitionFiles(paths, options = {}) {
|
|
|
113
118
|
if (paths.length === 0) {
|
|
114
119
|
return { count: 0, files: [], overriddenCount: 0 };
|
|
115
120
|
}
|
|
116
|
-
const
|
|
117
|
-
const
|
|
118
|
-
absolute: true,
|
|
119
|
-
onlyFiles: true,
|
|
120
|
-
ignore: options.excludePatterns
|
|
121
|
-
});
|
|
121
|
+
const layerDirectories = getLayerDirectories();
|
|
122
|
+
const reversedLayers = [...layerDirectories].reverse();
|
|
122
123
|
const definitionsMap = /* @__PURE__ */ new Map();
|
|
123
|
-
const filteredFiles = options.filter ? files.filter(options.filter) : files;
|
|
124
124
|
let overriddenCount = 0;
|
|
125
|
-
for (const
|
|
126
|
-
const
|
|
127
|
-
const
|
|
128
|
-
|
|
129
|
-
|
|
125
|
+
for (const layer of reversedLayers) {
|
|
126
|
+
const layerPatterns = createLayerFilePatterns(layer.server, paths);
|
|
127
|
+
const layerFiles = await glob(layerPatterns, {
|
|
128
|
+
absolute: true,
|
|
129
|
+
onlyFiles: true,
|
|
130
|
+
ignore: options.excludePatterns
|
|
131
|
+
});
|
|
132
|
+
const filteredFiles = options.filter ? layerFiles.filter(options.filter) : layerFiles;
|
|
133
|
+
for (const filePath of filteredFiles) {
|
|
134
|
+
const filename = filePath.split("/").pop();
|
|
135
|
+
const identifier = toIdentifier(filename);
|
|
136
|
+
if (definitionsMap.has(identifier)) {
|
|
137
|
+
overriddenCount++;
|
|
138
|
+
}
|
|
139
|
+
definitionsMap.set(identifier, filePath);
|
|
130
140
|
}
|
|
131
|
-
definitionsMap.set(identifier, filePath);
|
|
132
141
|
}
|
|
133
142
|
const total = definitionsMap.size;
|
|
134
143
|
return {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nuxtjs/mcp-toolkit",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
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.23.0",
|
|
37
37
|
"@nuxt/kit": "^4.2.1",
|
|
38
38
|
"automd": "^0.4.2",
|
|
39
39
|
"chokidar": "^4.0.3",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"tinyglobby": "^0.2.15"
|
|
44
44
|
},
|
|
45
45
|
"peerDependencies": {
|
|
46
|
-
"zod": "^
|
|
46
|
+
"zod": "^4.1.13"
|
|
47
47
|
},
|
|
48
48
|
"peerDependenciesMeta": {
|
|
49
49
|
"zod": {
|