@nocopypaste/vue-grid-mcp 0.0.0-stage → 0.3.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 CHANGED
@@ -1,3 +1,54 @@
1
- # Temporary Holding Version
1
+ # @nocopypaste/vue-grid-mcp
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ An [MCP](https://modelcontextprotocol.io) server that gives coding agents the exact API of
4
+ [`@nocopypaste/vue-grid`](../vue-grid) — so they register the right features, use real option names
5
+ and check their grid config instead of guessing. No dependencies besides the grid itself.
6
+
7
+ When it runs inside a project that has `@nocopypaste/vue-grid` installed, it answers from that copy, so
8
+ the docs match the version you use.
9
+
10
+ ## Add it
11
+
12
+ Claude Code (or use the [plugin](../../plugins/vue-grid), which adds this server and a skill):
13
+
14
+ ```sh
15
+ claude mcp add vue-grid -- npx -y @nocopypaste/vue-grid-mcp
16
+ ```
17
+
18
+ Any MCP client (Cursor, VS Code, Windsurf, Claude Desktop…):
19
+
20
+ ```json
21
+ { "mcpServers": { "vue-grid": { "command": "npx", "args": ["-y", "@nocopypaste/vue-grid-mcp"] } } }
22
+ ```
23
+
24
+ ## Tools
25
+
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
+
34
+ Resources: `vue-grid://AGENTS.md`, `vue-grid://api.md`, `vue-grid://README.md`,
35
+ `vue-grid://api.json`, `vue-grid://grid-config.schema.json`.
36
+
37
+ ## CLI
38
+
39
+ ```sh
40
+ npx @nocopypaste/vue-grid-mcp validate grid.json # diagnostics; exit 1 on errors ("-" reads stdin)
41
+ npx @nocopypaste/vue-grid-mcp guide # print AGENTS.md
42
+ ```
43
+
44
+ `grid.json` is the grid as data, e.g.:
45
+
46
+ ```json
47
+ { "rowKey": "id", "features": ["sortingFeature"], "sortMode": "client",
48
+ "columns": [{ "key": "total", "renderer": "currencyRenderer", "sortable": true }] }
49
+ ```
50
+
51
+ ## Protocol
52
+
53
+ stdio, JSON-RPC 2.0, MCP `2025-06-18` (also `2025-03-26`, `2024-11-05`): `initialize`, `ping`,
54
+ `tools/list`, `tools/call`, `resources/list`, `resources/read`. All tools are read-only.
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env node
2
+ // vue-grid-mcp run the MCP server on stdio (for Claude Code, Cursor, …)
3
+ // vue-grid-mcp validate <file> check a grid config (JSON) and print its diagnostics; exit 1 on errors
4
+ // vue-grid-mcp guide print AGENTS.md of the installed @nocopypaste/vue-grid
5
+ import { readFileSync } from 'node:fs'
6
+ import { loadDocs } from '../src/docs.js'
7
+ import { serve } from '../src/server.js'
8
+
9
+ const [command, arg] = process.argv.slice(2)
10
+
11
+ if (!command) {
12
+ await serve()
13
+ } else if (command === 'validate') {
14
+ if (!arg) {
15
+ console.error('usage: vue-grid-mcp validate <config.json> ("-" reads stdin)')
16
+ process.exit(2)
17
+ }
18
+ const config = JSON.parse(readFileSync(arg === '-' ? 0 : arg, 'utf8'))
19
+ const { validateGridConfig } = await loadDocs()
20
+ const { ok, diagnostics } = validateGridConfig(config)
21
+ for (const d of diagnostics) console.log(`${d.severity.padEnd(7)} ${d.path || '(config)'}: ${d.message}${d.fix ? `\n fix: ${d.fix}` : ''}`)
22
+ console.log(ok ? `\nOK (${diagnostics.length} note(s))` : '\nNOT OK')
23
+ process.exit(ok ? 0 : 1)
24
+ } else if (command === 'guide') {
25
+ process.stdout.write((await loadDocs()).files['AGENTS.md'])
26
+ } else {
27
+ console.error(`unknown command "${command}" (commands: validate <file>, guide; none = MCP server)`)
28
+ process.exit(2)
29
+ }
package/package.json CHANGED
@@ -1,6 +1,46 @@
1
1
  {
2
2
  "name": "@nocopypaste/vue-grid-mcp",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.3.0",
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
+ "license": "MIT",
6
+ "type": "module",
7
+ "keywords": [
8
+ "mcp",
9
+ "model-context-protocol",
10
+ "vue-grid",
11
+ "vue",
12
+ "data-grid",
13
+ "agents",
14
+ "claude"
15
+ ],
16
+ "bin": {
17
+ "vue-grid-mcp": "bin/vue-grid-mcp.js"
18
+ },
19
+ "files": [
20
+ "bin",
21
+ "src",
22
+ "README.md"
23
+ ],
24
+ "exports": {
25
+ ".": "./src/server.js"
26
+ },
27
+ "engines": {
28
+ "node": ">=20"
29
+ },
30
+ "scripts": {
31
+ "test": "node --test"
32
+ },
33
+ "dependencies": {
34
+ "@nocopypaste/vue-grid": "^0.3.0"
35
+ },
36
+ "repository": {
37
+ "type": "git",
38
+ "url": "git+https://github.com/eboye/eboye-vue-grid.git",
39
+ "directory": "packages/vue-grid-mcp"
40
+ },
41
+ "homepage": "https://github.com/eboye/eboye-vue-grid/tree/main/packages/vue-grid-mcp#readme",
42
+ "bugs": {
43
+ "url": "https://github.com/eboye/eboye-vue-grid/issues"
44
+ },
45
+ "author": "eboye"
46
+ }
package/src/docs.js ADDED
@@ -0,0 +1,58 @@
1
+ // Loads the grid's agent docs and API reference — from the project's own @nocopypaste/vue-grid when the
2
+ // server runs inside a project that has it (so answers match the installed version), else from
3
+ // this package's dependency.
4
+ import { readFileSync } from 'node:fs'
5
+ import { createRequire } from 'node:module'
6
+ import { dirname, join } from 'node:path'
7
+ import { pathToFileURL } from 'node:url'
8
+
9
+ function locateGrid(cwd) {
10
+ for (const base of [join(cwd, 'package.json'), import.meta.url]) {
11
+ try {
12
+ const require = createRequire(base)
13
+ return dirname(require.resolve('@nocopypaste/vue-grid/package.json'))
14
+ } catch {
15
+ // not installed there
16
+ }
17
+ }
18
+ throw new Error('@nocopypaste/vue-grid is not installed (it is a dependency of this server: reinstall it).')
19
+ }
20
+
21
+ /** Splits Markdown into `## ` / `### ` sections for search. */
22
+ function sections(source, text) {
23
+ const out = []
24
+ let current = { source, title: source, level: 1, lines: [] }
25
+ let inFence = false
26
+ for (const line of text.split('\n')) {
27
+ if (line.startsWith('```')) inFence = !inFence
28
+ const h = !inFence && /^(#{1,4}) (.+)$/.exec(line)
29
+ if (h) {
30
+ if (current.lines.length) out.push(current)
31
+ current = { source, title: h[2].trim(), level: h[1].length, lines: [line] }
32
+ } else current.lines.push(line)
33
+ }
34
+ if (current.lines.length) out.push(current)
35
+ return out.map((s) => ({ source: s.source, title: s.title, text: s.lines.join('\n').trim() }))
36
+ }
37
+
38
+ export async function loadDocs(cwd = process.cwd()) {
39
+ const dir = locateGrid(cwd)
40
+ const read = (rel) => readFileSync(join(dir, rel), 'utf8')
41
+ const pkg = JSON.parse(read('package.json'))
42
+ const api = JSON.parse(read('agent/api.json'))
43
+ const { validateGridConfig } = await import(pathToFileURL(join(dir, 'dist/agent/index.js')).href)
44
+ const files = {
45
+ 'AGENTS.md': read('AGENTS.md'),
46
+ 'agent/api.md': read('agent/api.md'),
47
+ 'README.md': read('README.md'),
48
+ }
49
+ return {
50
+ dir,
51
+ version: pkg.version,
52
+ api,
53
+ files,
54
+ schema: read('agent/grid-config.schema.json'),
55
+ validateGridConfig,
56
+ sections: Object.entries(files).flatMap(([name, text]) => sections(name, text)),
57
+ }
58
+ }
package/src/server.js ADDED
@@ -0,0 +1,96 @@
1
+ // A Model Context Protocol server over stdio (newline-delimited JSON-RPC 2.0), with no SDK: the
2
+ // protocol surface a docs-and-validation server needs is small — initialize, ping, tools and
3
+ // resources — so it ships without dependencies besides @nocopypaste/vue-grid itself.
4
+ import { createInterface } from 'node:readline'
5
+ import { loadDocs } from './docs.js'
6
+ import { resources, tools } from './tools.js'
7
+
8
+ const SUPPORTED = ['2025-06-18', '2025-03-26', '2024-11-05']
9
+ const NAME = 'vue-grid'
10
+
11
+ const INSTRUCTIONS =
12
+ 'Tools for @nocopypaste/vue-grid (<VGrid>, a Vue 3 data grid). Before writing or editing grid code, call ' +
13
+ 'vue_grid_guide once (rules + recipes). Look up exact props / column options / renderer options with ' +
14
+ 'vue_grid_api and vue_grid_renderer instead of guessing, and run vue_grid_validate on the grid config ' +
15
+ 'you wrote: options whose feature is not registered silently do nothing.'
16
+
17
+ /**
18
+ * Handles one JSON-RPC message; returns the response (or undefined for notifications).
19
+ * Exported for tests.
20
+ */
21
+ export async function handle(message, docs, version) {
22
+ const { id, method, params = {} } = message
23
+ const reply = (result) => (id === undefined ? undefined : { jsonrpc: '2.0', id, result })
24
+ const fail = (code, msg) => (id === undefined ? undefined : { jsonrpc: '2.0', id, error: { code, message: msg } })
25
+ try {
26
+ switch (method) {
27
+ case 'initialize': {
28
+ const requested = params.protocolVersion
29
+ return reply({
30
+ protocolVersion: SUPPORTED.includes(requested) ? requested : SUPPORTED[0],
31
+ capabilities: { tools: { listChanged: false }, resources: { listChanged: false } },
32
+ serverInfo: { name: NAME, title: '@nocopypaste/vue-grid', version },
33
+ instructions: INSTRUCTIONS,
34
+ })
35
+ }
36
+ case 'ping':
37
+ return reply({})
38
+ case 'tools/list':
39
+ return reply({
40
+ tools: tools.map(({ name, title, description, inputSchema, annotations }) => ({ name, title, description, inputSchema, annotations })),
41
+ })
42
+ case 'tools/call': {
43
+ const tool = tools.find((t) => t.name === params.name)
44
+ if (!tool) return fail(-32602, `Unknown tool: ${params.name}`)
45
+ try {
46
+ const text = await tool.run(docs, params.arguments ?? {})
47
+ return reply({ content: [{ type: 'text', text }] })
48
+ } catch (error) {
49
+ // tool errors are results the model can read and act on, not protocol errors
50
+ return reply({ content: [{ type: 'text', text: String(error?.message ?? error) }], isError: true })
51
+ }
52
+ }
53
+ case 'resources/list':
54
+ return reply({
55
+ resources: resources(docs).map(({ uri, name, title, mimeType }) => ({ uri, name, title, mimeType })),
56
+ })
57
+ case 'resources/read': {
58
+ const r = resources(docs).find((x) => x.uri === params.uri)
59
+ if (!r) return fail(-32602, `Unknown resource: ${params.uri}`)
60
+ return reply({ contents: [{ uri: r.uri, mimeType: r.mimeType, text: r.text() }] })
61
+ }
62
+ case 'resources/templates/list':
63
+ return reply({ resourceTemplates: [] })
64
+ case 'prompts/list':
65
+ return reply({ prompts: [] })
66
+ default:
67
+ if (method?.startsWith('notifications/')) return undefined
68
+ return fail(-32601, `Method not found: ${method}`)
69
+ }
70
+ } catch (error) {
71
+ return fail(-32603, String(error?.message ?? error))
72
+ }
73
+ }
74
+
75
+ /** Runs the server on stdin / stdout. Logs go to stderr (stdout is the protocol). */
76
+ export async function serve({ input = process.stdin, output = process.stdout, cwd = process.cwd() } = {}) {
77
+ const docs = await loadDocs(cwd)
78
+ const version = docs.version
79
+ process.stderr.write(`[vue-grid-mcp] @nocopypaste/vue-grid ${version} from ${docs.dir}\n`)
80
+ const lines = createInterface({ input, crlfDelay: Infinity })
81
+ for await (const line of lines) {
82
+ if (!line.trim()) continue
83
+ let message
84
+ try {
85
+ message = JSON.parse(line)
86
+ } catch {
87
+ output.write(JSON.stringify({ jsonrpc: '2.0', id: null, error: { code: -32700, message: 'Parse error' } }) + '\n')
88
+ continue
89
+ }
90
+ const batch = Array.isArray(message) ? message : [message]
91
+ for (const m of batch) {
92
+ const response = await handle(m, docs, version)
93
+ if (response) output.write(JSON.stringify(response) + '\n')
94
+ }
95
+ }
96
+ }
package/src/tools.js ADDED
@@ -0,0 +1,160 @@
1
+ // The MCP tools: what each does, its input schema, and its handler (docs → text).
2
+
3
+ const SECTIONS = ['props', 'models', 'events', 'slots', 'methods', 'column', 'features', 'renderers', 'types']
4
+ const json = (value) => JSON.stringify(value, null, 2)
5
+
6
+ /** Search: score sections by query terms in title (×3) and body. */
7
+ function search(docs, query, limit) {
8
+ const terms = query.toLowerCase().split(/[^\p{L}\p{N}_-]+/u).filter((t) => t.length > 1)
9
+ if (!terms.length) return []
10
+ return docs.sections
11
+ .map((s) => {
12
+ const title = s.title.toLowerCase()
13
+ const body = s.text.toLowerCase()
14
+ let score = 0
15
+ for (const t of terms) {
16
+ if (title.includes(t)) score += 3
17
+ score += Math.min(body.split(t).length - 1, 5)
18
+ }
19
+ // prefer the agent guide and the generated reference over README prose on ties
20
+ if (score > 0 && s.source === 'AGENTS.md') score += 0.5
21
+ return { s, score }
22
+ })
23
+ .filter((x) => x.score > 0)
24
+ .sort((a, b) => b.score - a.score)
25
+ .slice(0, limit)
26
+ .map(({ s }) => s)
27
+ }
28
+
29
+ function findMember(api, section, name) {
30
+ const list = section === 'types' ? Object.entries(api.types).map(([n, members]) => ({ name: n, members })) : api[section]
31
+ const lower = name.toLowerCase().replace(/^v-model:/, '').replace(/-(\w)/g, (_, c) => c.toUpperCase())
32
+ return list.filter((m) => {
33
+ const n = String(m.name ?? m.id).toLowerCase()
34
+ return n === lower.toLowerCase() || n === name.toLowerCase() || String(m.export ?? '').toLowerCase() === name.toLowerCase()
35
+ })
36
+ }
37
+
38
+ export const tools = [
39
+ {
40
+ name: 'vue_grid_guide',
41
+ title: 'vue-grid: rules and recipes',
42
+ description:
43
+ 'Start here before writing or changing <VGrid> code. Returns AGENTS.md for the installed @nocopypaste/vue-grid: the rules that cause silent bugs when skipped (register features, pass renderer definitions, sort-mode="client", bounded height), which feature / renderer to use for what, copy-paste recipes and pitfalls.',
44
+ inputSchema: { type: 'object', properties: {}, additionalProperties: false },
45
+ annotations: { readOnlyHint: true },
46
+ run: (docs) => docs.files['AGENTS.md'],
47
+ },
48
+ {
49
+ name: 'vue_grid_api',
50
+ title: 'vue-grid: API reference lookup',
51
+ description:
52
+ 'Exact API of <VGrid>, generated from the sources: props, v-models, events, slots, exposed methods, ColumnDef options, features (with the props / options each enables) and renderers (with every option), or the named types. Give `section` alone for the whole section, add `name` for one entry (e.g. section "column", name "aggregate"; section "props", name "virtual"; section "types", name "VirtualOptions"). With neither, returns an index.',
53
+ inputSchema: {
54
+ type: 'object',
55
+ properties: {
56
+ section: { type: 'string', enum: SECTIONS, description: 'Which part of the API.' },
57
+ name: { type: 'string', description: 'One entry: a prop, event, slot, method, column option, feature id / export, renderer name / export or type name.' },
58
+ },
59
+ additionalProperties: false,
60
+ },
61
+ annotations: { readOnlyHint: true },
62
+ run: (docs, { section, name }) => {
63
+ const { api } = docs
64
+ if (!section && !name) {
65
+ return json({
66
+ package: api.package,
67
+ version: api.version,
68
+ sections: Object.fromEntries(
69
+ SECTIONS.map((s) => [s, s === 'types' ? Object.keys(api.types) : api[s].map((m) => m.export ?? m.name)]),
70
+ ),
71
+ hint: 'Call again with section (and name) for details.',
72
+ })
73
+ }
74
+ if (!section) {
75
+ const hits = SECTIONS.flatMap((s) => findMember(api, s, name).map((m) => ({ section: s, ...m })))
76
+ return hits.length ? json(hits) : `Nothing named "${name}". Call without arguments for the index.`
77
+ }
78
+ if (!SECTIONS.includes(section)) throw new Error(`Unknown section "${section}". Use one of: ${SECTIONS.join(', ')}.`)
79
+ if (!name) return json(section === 'types' ? api.types : api[section])
80
+ const hits = findMember(api, section, name)
81
+ return hits.length ? json(hits.length === 1 ? hits[0] : hits) : `No ${section} entry named "${name}". Call with section "${section}" alone to list them.`
82
+ },
83
+ },
84
+ {
85
+ name: 'vue_grid_renderer',
86
+ title: 'vue-grid: renderer details',
87
+ description:
88
+ '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
+ inputSchema: {
90
+ type: 'object',
91
+ properties: { name: { type: 'string', description: 'Renderer name or export name. Omit to list all.' } },
92
+ additionalProperties: false,
93
+ },
94
+ annotations: { readOnlyHint: true },
95
+ run: (docs, { name }) => {
96
+ const list = docs.api.renderers
97
+ if (!name) return list.map((r) => `- ${r.name} (${r.export}): ${r.description}`).join('\n')
98
+ const key = name.toLowerCase()
99
+ const r = list.find((x) => x.name === key || x.export.toLowerCase() === key)
100
+ if (!r) {
101
+ const near = list.filter((x) => x.name.includes(key) || key.includes(x.name)).map((x) => x.name)
102
+ throw new Error(`Unknown renderer "${name}".${near.length ? ` Did you mean ${near.join(', ')}?` : ''} Call without a name to list them.`)
103
+ }
104
+ const example = `import { ${r.export} } from '@nocopypaste/vue-grid'\n\ncol({ key: '…', renderer: ${r.export}${r.options[0] ? `, rendererOptions: { ${r.options[0].name}: … }` : ''} })`
105
+ return `${json(r)}\n\nExample:\n${example}`
106
+ },
107
+ },
108
+ {
109
+ name: 'vue_grid_search_docs',
110
+ title: 'vue-grid: search the docs',
111
+ description:
112
+ 'Full-text search over the agent guide, the generated API reference and the README of the installed @nocopypaste/vue-grid. Returns the best matching sections in full (e.g. "lazy sub rows retry", "server data total", "theme dark mode tokens", "keyboard shortcuts").',
113
+ inputSchema: {
114
+ type: 'object',
115
+ properties: {
116
+ query: { type: 'string', description: 'What to look for.' },
117
+ limit: { type: 'number', description: 'Sections to return (default 4, max 10).' },
118
+ },
119
+ required: ['query'],
120
+ additionalProperties: false,
121
+ },
122
+ annotations: { readOnlyHint: true },
123
+ run: (docs, { query, limit = 4 }) => {
124
+ const hits = search(docs, String(query), Math.min(Math.max(1, Number(limit) || 4), 10))
125
+ if (!hits.length) return `No section matches "${query}". Try other words, or vue_grid_api for exact names.`
126
+ return hits.map((s) => `<!-- ${s.source} → ${s.title} -->\n${s.text}`).join('\n\n---\n\n')
127
+ },
128
+ },
129
+ {
130
+ name: 'vue_grid_validate',
131
+ title: 'vue-grid: validate a grid config',
132
+ description:
133
+ 'Checks a <VGrid> setup before you write or after you change it: pass its props (camelCase or kebab-case; "v-model:", ":" and "@" prefixes accepted), `columns`, and the `features` / `renderers` registered for it (per grid and app-wide together) as export names, e.g. ["sortingFeature"], ["currencyRenderer"]. Functions can be given as strings ("(row) => row.id"). Returns each problem with severity, path and the fix: unknown props / options (with did-you-mean), options whose feature is missing, unknown or unregistered renderers and options, wrong types and enums, and combinations that silently do nothing.',
134
+ inputSchema: {
135
+ type: 'object',
136
+ properties: {
137
+ config: {
138
+ type: 'object',
139
+ description: 'The grid config: { rowKey, columns: [...], features: [...], renderers?: [...], ...props }.',
140
+ },
141
+ },
142
+ required: ['config'],
143
+ additionalProperties: false,
144
+ },
145
+ annotations: { readOnlyHint: true },
146
+ run: (docs, { config }) => {
147
+ const result = docs.validateGridConfig(config)
148
+ const counts = ['error', 'warning', 'info'].map((s) => `${result.diagnostics.filter((d) => d.severity === s).length} ${s}(s)`)
149
+ return `${result.ok ? 'OK' : 'NOT OK'}: ${counts.join(', ')}\n\n${json(result.diagnostics)}`
150
+ },
151
+ },
152
+ ]
153
+
154
+ export const resources = (docs) => [
155
+ { uri: 'vue-grid://AGENTS.md', name: 'AGENTS.md', title: 'vue-grid guide for coding agents', mimeType: 'text/markdown', text: () => docs.files['AGENTS.md'] },
156
+ { uri: 'vue-grid://api.md', name: 'api.md', title: 'vue-grid API reference', mimeType: 'text/markdown', text: () => docs.files['agent/api.md'] },
157
+ { uri: 'vue-grid://README.md', name: 'README.md', title: 'vue-grid README', mimeType: 'text/markdown', text: () => docs.files['README.md'] },
158
+ { uri: 'vue-grid://api.json', name: 'api.json', title: 'vue-grid API reference (JSON)', mimeType: 'application/json', text: () => JSON.stringify(docs.api, null, 2) },
159
+ { uri: 'vue-grid://grid-config.schema.json', name: 'grid-config.schema.json', title: 'JSON Schema of a grid config', mimeType: 'application/schema+json', text: () => docs.schema },
160
+ ]