@mantine/mcp-server 9.6.3 → 9.7.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 +9 -4
- package/cjs/data-client.cjs +203 -73
- package/cjs/data-client.cjs.map +1 -1
- package/cjs/search.cjs +133 -0
- package/cjs/search.cjs.map +1 -0
- package/cjs/server.cjs +11 -234
- package/cjs/server.cjs.map +1 -1
- package/cjs/tools.cjs +108 -0
- package/cjs/tools.cjs.map +1 -0
- package/esm/data-client.mjs +203 -73
- package/esm/data-client.mjs.map +1 -1
- package/esm/search.mjs +132 -0
- package/esm/search.mjs.map +1 -0
- package/esm/server.mjs +11 -232
- package/esm/server.mjs.map +1 -1
- package/esm/tools.mjs +106 -0
- package/esm/tools.mjs.map +1 -0
- package/lib/data-client.d.ts +114 -35
- package/lib/search.d.ts +17 -0
- package/lib/server.d.ts +1 -0
- package/lib/tools.d.ts +4 -0
- package/lib/types.d.ts +51 -17
- package/package.json +5 -1
package/cjs/server.cjs
CHANGED
|
@@ -1,245 +1,22 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
const require_runtime = require("./_virtual/_rolldown/runtime.cjs");
|
|
3
2
|
const require_data_client = require("./data-client.cjs");
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
const require_tools = require("./tools.cjs");
|
|
4
|
+
let _modelcontextprotocol_server = require("@modelcontextprotocol/server");
|
|
5
|
+
let _modelcontextprotocol_server_stdio = require("@modelcontextprotocol/server/stdio");
|
|
6
6
|
//#region packages/@mantine/mcp-server/src/server.ts
|
|
7
|
-
|
|
8
|
-
{
|
|
9
|
-
name: "list_items",
|
|
10
|
-
description: "List Mantine documentation items. Supports filtering by kind (component|hook), package and text query.",
|
|
11
|
-
inputSchema: {
|
|
12
|
-
type: "object",
|
|
13
|
-
properties: {
|
|
14
|
-
kind: {
|
|
15
|
-
type: "string",
|
|
16
|
-
enum: ["component", "hook"]
|
|
17
|
-
},
|
|
18
|
-
package: { type: "string" },
|
|
19
|
-
query: { type: "string" },
|
|
20
|
-
limit: { type: "number" }
|
|
21
|
-
},
|
|
22
|
-
additionalProperties: false
|
|
23
|
-
}
|
|
24
|
-
},
|
|
25
|
-
{
|
|
26
|
-
name: "get_item_doc",
|
|
27
|
-
description: "Get the LLM-ready markdown documentation for a Mantine item by name or id.",
|
|
28
|
-
inputSchema: {
|
|
29
|
-
type: "object",
|
|
30
|
-
properties: {
|
|
31
|
-
name: { type: "string" },
|
|
32
|
-
kind: {
|
|
33
|
-
type: "string",
|
|
34
|
-
enum: ["component", "hook"]
|
|
35
|
-
}
|
|
36
|
-
},
|
|
37
|
-
required: ["name"],
|
|
38
|
-
additionalProperties: false
|
|
39
|
-
}
|
|
40
|
-
},
|
|
41
|
-
{
|
|
42
|
-
name: "get_item_props",
|
|
43
|
-
description: "Get normalized props metadata for a Mantine item by name or id.",
|
|
44
|
-
inputSchema: {
|
|
45
|
-
type: "object",
|
|
46
|
-
properties: {
|
|
47
|
-
name: { type: "string" },
|
|
48
|
-
kind: {
|
|
49
|
-
type: "string",
|
|
50
|
-
enum: ["component", "hook"]
|
|
51
|
-
}
|
|
52
|
-
},
|
|
53
|
-
required: ["name"],
|
|
54
|
-
additionalProperties: false
|
|
55
|
-
}
|
|
56
|
-
},
|
|
57
|
-
{
|
|
58
|
-
name: "search_docs",
|
|
59
|
-
description: "Search Mantine docs by free text query and return ranked matches.",
|
|
60
|
-
inputSchema: {
|
|
61
|
-
type: "object",
|
|
62
|
-
properties: {
|
|
63
|
-
kind: {
|
|
64
|
-
type: "string",
|
|
65
|
-
enum: ["component", "hook"]
|
|
66
|
-
},
|
|
67
|
-
query: { type: "string" },
|
|
68
|
-
limit: { type: "number" }
|
|
69
|
-
},
|
|
70
|
-
required: ["query"],
|
|
71
|
-
additionalProperties: false
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
];
|
|
75
|
-
function createJsonRpcError(code, message) {
|
|
76
|
-
return {
|
|
77
|
-
code,
|
|
78
|
-
message
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
function toToolResult(content) {
|
|
82
|
-
return { content: [{
|
|
83
|
-
type: "text",
|
|
84
|
-
text: typeof content === "string" ? content : JSON.stringify(content, null, 2)
|
|
85
|
-
}] };
|
|
86
|
-
}
|
|
87
|
-
function toToolError(message) {
|
|
88
|
-
return {
|
|
89
|
-
isError: true,
|
|
90
|
-
content: [{
|
|
91
|
-
type: "text",
|
|
92
|
-
text: message
|
|
93
|
-
}]
|
|
94
|
-
};
|
|
95
|
-
}
|
|
96
|
-
function parseListItemsArgs(args) {
|
|
97
|
-
return {
|
|
98
|
-
kind: args.kind === "component" || args.kind === "hook" ? args.kind : void 0,
|
|
99
|
-
package: typeof args.package === "string" ? args.package : void 0,
|
|
100
|
-
query: typeof args.query === "string" ? args.query : void 0,
|
|
101
|
-
limit: typeof args.limit === "number" ? args.limit : void 0
|
|
102
|
-
};
|
|
103
|
-
}
|
|
104
|
-
function parseGetItemArgs(args) {
|
|
105
|
-
if (typeof args.name !== "string" || args.name.length === 0) return null;
|
|
106
|
-
return {
|
|
107
|
-
name: args.name,
|
|
108
|
-
kind: args.kind === "component" || args.kind === "hook" ? args.kind : void 0
|
|
109
|
-
};
|
|
110
|
-
}
|
|
111
|
-
function parseSearchDocsArgs(args) {
|
|
112
|
-
if (typeof args.query !== "string" || args.query.length === 0) return null;
|
|
113
|
-
return {
|
|
114
|
-
query: args.query,
|
|
115
|
-
kind: args.kind === "component" || args.kind === "hook" ? args.kind : void 0,
|
|
116
|
-
limit: typeof args.limit === "number" ? args.limit : void 0
|
|
117
|
-
};
|
|
118
|
-
}
|
|
119
|
-
function writeMessage(payload) {
|
|
120
|
-
process.stdout.write(`${JSON.stringify(payload)}\n`);
|
|
121
|
-
}
|
|
122
|
-
function writeResponse(id, result) {
|
|
123
|
-
writeMessage({
|
|
124
|
-
jsonrpc: "2.0",
|
|
125
|
-
id,
|
|
126
|
-
result
|
|
127
|
-
});
|
|
128
|
-
}
|
|
129
|
-
function writeError(id, code, message) {
|
|
130
|
-
writeMessage({
|
|
131
|
-
jsonrpc: "2.0",
|
|
132
|
-
id,
|
|
133
|
-
error: createJsonRpcError(code, message)
|
|
134
|
-
});
|
|
135
|
-
}
|
|
7
|
+
/** Starts the Mantine documentation MCP server over stdio */
|
|
136
8
|
function startServer() {
|
|
137
9
|
const timeoutMs = Number(process.env.MANTINE_MCP_TIMEOUT_MS || 1e4);
|
|
138
10
|
const dataUrl = process.env.MANTINE_MCP_DATA_URL || "https://mantine.dev/mcp";
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
let request;
|
|
147
|
-
try {
|
|
148
|
-
request = JSON.parse(trimmed);
|
|
149
|
-
} catch {
|
|
150
|
-
writeError(null, -32700, "Parse error");
|
|
151
|
-
return;
|
|
152
|
-
}
|
|
153
|
-
handleRequest(client, request);
|
|
11
|
+
(0, _modelcontextprotocol_server_stdio.serveStdio)(() => {
|
|
12
|
+
const server = new _modelcontextprotocol_server.McpServer({
|
|
13
|
+
name: "@mantine/mcp-server",
|
|
14
|
+
version: "9"
|
|
15
|
+
});
|
|
16
|
+
require_tools.registerTools(server, new require_data_client.MantineMcpDataClient(dataUrl, timeoutMs));
|
|
17
|
+
return server;
|
|
154
18
|
});
|
|
155
19
|
}
|
|
156
|
-
async function handleRequest(client, request) {
|
|
157
|
-
const id = request.id ?? null;
|
|
158
|
-
if (!request || request.jsonrpc !== "2.0" || typeof request.method !== "string") {
|
|
159
|
-
writeError(id, -32600, "Invalid request");
|
|
160
|
-
return;
|
|
161
|
-
}
|
|
162
|
-
try {
|
|
163
|
-
switch (request.method) {
|
|
164
|
-
case "initialize":
|
|
165
|
-
writeResponse(id, {
|
|
166
|
-
protocolVersion: "2024-11-05",
|
|
167
|
-
capabilities: { tools: {} },
|
|
168
|
-
serverInfo: {
|
|
169
|
-
name: "@mantine/mcp-server",
|
|
170
|
-
version: "9"
|
|
171
|
-
}
|
|
172
|
-
});
|
|
173
|
-
break;
|
|
174
|
-
case "notifications/initialized": return;
|
|
175
|
-
case "tools/list":
|
|
176
|
-
writeResponse(id, { tools: TOOL_DEFINITIONS });
|
|
177
|
-
return;
|
|
178
|
-
case "tools/call": {
|
|
179
|
-
const params = request.params && typeof request.params === "object" ? request.params : {};
|
|
180
|
-
const name = typeof params.name === "string" ? params.name : "";
|
|
181
|
-
const args = params.arguments && typeof params.arguments === "object" ? params.arguments : {};
|
|
182
|
-
if (!name) {
|
|
183
|
-
writeResponse(id, toToolError("Tool name is required"));
|
|
184
|
-
return;
|
|
185
|
-
}
|
|
186
|
-
if (name === "list_items") {
|
|
187
|
-
writeResponse(id, toToolResult(await client.listItems(parseListItemsArgs(args))));
|
|
188
|
-
return;
|
|
189
|
-
}
|
|
190
|
-
if (name === "get_item_doc") {
|
|
191
|
-
const parsed = parseGetItemArgs(args);
|
|
192
|
-
if (!parsed) {
|
|
193
|
-
writeResponse(id, toToolError("Argument \"name\" is required"));
|
|
194
|
-
return;
|
|
195
|
-
}
|
|
196
|
-
const result = await client.getItemDoc(parsed);
|
|
197
|
-
if (!result) {
|
|
198
|
-
writeResponse(id, toToolError(`Item not found: ${parsed.name}`));
|
|
199
|
-
return;
|
|
200
|
-
}
|
|
201
|
-
writeResponse(id, toToolResult(result));
|
|
202
|
-
return;
|
|
203
|
-
}
|
|
204
|
-
if (name === "get_item_props") {
|
|
205
|
-
const parsed = parseGetItemArgs(args);
|
|
206
|
-
if (!parsed) {
|
|
207
|
-
writeResponse(id, toToolError("Argument \"name\" is required"));
|
|
208
|
-
return;
|
|
209
|
-
}
|
|
210
|
-
const result = await client.getItemProps(parsed);
|
|
211
|
-
if (!result) {
|
|
212
|
-
writeResponse(id, toToolError(`Item not found: ${parsed.name}`));
|
|
213
|
-
return;
|
|
214
|
-
}
|
|
215
|
-
writeResponse(id, toToolResult(result));
|
|
216
|
-
return;
|
|
217
|
-
}
|
|
218
|
-
if (name === "search_docs") {
|
|
219
|
-
const parsed = parseSearchDocsArgs(args);
|
|
220
|
-
if (!parsed) {
|
|
221
|
-
writeResponse(id, toToolError("Argument \"query\" is required"));
|
|
222
|
-
return;
|
|
223
|
-
}
|
|
224
|
-
writeResponse(id, toToolResult(await client.searchDocs(parsed)));
|
|
225
|
-
return;
|
|
226
|
-
}
|
|
227
|
-
writeResponse(id, toToolError(`Unknown tool: ${name}`));
|
|
228
|
-
return;
|
|
229
|
-
}
|
|
230
|
-
default:
|
|
231
|
-
if (id === null) return;
|
|
232
|
-
writeError(id, -32601, `Method not found: ${request.method}`);
|
|
233
|
-
}
|
|
234
|
-
} catch (error) {
|
|
235
|
-
const message = error instanceof Error ? error.message : "Unexpected error";
|
|
236
|
-
if (request.method === "tools/call") {
|
|
237
|
-
writeResponse(id, toToolError(message));
|
|
238
|
-
return;
|
|
239
|
-
}
|
|
240
|
-
writeError(id, -32e3, message);
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
20
|
//#endregion
|
|
244
21
|
exports.startServer = startServer;
|
|
245
22
|
|
package/cjs/server.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.cjs","names":["MantineMcpDataClient","readline"],"sources":["../src/server.ts"],"sourcesContent":["import readline from 'node:readline';\nimport { MantineMcpDataClient } from './data-client';\nimport { GetItemArgs, ListItemsArgs, SearchDocsArgs } from './types';\n\ninterface JsonRpcRequest {\n jsonrpc: '2.0';\n id?: string | number | null;\n method: string;\n params?: unknown;\n}\n\nconst TOOL_DEFINITIONS = [\n {\n name: 'list_items',\n description:\n 'List Mantine documentation items. Supports filtering by kind (component|hook), package and text query.',\n inputSchema: {\n type: 'object',\n properties: {\n kind: { type: 'string', enum: ['component', 'hook'] },\n package: { type: 'string' },\n query: { type: 'string' },\n limit: { type: 'number' },\n },\n additionalProperties: false,\n },\n },\n {\n name: 'get_item_doc',\n description: 'Get the LLM-ready markdown documentation for a Mantine item by name or id.',\n inputSchema: {\n type: 'object',\n properties: {\n name: { type: 'string' },\n kind: { type: 'string', enum: ['component', 'hook'] },\n },\n required: ['name'],\n additionalProperties: false,\n },\n },\n {\n name: 'get_item_props',\n description: 'Get normalized props metadata for a Mantine item by name or id.',\n inputSchema: {\n type: 'object',\n properties: {\n name: { type: 'string' },\n kind: { type: 'string', enum: ['component', 'hook'] },\n },\n required: ['name'],\n additionalProperties: false,\n },\n },\n {\n name: 'search_docs',\n description: 'Search Mantine docs by free text query and return ranked matches.',\n inputSchema: {\n type: 'object',\n properties: {\n kind: { type: 'string', enum: ['component', 'hook'] },\n query: { type: 'string' },\n limit: { type: 'number' },\n },\n required: ['query'],\n additionalProperties: false,\n },\n },\n];\n\nfunction createJsonRpcError(code: number, message: string) {\n return { code, message };\n}\n\nfunction toToolResult(content: unknown) {\n const text = typeof content === 'string' ? content : JSON.stringify(content, null, 2);\n\n return {\n content: [{ type: 'text', text }],\n };\n}\n\nfunction toToolError(message: string) {\n return {\n isError: true,\n content: [{ type: 'text', text: message }],\n };\n}\n\nfunction parseListItemsArgs(args: Record<string, unknown>): ListItemsArgs {\n return {\n kind: args.kind === 'component' || args.kind === 'hook' ? args.kind : undefined,\n package: typeof args.package === 'string' ? args.package : undefined,\n query: typeof args.query === 'string' ? args.query : undefined,\n limit: typeof args.limit === 'number' ? args.limit : undefined,\n };\n}\n\nfunction parseGetItemArgs(args: Record<string, unknown>): GetItemArgs | null {\n if (typeof args.name !== 'string' || args.name.length === 0) {\n return null;\n }\n\n return {\n name: args.name,\n kind: args.kind === 'component' || args.kind === 'hook' ? args.kind : undefined,\n };\n}\n\nfunction parseSearchDocsArgs(args: Record<string, unknown>): SearchDocsArgs | null {\n if (typeof args.query !== 'string' || args.query.length === 0) {\n return null;\n }\n\n return {\n query: args.query,\n kind: args.kind === 'component' || args.kind === 'hook' ? args.kind : undefined,\n limit: typeof args.limit === 'number' ? args.limit : undefined,\n };\n}\n\nfunction writeMessage(payload: unknown) {\n process.stdout.write(`${JSON.stringify(payload)}\\n`);\n}\n\nfunction writeResponse(id: string | number | null, result: unknown) {\n writeMessage({ jsonrpc: '2.0', id, result });\n}\n\nfunction writeError(id: string | number | null, code: number, message: string) {\n writeMessage({\n jsonrpc: '2.0',\n id,\n error: createJsonRpcError(code, message),\n });\n}\n\nexport function startServer() {\n const timeoutMs = Number(process.env.MANTINE_MCP_TIMEOUT_MS || 10000);\n const dataUrl = process.env.MANTINE_MCP_DATA_URL || 'https://mantine.dev/mcp';\n const client = new MantineMcpDataClient(dataUrl, timeoutMs);\n\n const rl = readline.createInterface({ input: process.stdin, terminal: false });\n\n rl.on('line', (line: string) => {\n const trimmed = line.trim();\n if (trimmed.length === 0) {\n return;\n }\n\n let request: JsonRpcRequest;\n try {\n request = JSON.parse(trimmed);\n } catch {\n writeError(null, -32700, 'Parse error');\n return;\n }\n\n void handleRequest(client, request);\n });\n}\n\nasync function handleRequest(client: MantineMcpDataClient, request: JsonRpcRequest) {\n const id = request.id ?? null;\n\n if (!request || request.jsonrpc !== '2.0' || typeof request.method !== 'string') {\n writeError(id, -32600, 'Invalid request');\n return;\n }\n\n try {\n switch (request.method) {\n case 'initialize': {\n writeResponse(id, {\n protocolVersion: '2024-11-05',\n capabilities: {\n tools: {},\n },\n serverInfo: {\n name: '@mantine/mcp-server',\n version: '9',\n },\n });\n break;\n }\n\n case 'notifications/initialized': {\n return;\n }\n\n case 'tools/list': {\n writeResponse(id, { tools: TOOL_DEFINITIONS });\n return;\n }\n\n case 'tools/call': {\n const params =\n request.params && typeof request.params === 'object'\n ? (request.params as Record<string, unknown>)\n : {};\n const name = typeof params.name === 'string' ? params.name : '';\n const args =\n params.arguments && typeof params.arguments === 'object'\n ? (params.arguments as Record<string, unknown>)\n : {};\n\n if (!name) {\n writeResponse(id, toToolError('Tool name is required'));\n return;\n }\n\n if (name === 'list_items') {\n const result = await client.listItems(parseListItemsArgs(args));\n writeResponse(id, toToolResult(result));\n return;\n }\n\n if (name === 'get_item_doc') {\n const parsed = parseGetItemArgs(args);\n if (!parsed) {\n writeResponse(id, toToolError('Argument \"name\" is required'));\n return;\n }\n\n const result = await client.getItemDoc(parsed);\n if (!result) {\n writeResponse(id, toToolError(`Item not found: ${parsed.name}`));\n return;\n }\n\n writeResponse(id, toToolResult(result));\n return;\n }\n\n if (name === 'get_item_props') {\n const parsed = parseGetItemArgs(args);\n if (!parsed) {\n writeResponse(id, toToolError('Argument \"name\" is required'));\n return;\n }\n\n const result = await client.getItemProps(parsed);\n if (!result) {\n writeResponse(id, toToolError(`Item not found: ${parsed.name}`));\n return;\n }\n\n writeResponse(id, toToolResult(result));\n return;\n }\n\n if (name === 'search_docs') {\n const parsed = parseSearchDocsArgs(args);\n if (!parsed) {\n writeResponse(id, toToolError('Argument \"query\" is required'));\n return;\n }\n\n const result = await client.searchDocs(parsed);\n writeResponse(id, toToolResult(result));\n return;\n }\n\n writeResponse(id, toToolError(`Unknown tool: ${name}`));\n return;\n }\n\n default: {\n if (id === null) {\n return;\n }\n\n writeError(id, -32601, `Method not found: ${request.method}`);\n }\n }\n } catch (error) {\n const message = error instanceof Error ? error.message : 'Unexpected error';\n\n if (request.method === 'tools/call') {\n writeResponse(id, toToolError(message));\n return;\n }\n\n writeError(id, -32000, message);\n }\n}\n"],"mappings":";;;;;;AAWA,MAAM,mBAAmB;CACvB;EACE,MAAM;EACN,aACE;EACF,aAAa;GACX,MAAM;GACN,YAAY;IACV,MAAM;KAAE,MAAM;KAAU,MAAM,CAAC,aAAa,MAAM;IAAE;IACpD,SAAS,EAAE,MAAM,SAAS;IAC1B,OAAO,EAAE,MAAM,SAAS;IACxB,OAAO,EAAE,MAAM,SAAS;GAC1B;GACA,sBAAsB;EACxB;CACF;CACA;EACE,MAAM;EACN,aAAa;EACb,aAAa;GACX,MAAM;GACN,YAAY;IACV,MAAM,EAAE,MAAM,SAAS;IACvB,MAAM;KAAE,MAAM;KAAU,MAAM,CAAC,aAAa,MAAM;IAAE;GACtD;GACA,UAAU,CAAC,MAAM;GACjB,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mB,OAAO,MAAM,CAAC;MAC/D;KACF;KAEA,cAAc,IAAI,aAAa,MAAM,CAAC;KACtC;IACF;IAEA,IAAI,SAAS,eAAe;KAC1B,MAAM,SAAS,oBAAoB,IAAI;KACvC,IAAI,CAAC,QAAQ;MACX,cAAc,IAAI,YAAY,gCAA8B,CAAC;MAC7D;KACF;KAGA,cAAc,IAAI,aAAa,MADV,OAAO,WAAW,MAAM,CACR,CAAC;KACtC;IACF;IAEA,cAAc,IAAI,YAAY,iBAAiB,MAAM,CAAC;IACtD;GACF;GAEA;IACE,IAAI,OAAO,MACT;IAGF,WAAW,IAAI,QAAQ,qBAAqB,QAAQ,QAAQ;EAEhE;CACF,SAAS,OAAO;EACd,MAAM,UAAU,iBAAiB,QAAQ,MAAM,UAAU;EAEzD,IAAI,QAAQ,WAAW,cAAc;GACnC,cAAc,IAAI,YAAY,OAAO,CAAC;GACtC;EACF;EAEA,WAAW,IAAI,OAAQ,OAAO;CAChC;AACF"}
|
|
1
|
+
{"version":3,"file":"server.cjs","names":["McpServer","MantineMcpDataClient"],"sources":["../src/server.ts"],"sourcesContent":["import { McpServer } from '@modelcontextprotocol/server';\nimport { serveStdio } from '@modelcontextprotocol/server/stdio';\nimport { MantineMcpDataClient } from './data-client';\nimport { registerTools } from './tools';\n\n/** Starts the Mantine documentation MCP server over stdio */\nexport function startServer(): void {\n const timeoutMs = Number(process.env.MANTINE_MCP_TIMEOUT_MS || 10000);\n const dataUrl = process.env.MANTINE_MCP_DATA_URL || 'https://mantine.dev/mcp';\n\n serveStdio(() => {\n const server = new McpServer({ name: '@mantine/mcp-server', version: '9' });\n registerTools(server, new MantineMcpDataClient(dataUrl, timeoutMs));\n return server;\n });\n}\n"],"mappings":";;;;;;;AAMA,SAAgB,cAAoB;CAClC,MAAM,YAAY,OAAO,QAAQ,IAAI,0BAA0B,GAAK;CACpE,MAAM,UAAU,QAAQ,IAAI,wBAAwB;CAEpD,CAAA,GAAA,mCAAA,WAAA,OAAiB;EACf,MAAM,SAAS,IAAIA,6BAAAA,UAAU;GAAE,MAAM;GAAuB,SAAS;EAAI,CAAC;EAC1E,cAAA,cAAc,QAAQ,IAAIC,oBAAAA,qBAAqB,SAAS,SAAS,CAAC;EAClE,OAAO;CACT,CAAC;AACH"}
|
package/cjs/tools.cjs
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
const require_runtime = require("./_virtual/_rolldown/runtime.cjs");
|
|
3
|
+
let zod = require("zod");
|
|
4
|
+
zod = require_runtime.__toESM(zod);
|
|
5
|
+
//#region packages/@mantine/mcp-server/src/tools.ts
|
|
6
|
+
const kindSchema = zod.enum([
|
|
7
|
+
"component",
|
|
8
|
+
"hook",
|
|
9
|
+
"guide",
|
|
10
|
+
"faq"
|
|
11
|
+
]);
|
|
12
|
+
const groupSchema = zod.enum([
|
|
13
|
+
"gettingStarted",
|
|
14
|
+
"theming",
|
|
15
|
+
"hooks",
|
|
16
|
+
"components",
|
|
17
|
+
"extensions",
|
|
18
|
+
"form"
|
|
19
|
+
]);
|
|
20
|
+
const nameSchema = zod.string().trim().min(1);
|
|
21
|
+
function text(payload) {
|
|
22
|
+
return { content: [{
|
|
23
|
+
type: "text",
|
|
24
|
+
text: typeof payload === "string" ? payload : JSON.stringify(payload, null, 2)
|
|
25
|
+
}] };
|
|
26
|
+
}
|
|
27
|
+
function error(message) {
|
|
28
|
+
return {
|
|
29
|
+
isError: true,
|
|
30
|
+
content: [{
|
|
31
|
+
type: "text",
|
|
32
|
+
text: message
|
|
33
|
+
}]
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
/** Registers every Mantine documentation tool on an MCP server instance */
|
|
37
|
+
function registerTools(server, client) {
|
|
38
|
+
server.registerTool("search_docs", {
|
|
39
|
+
title: "Search Mantine documentation",
|
|
40
|
+
description: "Search all Mantine documentation — components, hooks, @mantine/form, styling, theming, guides and FAQ. Returns ranked matches; a match may point at a specific section, which can then be fetched with get_item_doc.",
|
|
41
|
+
inputSchema: zod.object({
|
|
42
|
+
query: zod.string().describe("Free text query, e.g. \"validate a form with zod\""),
|
|
43
|
+
kind: kindSchema.optional(),
|
|
44
|
+
package: zod.string().optional().describe("Filter by package, e.g. \"@mantine/form\""),
|
|
45
|
+
limit: zod.number().optional().describe("Maximum number of results (default 20, max 100)")
|
|
46
|
+
})
|
|
47
|
+
}, async (args) => text(await client.search(args)));
|
|
48
|
+
server.registerTool("get_item_doc", {
|
|
49
|
+
title: "Get Mantine documentation",
|
|
50
|
+
description: "Get documentation for a Mantine component, hook, guide or FAQ page. Without a section it returns an outline (description plus section list) — pass a section to fetch just that part, or full:true for the whole page.",
|
|
51
|
+
inputSchema: zod.object({
|
|
52
|
+
name: nameSchema.describe("Item name or id, e.g. \"useForm\", \"Button\", \"form-validation\""),
|
|
53
|
+
kind: kindSchema.optional(),
|
|
54
|
+
section: zod.string().optional().describe("Section slug from the outline, e.g. \"zod\""),
|
|
55
|
+
full: zod.boolean().optional().describe("Return the entire page; can be very large")
|
|
56
|
+
})
|
|
57
|
+
}, async (args) => {
|
|
58
|
+
const result = await client.getDoc(args);
|
|
59
|
+
if (!result) {
|
|
60
|
+
const suggestions = await client.suggestFor(args.name);
|
|
61
|
+
return error(suggestions.length > 0 ? `No exact match for "${args.name}". Did you mean: ${suggestions.join(", ")}?` : `No Mantine documentation found for "${args.name}". Try search_docs first.`);
|
|
62
|
+
}
|
|
63
|
+
return text(result);
|
|
64
|
+
});
|
|
65
|
+
server.registerTool("get_item_props", {
|
|
66
|
+
title: "Get Mantine props or signature",
|
|
67
|
+
description: "Get props for a Mantine component, or the TypeScript signature for a hook. Pages documenting an API in prose point at the relevant section instead.",
|
|
68
|
+
inputSchema: zod.object({
|
|
69
|
+
name: nameSchema,
|
|
70
|
+
kind: kindSchema.optional()
|
|
71
|
+
})
|
|
72
|
+
}, async (args) => {
|
|
73
|
+
const result = await client.getProps(args);
|
|
74
|
+
if (!result) {
|
|
75
|
+
const suggestions = await client.suggestFor(args.name);
|
|
76
|
+
return error(suggestions.length > 0 ? `No exact match for "${args.name}". Did you mean: ${suggestions.join(", ")}?` : `No Mantine documentation found for "${args.name}".`);
|
|
77
|
+
}
|
|
78
|
+
return text(result);
|
|
79
|
+
});
|
|
80
|
+
server.registerTool("list_items", {
|
|
81
|
+
title: "List Mantine documentation items",
|
|
82
|
+
description: "List Mantine documentation items, filtered by kind, nav group, category, package or a text query.",
|
|
83
|
+
inputSchema: zod.object({
|
|
84
|
+
kind: kindSchema.optional(),
|
|
85
|
+
group: groupSchema.optional(),
|
|
86
|
+
category: zod.string().optional(),
|
|
87
|
+
package: zod.string().optional(),
|
|
88
|
+
query: zod.string().optional(),
|
|
89
|
+
limit: zod.number().optional().describe("Maximum number of results (default 30, max 500)")
|
|
90
|
+
})
|
|
91
|
+
}, async (args) => text(await client.listItems(args)));
|
|
92
|
+
server.registerTool("get_api", {
|
|
93
|
+
title: "Resolve a Mantine symbol",
|
|
94
|
+
description: "Resolve a Mantine symbol (useForm, useDisclosure, UseFormReturnType) to its TypeScript signature and exported types, without knowing which page documents it.",
|
|
95
|
+
inputSchema: zod.object({ symbol: nameSchema })
|
|
96
|
+
}, async ({ symbol }) => {
|
|
97
|
+
const result = await client.getApi(symbol);
|
|
98
|
+
if (!result) {
|
|
99
|
+
const suggestions = await client.suggestFor(symbol);
|
|
100
|
+
return error(suggestions.length > 0 ? `No API found for "${symbol}". Did you mean: ${suggestions.join(", ")}?` : `No API found for "${symbol}". Try search_docs.`);
|
|
101
|
+
}
|
|
102
|
+
return text(result);
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
//#endregion
|
|
106
|
+
exports.registerTools = registerTools;
|
|
107
|
+
|
|
108
|
+
//# sourceMappingURL=tools.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tools.cjs","names":["z"],"sources":["../src/tools.ts"],"sourcesContent":["import type { McpServer } from '@modelcontextprotocol/server';\nimport * as z from 'zod';\nimport { MantineMcpDataClient } from './data-client';\n\nconst kindSchema = z.enum(['component', 'hook', 'guide', 'faq']);\nconst groupSchema = z.enum([\n 'gettingStarted',\n 'theming',\n 'hooks',\n 'components',\n 'extensions',\n 'form',\n]);\nconst nameSchema = z.string().trim().min(1);\n\nfunction text(payload: unknown) {\n return {\n content: [\n {\n type: 'text' as const,\n text: typeof payload === 'string' ? payload : JSON.stringify(payload, null, 2),\n },\n ],\n };\n}\n\nfunction error(message: string) {\n return { isError: true, content: [{ type: 'text' as const, text: message }] };\n}\n\n/** Registers every Mantine documentation tool on an MCP server instance */\nexport function registerTools(server: McpServer, client: MantineMcpDataClient): void {\n server.registerTool(\n 'search_docs',\n {\n title: 'Search Mantine documentation',\n description:\n 'Search all Mantine documentation — components, hooks, @mantine/form, styling, theming, guides and FAQ. Returns ranked matches; a match may point at a specific section, which can then be fetched with get_item_doc.',\n inputSchema: z.object({\n query: z.string().describe('Free text query, e.g. \"validate a form with zod\"'),\n kind: kindSchema.optional(),\n package: z.string().optional().describe('Filter by package, e.g. \"@mantine/form\"'),\n limit: z.number().optional().describe('Maximum number of results (default 20, max 100)'),\n }),\n },\n async (args) => text(await client.search(args))\n );\n\n server.registerTool(\n 'get_item_doc',\n {\n title: 'Get Mantine documentation',\n description:\n 'Get documentation for a Mantine component, hook, guide or FAQ page. Without a section it returns an outline (description plus section list) — pass a section to fetch just that part, or full:true for the whole page.',\n inputSchema: z.object({\n name: nameSchema.describe('Item name or id, e.g. \"useForm\", \"Button\", \"form-validation\"'),\n kind: kindSchema.optional(),\n section: z.string().optional().describe('Section slug from the outline, e.g. \"zod\"'),\n full: z.boolean().optional().describe('Return the entire page; can be very large'),\n }),\n },\n async (args) => {\n const result = await client.getDoc(args);\n\n if (!result) {\n const suggestions = await client.suggestFor(args.name);\n return error(\n suggestions.length > 0\n ? `No exact match for \"${args.name}\". Did you mean: ${suggestions.join(', ')}?`\n : `No Mantine documentation found for \"${args.name}\". Try search_docs first.`\n );\n }\n\n return text(result);\n }\n );\n\n server.registerTool(\n 'get_item_props',\n {\n title: 'Get Mantine props or signature',\n description:\n 'Get props for a Mantine component, or the TypeScript signature for a hook. Pages documenting an API in prose point at the relevant section instead.',\n inputSchema: z.object({ name: nameSchema, kind: kindSchema.optional() }),\n },\n async (args) => {\n const result = await client.getProps(args);\n\n if (!result) {\n const suggestions = await client.suggestFor(args.name);\n return error(\n suggestions.length > 0\n ? `No exact match for \"${args.name}\". Did you mean: ${suggestions.join(', ')}?`\n : `No Mantine documentation found for \"${args.name}\".`\n );\n }\n\n return text(result);\n }\n );\n\n server.registerTool(\n 'list_items',\n {\n title: 'List Mantine documentation items',\n description:\n 'List Mantine documentation items, filtered by kind, nav group, category, package or a text query.',\n inputSchema: z.object({\n kind: kindSchema.optional(),\n group: groupSchema.optional(),\n category: z.string().optional(),\n package: z.string().optional(),\n query: z.string().optional(),\n limit: z.number().optional().describe('Maximum number of results (default 30, max 500)'),\n }),\n },\n async (args) => text(await client.listItems(args))\n );\n\n server.registerTool(\n 'get_api',\n {\n title: 'Resolve a Mantine symbol',\n description:\n 'Resolve a Mantine symbol (useForm, useDisclosure, UseFormReturnType) to its TypeScript signature and exported types, without knowing which page documents it.',\n inputSchema: z.object({ symbol: nameSchema }),\n },\n async ({ symbol }) => {\n const result = await client.getApi(symbol);\n\n if (!result) {\n const suggestions = await client.suggestFor(symbol);\n return error(\n suggestions.length > 0\n ? `No API found for \"${symbol}\". Did you mean: ${suggestions.join(', ')}?`\n : `No API found for \"${symbol}\". Try search_docs.`\n );\n }\n\n return text(result);\n }\n );\n}\n"],"mappings":";;;;;AAIA,MAAM,aAAaA,IAAE,KAAK;CAAC;CAAa;CAAQ;CAAS;AAAK,CAAC;AAC/D,MAAM,cAAcA,IAAE,KAAK;CACzB;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;AACD,MAAM,aAAaA,IAAE,OAAO,CAAC,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC;AAE1C,SAAS,KAAK,SAAkB;CAC9B,OAAO,EACL,SA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