@nocopypaste/vue-grid-mcp 0.3.1 → 0.3.2
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 +13 -9
- package/bin/vue-grid-mcp.js +7 -2
- package/package.json +2 -2
- package/src/docs.js +3 -1
- package/src/server.js +31 -6
- package/src/tools.js +99 -22
package/README.md
CHANGED
|
@@ -23,13 +23,13 @@ Any MCP client (Cursor, VS Code, Windsurf, Claude Desktop…):
|
|
|
23
23
|
|
|
24
24
|
## Tools
|
|
25
25
|
|
|
26
|
-
| Tool
|
|
27
|
-
|
|
28
|
-
| `vue_grid_guide`
|
|
29
|
-
| `vue_grid_api` `{ section?, name? }`
|
|
30
|
-
| `vue_grid_renderer` `{ name? }`
|
|
31
|
-
| `vue_grid_search_docs` `{ query, limit? }` | The best matching sections of the guide, API reference and README.
|
|
32
|
-
| `vue_grid_validate` `{ config }`
|
|
26
|
+
| Tool | What it returns |
|
|
27
|
+
| ------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
28
|
+
| `vue_grid_guide` | `AGENTS.md`: the rules that prevent silent failures, which feature / renderer for what, recipes, pitfalls. Call it first. |
|
|
29
|
+
| `vue_grid_api` `{ section?, name? }` | The generated API reference: props, v-models, events, slots, methods, `column` options, features, renderers, types — an index, a section, or one entry (with the feature it needs). |
|
|
30
|
+
| `vue_grid_renderer` `{ name? }` | A renderer's options with types and a column example, or all renderers in one list. |
|
|
31
|
+
| `vue_grid_search_docs` `{ query, limit? }` | The best matching sections of the guide, API reference and README. |
|
|
32
|
+
| `vue_grid_validate` `{ config }` | Diagnostics for a grid config (props, `columns`, `features`, `renderers`): unknown names with did-you-mean, options whose feature is missing, unknown / unregistered renderers and options, wrong types, combinations that do nothing — each with a fix. |
|
|
33
33
|
|
|
34
34
|
Resources: `vue-grid://AGENTS.md`, `vue-grid://api.md`, `vue-grid://README.md`,
|
|
35
35
|
`vue-grid://api.json`, `vue-grid://grid-config.schema.json`.
|
|
@@ -44,8 +44,12 @@ npx @nocopypaste/vue-grid-mcp guide # print AGENTS.md
|
|
|
44
44
|
`grid.json` is the grid as data, e.g.:
|
|
45
45
|
|
|
46
46
|
```json
|
|
47
|
-
{
|
|
48
|
-
"
|
|
47
|
+
{
|
|
48
|
+
"rowKey": "id",
|
|
49
|
+
"features": ["sortingFeature"],
|
|
50
|
+
"sortMode": "client",
|
|
51
|
+
"columns": [{ "key": "total", "renderer": "currencyRenderer", "sortable": true }]
|
|
52
|
+
}
|
|
49
53
|
```
|
|
50
54
|
|
|
51
55
|
## Protocol
|
package/bin/vue-grid-mcp.js
CHANGED
|
@@ -18,12 +18,17 @@ if (!command) {
|
|
|
18
18
|
const config = JSON.parse(readFileSync(arg === '-' ? 0 : arg, 'utf8'))
|
|
19
19
|
const { validateGridConfig } = await loadDocs()
|
|
20
20
|
const { ok, diagnostics } = validateGridConfig(config)
|
|
21
|
-
for (const d of diagnostics)
|
|
21
|
+
for (const d of diagnostics)
|
|
22
|
+
console.log(
|
|
23
|
+
`${d.severity.padEnd(7)} ${d.path || '(config)'}: ${d.message}${d.fix ? `\n fix: ${d.fix}` : ''}`,
|
|
24
|
+
)
|
|
22
25
|
console.log(ok ? `\nOK (${diagnostics.length} note(s))` : '\nNOT OK')
|
|
23
26
|
process.exit(ok ? 0 : 1)
|
|
24
27
|
} else if (command === 'guide') {
|
|
25
28
|
process.stdout.write((await loadDocs()).files['AGENTS.md'])
|
|
26
29
|
} else {
|
|
27
|
-
console.error(
|
|
30
|
+
console.error(
|
|
31
|
+
`unknown command "${command}" (commands: validate <file>, guide; none = MCP server)`,
|
|
32
|
+
)
|
|
28
33
|
process.exit(2)
|
|
29
34
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocopypaste/vue-grid-mcp",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.2",
|
|
4
4
|
"description": "MCP server for @nocopypaste/vue-grid: the grid's rules, API reference, renderer catalogue, doc search and a grid-config validator, as tools for coding agents. Zero dependencies besides the grid itself.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"test": "node --test"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@nocopypaste/vue-grid": "^0.3.
|
|
34
|
+
"@nocopypaste/vue-grid": "^0.3.2"
|
|
35
35
|
},
|
|
36
36
|
"repository": {
|
|
37
37
|
"type": "git",
|
package/src/docs.js
CHANGED
|
@@ -15,7 +15,9 @@ function locateGrid(cwd) {
|
|
|
15
15
|
// not installed there
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
|
-
throw new Error(
|
|
18
|
+
throw new Error(
|
|
19
|
+
'@nocopypaste/vue-grid is not installed (it is a dependency of this server: reinstall it).',
|
|
20
|
+
)
|
|
19
21
|
}
|
|
20
22
|
|
|
21
23
|
/** Splits Markdown into `## ` / `### ` sections for search. */
|
package/src/server.js
CHANGED
|
@@ -21,7 +21,8 @@ const INSTRUCTIONS =
|
|
|
21
21
|
export async function handle(message, docs, version) {
|
|
22
22
|
const { id, method, params = {} } = message
|
|
23
23
|
const reply = (result) => (id === undefined ? undefined : { jsonrpc: '2.0', id, result })
|
|
24
|
-
const fail = (code, msg) =>
|
|
24
|
+
const fail = (code, msg) =>
|
|
25
|
+
id === undefined ? undefined : { jsonrpc: '2.0', id, error: { code, message: msg } }
|
|
25
26
|
try {
|
|
26
27
|
switch (method) {
|
|
27
28
|
case 'initialize': {
|
|
@@ -37,7 +38,13 @@ export async function handle(message, docs, version) {
|
|
|
37
38
|
return reply({})
|
|
38
39
|
case 'tools/list':
|
|
39
40
|
return reply({
|
|
40
|
-
tools: tools.map(({ name, title, description, inputSchema, annotations }) => ({
|
|
41
|
+
tools: tools.map(({ name, title, description, inputSchema, annotations }) => ({
|
|
42
|
+
name,
|
|
43
|
+
title,
|
|
44
|
+
description,
|
|
45
|
+
inputSchema,
|
|
46
|
+
annotations,
|
|
47
|
+
})),
|
|
41
48
|
})
|
|
42
49
|
case 'tools/call': {
|
|
43
50
|
const tool = tools.find((t) => t.name === params.name)
|
|
@@ -47,12 +54,20 @@ export async function handle(message, docs, version) {
|
|
|
47
54
|
return reply({ content: [{ type: 'text', text }] })
|
|
48
55
|
} catch (error) {
|
|
49
56
|
// tool errors are results the model can read and act on, not protocol errors
|
|
50
|
-
return reply({
|
|
57
|
+
return reply({
|
|
58
|
+
content: [{ type: 'text', text: String(error?.message ?? error) }],
|
|
59
|
+
isError: true,
|
|
60
|
+
})
|
|
51
61
|
}
|
|
52
62
|
}
|
|
53
63
|
case 'resources/list':
|
|
54
64
|
return reply({
|
|
55
|
-
resources: resources(docs).map(({ uri, name, title, mimeType }) => ({
|
|
65
|
+
resources: resources(docs).map(({ uri, name, title, mimeType }) => ({
|
|
66
|
+
uri,
|
|
67
|
+
name,
|
|
68
|
+
title,
|
|
69
|
+
mimeType,
|
|
70
|
+
})),
|
|
56
71
|
})
|
|
57
72
|
case 'resources/read': {
|
|
58
73
|
const r = resources(docs).find((x) => x.uri === params.uri)
|
|
@@ -73,7 +88,11 @@ export async function handle(message, docs, version) {
|
|
|
73
88
|
}
|
|
74
89
|
|
|
75
90
|
/** Runs the server on stdin / stdout. Logs go to stderr (stdout is the protocol). */
|
|
76
|
-
export async function serve({
|
|
91
|
+
export async function serve({
|
|
92
|
+
input = process.stdin,
|
|
93
|
+
output = process.stdout,
|
|
94
|
+
cwd = process.cwd(),
|
|
95
|
+
} = {}) {
|
|
77
96
|
const docs = await loadDocs(cwd)
|
|
78
97
|
const version = docs.version
|
|
79
98
|
process.stderr.write(`[vue-grid-mcp] @nocopypaste/vue-grid ${version} from ${docs.dir}\n`)
|
|
@@ -84,7 +103,13 @@ export async function serve({ input = process.stdin, output = process.stdout, cw
|
|
|
84
103
|
try {
|
|
85
104
|
message = JSON.parse(line)
|
|
86
105
|
} catch {
|
|
87
|
-
output.write(
|
|
106
|
+
output.write(
|
|
107
|
+
JSON.stringify({
|
|
108
|
+
jsonrpc: '2.0',
|
|
109
|
+
id: null,
|
|
110
|
+
error: { code: -32700, message: 'Parse error' },
|
|
111
|
+
}) + '\n',
|
|
112
|
+
)
|
|
88
113
|
continue
|
|
89
114
|
}
|
|
90
115
|
const batch = Array.isArray(message) ? message : [message]
|
package/src/tools.js
CHANGED
|
@@ -1,11 +1,24 @@
|
|
|
1
1
|
// The MCP tools: what each does, its input schema, and its handler (docs → text).
|
|
2
2
|
|
|
3
|
-
const SECTIONS = [
|
|
3
|
+
const SECTIONS = [
|
|
4
|
+
'props',
|
|
5
|
+
'models',
|
|
6
|
+
'events',
|
|
7
|
+
'slots',
|
|
8
|
+
'methods',
|
|
9
|
+
'column',
|
|
10
|
+
'features',
|
|
11
|
+
'renderers',
|
|
12
|
+
'types',
|
|
13
|
+
]
|
|
4
14
|
const json = (value) => JSON.stringify(value, null, 2)
|
|
5
15
|
|
|
6
16
|
/** Search: score sections by query terms in title (×3) and body. */
|
|
7
17
|
function search(docs, query, limit) {
|
|
8
|
-
const terms = query
|
|
18
|
+
const terms = query
|
|
19
|
+
.toLowerCase()
|
|
20
|
+
.split(/[^\p{L}\p{N}_-]+/u)
|
|
21
|
+
.filter((t) => t.length > 1)
|
|
9
22
|
if (!terms.length) return []
|
|
10
23
|
return docs.sections
|
|
11
24
|
.map((s) => {
|
|
@@ -27,11 +40,21 @@ function search(docs, query, limit) {
|
|
|
27
40
|
}
|
|
28
41
|
|
|
29
42
|
function findMember(api, section, name) {
|
|
30
|
-
const list =
|
|
31
|
-
|
|
43
|
+
const list =
|
|
44
|
+
section === 'types'
|
|
45
|
+
? Object.entries(api.types).map(([n, members]) => ({ name: n, members }))
|
|
46
|
+
: api[section]
|
|
47
|
+
const lower = name
|
|
48
|
+
.toLowerCase()
|
|
49
|
+
.replace(/^v-model:/, '')
|
|
50
|
+
.replace(/-(\w)/g, (_, c) => c.toUpperCase())
|
|
32
51
|
return list.filter((m) => {
|
|
33
52
|
const n = String(m.name ?? m.id).toLowerCase()
|
|
34
|
-
return
|
|
53
|
+
return (
|
|
54
|
+
n === lower.toLowerCase() ||
|
|
55
|
+
n === name.toLowerCase() ||
|
|
56
|
+
String(m.export ?? '').toLowerCase() === name.toLowerCase()
|
|
57
|
+
)
|
|
35
58
|
})
|
|
36
59
|
}
|
|
37
60
|
|
|
@@ -54,7 +77,11 @@ export const tools = [
|
|
|
54
77
|
type: 'object',
|
|
55
78
|
properties: {
|
|
56
79
|
section: { type: 'string', enum: SECTIONS, description: 'Which part of the API.' },
|
|
57
|
-
name: {
|
|
80
|
+
name: {
|
|
81
|
+
type: 'string',
|
|
82
|
+
description:
|
|
83
|
+
'One entry: a prop, event, slot, method, column option, feature id / export, renderer name / export or type name.',
|
|
84
|
+
},
|
|
58
85
|
},
|
|
59
86
|
additionalProperties: false,
|
|
60
87
|
},
|
|
@@ -66,19 +93,29 @@ export const tools = [
|
|
|
66
93
|
package: api.package,
|
|
67
94
|
version: api.version,
|
|
68
95
|
sections: Object.fromEntries(
|
|
69
|
-
SECTIONS.map((s) => [
|
|
96
|
+
SECTIONS.map((s) => [
|
|
97
|
+
s,
|
|
98
|
+
s === 'types' ? Object.keys(api.types) : api[s].map((m) => m.export ?? m.name),
|
|
99
|
+
]),
|
|
70
100
|
),
|
|
71
101
|
hint: 'Call again with section (and name) for details.',
|
|
72
102
|
})
|
|
73
103
|
}
|
|
74
104
|
if (!section) {
|
|
75
|
-
const hits = SECTIONS.flatMap((s) =>
|
|
76
|
-
|
|
105
|
+
const hits = SECTIONS.flatMap((s) =>
|
|
106
|
+
findMember(api, s, name).map((m) => ({ section: s, ...m })),
|
|
107
|
+
)
|
|
108
|
+
return hits.length
|
|
109
|
+
? json(hits)
|
|
110
|
+
: `Nothing named "${name}". Call without arguments for the index.`
|
|
77
111
|
}
|
|
78
|
-
if (!SECTIONS.includes(section))
|
|
112
|
+
if (!SECTIONS.includes(section))
|
|
113
|
+
throw new Error(`Unknown section "${section}". Use one of: ${SECTIONS.join(', ')}.`)
|
|
79
114
|
if (!name) return json(section === 'types' ? api.types : api[section])
|
|
80
115
|
const hits = findMember(api, section, name)
|
|
81
|
-
return hits.length
|
|
116
|
+
return hits.length
|
|
117
|
+
? json(hits.length === 1 ? hits[0] : hits)
|
|
118
|
+
: `No ${section} entry named "${name}". Call with section "${section}" alone to list them.`
|
|
82
119
|
},
|
|
83
120
|
},
|
|
84
121
|
{
|
|
@@ -88,7 +125,9 @@ export const tools = [
|
|
|
88
125
|
'A cell renderer by name or export (e.g. "currency" or "currencyRenderer"): what it shows, its alignment and filter type, every rendererOption with its type and meaning, and a column example. Without a name, lists all renderers with one-line descriptions so you can pick by data type.',
|
|
89
126
|
inputSchema: {
|
|
90
127
|
type: 'object',
|
|
91
|
-
properties: {
|
|
128
|
+
properties: {
|
|
129
|
+
name: { type: 'string', description: 'Renderer name or export name. Omit to list all.' },
|
|
130
|
+
},
|
|
92
131
|
additionalProperties: false,
|
|
93
132
|
},
|
|
94
133
|
annotations: { readOnlyHint: true },
|
|
@@ -98,8 +137,12 @@ export const tools = [
|
|
|
98
137
|
const key = name.toLowerCase()
|
|
99
138
|
const r = list.find((x) => x.name === key || x.export.toLowerCase() === key)
|
|
100
139
|
if (!r) {
|
|
101
|
-
const near = list
|
|
102
|
-
|
|
140
|
+
const near = list
|
|
141
|
+
.filter((x) => x.name.includes(key) || key.includes(x.name))
|
|
142
|
+
.map((x) => x.name)
|
|
143
|
+
throw new Error(
|
|
144
|
+
`Unknown renderer "${name}".${near.length ? ` Did you mean ${near.join(', ')}?` : ''} Call without a name to list them.`,
|
|
145
|
+
)
|
|
103
146
|
}
|
|
104
147
|
const example = `import { ${r.export} } from '@nocopypaste/vue-grid'\n\ncol({ key: '…', renderer: ${r.export}${r.options[0] ? `, rendererOptions: { ${r.options[0].name}: … }` : ''} })`
|
|
105
148
|
return `${json(r)}\n\nExample:\n${example}`
|
|
@@ -122,7 +165,8 @@ export const tools = [
|
|
|
122
165
|
annotations: { readOnlyHint: true },
|
|
123
166
|
run: (docs, { query, limit = 4 }) => {
|
|
124
167
|
const hits = search(docs, String(query), Math.min(Math.max(1, Number(limit) || 4), 10))
|
|
125
|
-
if (!hits.length)
|
|
168
|
+
if (!hits.length)
|
|
169
|
+
return `No section matches "${query}". Try other words, or vue_grid_api for exact names.`
|
|
126
170
|
return hits.map((s) => `<!-- ${s.source} → ${s.title} -->\n${s.text}`).join('\n\n---\n\n')
|
|
127
171
|
},
|
|
128
172
|
},
|
|
@@ -136,7 +180,8 @@ export const tools = [
|
|
|
136
180
|
properties: {
|
|
137
181
|
config: {
|
|
138
182
|
type: 'object',
|
|
139
|
-
description:
|
|
183
|
+
description:
|
|
184
|
+
'The grid config: { rowKey, columns: [...], features: [...], renderers?: [...], ...props }.',
|
|
140
185
|
},
|
|
141
186
|
},
|
|
142
187
|
required: ['config'],
|
|
@@ -145,16 +190,48 @@ export const tools = [
|
|
|
145
190
|
annotations: { readOnlyHint: true },
|
|
146
191
|
run: (docs, { config }) => {
|
|
147
192
|
const result = docs.validateGridConfig(config)
|
|
148
|
-
const counts = ['error', 'warning', 'info'].map(
|
|
193
|
+
const counts = ['error', 'warning', 'info'].map(
|
|
194
|
+
(s) => `${result.diagnostics.filter((d) => d.severity === s).length} ${s}(s)`,
|
|
195
|
+
)
|
|
149
196
|
return `${result.ok ? 'OK' : 'NOT OK'}: ${counts.join(', ')}\n\n${json(result.diagnostics)}`
|
|
150
197
|
},
|
|
151
198
|
},
|
|
152
199
|
]
|
|
153
200
|
|
|
154
201
|
export const resources = (docs) => [
|
|
155
|
-
{
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
202
|
+
{
|
|
203
|
+
uri: 'vue-grid://AGENTS.md',
|
|
204
|
+
name: 'AGENTS.md',
|
|
205
|
+
title: 'vue-grid guide for coding agents',
|
|
206
|
+
mimeType: 'text/markdown',
|
|
207
|
+
text: () => docs.files['AGENTS.md'],
|
|
208
|
+
},
|
|
209
|
+
{
|
|
210
|
+
uri: 'vue-grid://api.md',
|
|
211
|
+
name: 'api.md',
|
|
212
|
+
title: 'vue-grid API reference',
|
|
213
|
+
mimeType: 'text/markdown',
|
|
214
|
+
text: () => docs.files['agent/api.md'],
|
|
215
|
+
},
|
|
216
|
+
{
|
|
217
|
+
uri: 'vue-grid://README.md',
|
|
218
|
+
name: 'README.md',
|
|
219
|
+
title: 'vue-grid README',
|
|
220
|
+
mimeType: 'text/markdown',
|
|
221
|
+
text: () => docs.files['README.md'],
|
|
222
|
+
},
|
|
223
|
+
{
|
|
224
|
+
uri: 'vue-grid://api.json',
|
|
225
|
+
name: 'api.json',
|
|
226
|
+
title: 'vue-grid API reference (JSON)',
|
|
227
|
+
mimeType: 'application/json',
|
|
228
|
+
text: () => JSON.stringify(docs.api, null, 2),
|
|
229
|
+
},
|
|
230
|
+
{
|
|
231
|
+
uri: 'vue-grid://grid-config.schema.json',
|
|
232
|
+
name: 'grid-config.schema.json',
|
|
233
|
+
title: 'JSON Schema of a grid config',
|
|
234
|
+
mimeType: 'application/schema+json',
|
|
235
|
+
text: () => docs.schema,
|
|
236
|
+
},
|
|
160
237
|
]
|