@jotx-labs/mcp 2.4.246
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/__tests__/server.test.d.ts +2 -0
- package/dist/__tests__/server.test.d.ts.map +1 -0
- package/dist/__tests__/server.test.js +28 -0
- package/dist/__tests__/server.test.js.map +1 -0
- package/dist/__tests__/validation.test.d.ts +2 -0
- package/dist/__tests__/validation.test.d.ts.map +1 -0
- package/dist/__tests__/validation.test.js +25 -0
- package/dist/__tests__/validation.test.js.map +1 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +30 -0
- package/dist/index.js.map +1 -0
- package/dist/server.d.ts +35 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +131 -0
- package/dist/server.js.map +1 -0
- package/dist/syntax-guide.d.ts +19 -0
- package/dist/syntax-guide.d.ts.map +1 -0
- package/dist/syntax-guide.js +342 -0
- package/dist/syntax-guide.js.map +1 -0
- package/dist/tools/context-tools.d.ts +12 -0
- package/dist/tools/context-tools.d.ts.map +1 -0
- package/dist/tools/context-tools.js +82 -0
- package/dist/tools/context-tools.js.map +1 -0
- package/dist/tools/file-tools.d.ts +12 -0
- package/dist/tools/file-tools.d.ts.map +1 -0
- package/dist/tools/file-tools.js +150 -0
- package/dist/tools/file-tools.js.map +1 -0
- package/dist/tools/graph-tools.d.ts +12 -0
- package/dist/tools/graph-tools.d.ts.map +1 -0
- package/dist/tools/graph-tools.js +222 -0
- package/dist/tools/graph-tools.js.map +1 -0
- package/dist/tools/search-tools.d.ts +12 -0
- package/dist/tools/search-tools.d.ts.map +1 -0
- package/dist/tools/search-tools.js +63 -0
- package/dist/tools/search-tools.js.map +1 -0
- package/dist/tools/validation-tools.d.ts +12 -0
- package/dist/tools/validation-tools.d.ts.map +1 -0
- package/dist/tools/validation-tools.js +159 -0
- package/dist/tools/validation-tools.js.map +1 -0
- package/dist/types.d.ts +95 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +9 -0
- package/dist/types.js.map +1 -0
- package/package.json +40 -0
|
@@ -0,0 +1,342 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Syntax Guide — Jotx User Manual content loader
|
|
4
|
+
*
|
|
5
|
+
* Provides the Jotx syntax reference for AI consumption.
|
|
6
|
+
* Can load from a file path (provided by host app) or return
|
|
7
|
+
* a concise embedded reference.
|
|
8
|
+
*/
|
|
9
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
12
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
13
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
14
|
+
}
|
|
15
|
+
Object.defineProperty(o, k2, desc);
|
|
16
|
+
}) : (function(o, m, k, k2) {
|
|
17
|
+
if (k2 === undefined) k2 = k;
|
|
18
|
+
o[k2] = m[k];
|
|
19
|
+
}));
|
|
20
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
21
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
22
|
+
}) : function(o, v) {
|
|
23
|
+
o["default"] = v;
|
|
24
|
+
});
|
|
25
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
26
|
+
var ownKeys = function(o) {
|
|
27
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
28
|
+
var ar = [];
|
|
29
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
30
|
+
return ar;
|
|
31
|
+
};
|
|
32
|
+
return ownKeys(o);
|
|
33
|
+
};
|
|
34
|
+
return function (mod) {
|
|
35
|
+
if (mod && mod.__esModule) return mod;
|
|
36
|
+
var result = {};
|
|
37
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
38
|
+
__setModuleDefault(result, mod);
|
|
39
|
+
return result;
|
|
40
|
+
};
|
|
41
|
+
})();
|
|
42
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
43
|
+
exports.loadSyntaxGuide = loadSyntaxGuide;
|
|
44
|
+
exports.getSyntaxGuideByTopic = getSyntaxGuideByTopic;
|
|
45
|
+
const fs = __importStar(require("fs"));
|
|
46
|
+
/**
|
|
47
|
+
* Topic sections that can be extracted from the guide
|
|
48
|
+
*/
|
|
49
|
+
const TOPIC_KEYWORDS = {
|
|
50
|
+
headings: ['heading', 'level 1', 'level 2', 'level 3'],
|
|
51
|
+
lists: ['list', 'listtype', 'bulleted', 'numbered', 'listitem'],
|
|
52
|
+
checklists: ['checklist', 'taskitem', 'checked'],
|
|
53
|
+
code: ['code', 'language', 'codereference'],
|
|
54
|
+
charts: ['chart', 'charttype', 'json', 'bar', 'line', 'pie'],
|
|
55
|
+
math: ['math', 'src', 'display', 'LaTeX'],
|
|
56
|
+
mermaid: ['mermaid', 'flowchart', 'sequence'],
|
|
57
|
+
tables: ['table', 'columns', 'row', 'cell'],
|
|
58
|
+
images: ['image', 'floatimage', 'src', 'alt', 'caption'],
|
|
59
|
+
videos: ['video', 'youtube', 'local'],
|
|
60
|
+
callouts: ['callout', 'variant', 'info', 'warning', 'success', 'danger'],
|
|
61
|
+
navigation: ['button', 'gridcard', 'card', 'jotxlink', 'link'],
|
|
62
|
+
layout: ['columns', 'column', 'cols', 'section', 'toggle'],
|
|
63
|
+
properties: ['properties', 'property', 'key', 'value'],
|
|
64
|
+
presentations: ['slideproperties', 'theme', 'transition', 'divider'],
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* Embedded concise syntax reference.
|
|
68
|
+
* Used when no external file path is provided.
|
|
69
|
+
*/
|
|
70
|
+
const EMBEDDED_SYNTAX_REFERENCE = `# Jotx .jot File Syntax Reference
|
|
71
|
+
|
|
72
|
+
## File Structure
|
|
73
|
+
Every .jot file MUST start with a header definition:
|
|
74
|
+
\`\`\`
|
|
75
|
+
hdef jotx <DocumentId>
|
|
76
|
+
|
|
77
|
+
title "Document Title"
|
|
78
|
+
icon "📄"
|
|
79
|
+
type root
|
|
80
|
+
\`\`\`
|
|
81
|
+
|
|
82
|
+
## Block Syntax
|
|
83
|
+
All blocks use the pattern: \`def <blocktype> <unique_id>\`
|
|
84
|
+
Block IDs must be unique within a document (8-char alphanumeric recommended).
|
|
85
|
+
|
|
86
|
+
## Core Block Types
|
|
87
|
+
|
|
88
|
+
### Text Blocks
|
|
89
|
+
\`\`\`
|
|
90
|
+
def heading block_1
|
|
91
|
+
text "My Heading"
|
|
92
|
+
level 1
|
|
93
|
+
|
|
94
|
+
def paragraph block_2
|
|
95
|
+
text "Regular paragraph text with **bold** and *italic*."
|
|
96
|
+
|
|
97
|
+
def quote block_3
|
|
98
|
+
text "A blockquote"
|
|
99
|
+
\`\`\`
|
|
100
|
+
|
|
101
|
+
### Lists
|
|
102
|
+
\`\`\`
|
|
103
|
+
def list block_4
|
|
104
|
+
listtype bulleted
|
|
105
|
+
def listitem item_1
|
|
106
|
+
text "First item"
|
|
107
|
+
def listitem item_2
|
|
108
|
+
text "Second item"
|
|
109
|
+
|
|
110
|
+
def list block_5
|
|
111
|
+
listtype numbered
|
|
112
|
+
def listitem item_1
|
|
113
|
+
text "Step one"
|
|
114
|
+
\`\`\`
|
|
115
|
+
|
|
116
|
+
### Checklists
|
|
117
|
+
\`\`\`
|
|
118
|
+
def checklist block_6
|
|
119
|
+
def taskitem task_1
|
|
120
|
+
checked "false"
|
|
121
|
+
text "Todo item"
|
|
122
|
+
def taskitem task_2
|
|
123
|
+
checked "true"
|
|
124
|
+
text "Done item"
|
|
125
|
+
\`\`\`
|
|
126
|
+
|
|
127
|
+
### Code
|
|
128
|
+
\`\`\`
|
|
129
|
+
def code block_7
|
|
130
|
+
language "typescript"
|
|
131
|
+
text """function hello() {
|
|
132
|
+
return "world"
|
|
133
|
+
}"""
|
|
134
|
+
\`\`\`
|
|
135
|
+
|
|
136
|
+
### Charts
|
|
137
|
+
\`\`\`
|
|
138
|
+
def chart block_8
|
|
139
|
+
title "Monthly Stats"
|
|
140
|
+
charttype bar
|
|
141
|
+
json "{\\"labels\\": [\\"Jan\\", \\"Feb\\"], \\"datasets\\": [{\\"label\\": \\"Events\\", \\"data\\": [12, 39]}]}"
|
|
142
|
+
showsource "false"
|
|
143
|
+
\`\`\`
|
|
144
|
+
|
|
145
|
+
### Math (LaTeX)
|
|
146
|
+
\`\`\`
|
|
147
|
+
def math block_9
|
|
148
|
+
title "Equation"
|
|
149
|
+
src "E = mc^2"
|
|
150
|
+
display block
|
|
151
|
+
\`\`\`
|
|
152
|
+
|
|
153
|
+
### Mermaid Diagrams
|
|
154
|
+
\`\`\`
|
|
155
|
+
def mermaid block_10
|
|
156
|
+
title "Flow"
|
|
157
|
+
src """flowchart TD
|
|
158
|
+
A[Start] --> B[End]"""
|
|
159
|
+
showsource "false"
|
|
160
|
+
\`\`\`
|
|
161
|
+
|
|
162
|
+
### Tables
|
|
163
|
+
\`\`\`
|
|
164
|
+
def table block_11
|
|
165
|
+
columns "Name, Value"
|
|
166
|
+
def row r1
|
|
167
|
+
def cell c1
|
|
168
|
+
def paragraph p1
|
|
169
|
+
text "Cell content"
|
|
170
|
+
def cell c2
|
|
171
|
+
def paragraph p2
|
|
172
|
+
text "Cell content"
|
|
173
|
+
\`\`\`
|
|
174
|
+
|
|
175
|
+
### Callouts (4 variants: info, warning, success, danger)
|
|
176
|
+
\`\`\`
|
|
177
|
+
def callout block_12
|
|
178
|
+
variant info
|
|
179
|
+
text "ℹ️ This is an info callout"
|
|
180
|
+
\`\`\`
|
|
181
|
+
|
|
182
|
+
### Images
|
|
183
|
+
\`\`\`
|
|
184
|
+
def image block_13
|
|
185
|
+
src "https://example.com/image.png"
|
|
186
|
+
alt "Description"
|
|
187
|
+
width 500
|
|
188
|
+
height "auto"
|
|
189
|
+
align center
|
|
190
|
+
caption "Image caption"
|
|
191
|
+
\`\`\`
|
|
192
|
+
|
|
193
|
+
### Navigation
|
|
194
|
+
\`\`\`
|
|
195
|
+
def button block_14
|
|
196
|
+
label "Next Page"
|
|
197
|
+
link "./next.jot"
|
|
198
|
+
style primary
|
|
199
|
+
align left
|
|
200
|
+
|
|
201
|
+
def gridcard block_15
|
|
202
|
+
layout 2x2
|
|
203
|
+
def card c1
|
|
204
|
+
title "Dashboard"
|
|
205
|
+
icon "📊"
|
|
206
|
+
color teal
|
|
207
|
+
link "./dashboard.jot"
|
|
208
|
+
value ""
|
|
209
|
+
\`\`\`
|
|
210
|
+
|
|
211
|
+
### Toggle & Section (collapsible)
|
|
212
|
+
\`\`\`
|
|
213
|
+
def toggle block_16
|
|
214
|
+
title "Click to expand"
|
|
215
|
+
collapsed "false"
|
|
216
|
+
def paragraph p1
|
|
217
|
+
text "Hidden content"
|
|
218
|
+
|
|
219
|
+
def section block_17
|
|
220
|
+
title "Section Title"
|
|
221
|
+
collapsed "false"
|
|
222
|
+
def paragraph p1
|
|
223
|
+
text "Section content"
|
|
224
|
+
\`\`\`
|
|
225
|
+
|
|
226
|
+
### Columns Layout
|
|
227
|
+
\`\`\`
|
|
228
|
+
def columns block_18
|
|
229
|
+
cols "2"
|
|
230
|
+
def column col1
|
|
231
|
+
def paragraph p1
|
|
232
|
+
text "Left column"
|
|
233
|
+
def column col2
|
|
234
|
+
def paragraph p2
|
|
235
|
+
text "Right column"
|
|
236
|
+
\`\`\`
|
|
237
|
+
|
|
238
|
+
### Divider
|
|
239
|
+
\`\`\`
|
|
240
|
+
def divider block_19
|
|
241
|
+
\`\`\`
|
|
242
|
+
|
|
243
|
+
### Properties (key-value metadata)
|
|
244
|
+
\`\`\`
|
|
245
|
+
def properties block_20
|
|
246
|
+
def property p1
|
|
247
|
+
key "Status"
|
|
248
|
+
value "Active"
|
|
249
|
+
def property p2
|
|
250
|
+
key "Priority"
|
|
251
|
+
value "High"
|
|
252
|
+
\`\`\`
|
|
253
|
+
|
|
254
|
+
### Internal Links (jotxlink)
|
|
255
|
+
\`\`\`
|
|
256
|
+
def jotxlink block_21
|
|
257
|
+
reftype heading
|
|
258
|
+
refid DocumentId#block_id
|
|
259
|
+
\`\`\`
|
|
260
|
+
|
|
261
|
+
## Important Rules
|
|
262
|
+
1. Every file starts with \`hdef jotx <DocumentId>\`
|
|
263
|
+
2. Block IDs must be unique within a file
|
|
264
|
+
3. Indentation is 2 spaces per nesting level
|
|
265
|
+
4. String values use double quotes: \`text "hello"\`
|
|
266
|
+
5. Multi-line strings use triple quotes: \`text """line1\\nline2"""\`
|
|
267
|
+
6. Boolean-like properties are strings: \`checked "false"\`, not \`checked false\`
|
|
268
|
+
7. Nested blocks (children) are indented under their parent
|
|
269
|
+
`;
|
|
270
|
+
/**
|
|
271
|
+
* Load the syntax guide content.
|
|
272
|
+
* If a file path is provided, reads the full User Manual.
|
|
273
|
+
* Otherwise, returns the embedded concise reference.
|
|
274
|
+
*/
|
|
275
|
+
function loadSyntaxGuide(filePath) {
|
|
276
|
+
if (filePath) {
|
|
277
|
+
try {
|
|
278
|
+
return fs.readFileSync(filePath, 'utf-8');
|
|
279
|
+
}
|
|
280
|
+
catch {
|
|
281
|
+
// Fall back to embedded reference if file not found
|
|
282
|
+
return EMBEDDED_SYNTAX_REFERENCE;
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
return EMBEDDED_SYNTAX_REFERENCE;
|
|
286
|
+
}
|
|
287
|
+
/**
|
|
288
|
+
* Get a topic-specific section from the syntax guide.
|
|
289
|
+
* If topic is not found, returns the full guide.
|
|
290
|
+
*/
|
|
291
|
+
function getSyntaxGuideByTopic(topic, fullGuide) {
|
|
292
|
+
const topicLower = topic.toLowerCase();
|
|
293
|
+
const keywords = TOPIC_KEYWORDS[topicLower];
|
|
294
|
+
if (!keywords) {
|
|
295
|
+
// Return available topics + full guide
|
|
296
|
+
const availableTopics = Object.keys(TOPIC_KEYWORDS).join(', ');
|
|
297
|
+
return `Available topics: ${availableTopics}\n\n${fullGuide}`;
|
|
298
|
+
}
|
|
299
|
+
// Extract relevant sections from the guide
|
|
300
|
+
const lines = fullGuide.split('\n');
|
|
301
|
+
const relevantLines = [];
|
|
302
|
+
let inRelevantSection = false;
|
|
303
|
+
let sectionDepth = 0;
|
|
304
|
+
for (const line of lines) {
|
|
305
|
+
const isHeader = line.match(/^#{1,3}\s/);
|
|
306
|
+
if (isHeader) {
|
|
307
|
+
const headerLower = line.toLowerCase();
|
|
308
|
+
const isRelevant = keywords.some(kw => headerLower.includes(kw));
|
|
309
|
+
if (isRelevant) {
|
|
310
|
+
inRelevantSection = true;
|
|
311
|
+
sectionDepth = (line.match(/^#+/) || [''])[0].length;
|
|
312
|
+
}
|
|
313
|
+
else if (inRelevantSection) {
|
|
314
|
+
const currentDepth = (line.match(/^#+/) || [''])[0].length;
|
|
315
|
+
if (currentDepth <= sectionDepth) {
|
|
316
|
+
inRelevantSection = false;
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
if (inRelevantSection) {
|
|
321
|
+
relevantLines.push(line);
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
if (relevantLines.length > 0) {
|
|
325
|
+
return `# Jotx Syntax: ${topic}\n\n${relevantLines.join('\n')}`;
|
|
326
|
+
}
|
|
327
|
+
// Fallback: search for keyword matches in the full guide
|
|
328
|
+
const codeBlockLines = [];
|
|
329
|
+
let inCodeBlock = false;
|
|
330
|
+
for (const line of lines) {
|
|
331
|
+
if (line.startsWith('```')) {
|
|
332
|
+
inCodeBlock = !inCodeBlock;
|
|
333
|
+
}
|
|
334
|
+
if (inCodeBlock || keywords.some(kw => line.toLowerCase().includes(kw))) {
|
|
335
|
+
codeBlockLines.push(line);
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
return codeBlockLines.length > 0
|
|
339
|
+
? `# Jotx Syntax: ${topic}\n\n${codeBlockLines.join('\n')}`
|
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;IAED,yDAAyD;IACzD,MAAM,cAAc,GAAa,EAAE,CAAA;IACnC,IAAI,WAAW,GAAG,KAAK,CAAA;IAEvB,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACvB,IAAI,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC;YACzB,WAAW,GAAG,CAAC,WAAW,CAAA;QAC9B,CAAC;QACD,IAAI,WAAW,IAAI,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC;YACtE,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QAC7B,CAAC;IACL,CAAC;IAED,OAAO,cAAc,CAAC,MAAM,GAAG,CAAC;QAC5B,CAAC,CAAC,kBAAkB,KAAK,OAAO,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;QAC3D,CAAC,CAAC,SAAS,CAAA;AACnB,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Context Tools — MCP tools for editor context and error forwarding
|
|
3
|
+
*
|
|
4
|
+
* Tools: jotx_get_current_doc, jotx_report_errors
|
|
5
|
+
*/
|
|
6
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
7
|
+
import { JotxMCPConfig } from '../types';
|
|
8
|
+
/**
|
|
9
|
+
* Register context tools on the MCP server.
|
|
10
|
+
*/
|
|
11
|
+
export declare function registerContextTools(server: McpServer, config: JotxMCPConfig): void;
|
|
12
|
+
//# sourceMappingURL=context-tools.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context-tools.d.ts","sourceRoot":"","sources":["../../src/tools/context-tools.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAA;AACnE,OAAO,EAAE,aAAa,EAA8B,MAAM,UAAU,CAAA;AAYpE;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,aAAa,GAAG,IAAI,CA6EnF"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Context Tools — MCP tools for editor context and error forwarding
|
|
4
|
+
*
|
|
5
|
+
* Tools: jotx_get_current_doc, jotx_report_errors
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.registerContextTools = registerContextTools;
|
|
9
|
+
const zod_1 = require("zod");
|
|
10
|
+
// Define schemas explicitly to avoid TS2589
|
|
11
|
+
const ReportErrorsSchema = {
|
|
12
|
+
errors: zod_1.z.array(zod_1.z.object({
|
|
13
|
+
message: zod_1.z.string().describe('The error message'),
|
|
14
|
+
filePath: zod_1.z.string().optional().describe('File where the error occurred'),
|
|
15
|
+
line: zod_1.z.number().optional().describe('Line number of the error'),
|
|
16
|
+
blockId: zod_1.z.string().optional().describe('Block ID where the error occurred'),
|
|
17
|
+
})).describe('Array of validation errors from the editor'),
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Register context tools on the MCP server.
|
|
21
|
+
*/
|
|
22
|
+
function registerContextTools(server, config) {
|
|
23
|
+
// ─── jotx_get_current_doc ────────────────────────────────────────
|
|
24
|
+
server.tool('jotx_get_current_doc', 'Get the full content of the document currently open in the editor. Use this instead of jotx_read_file when the user asks about their current/active document.', {}, async () => {
|
|
25
|
+
try {
|
|
26
|
+
const context = config.getCurrentContext?.();
|
|
27
|
+
if (!context || !context.content) {
|
|
28
|
+
return {
|
|
29
|
+
content: [{
|
|
30
|
+
type: 'text',
|
|
31
|
+
text: 'No document is currently open in the editor.',
|
|
32
|
+
}],
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
const info = context.filePath
|
|
36
|
+
? `Currently open: ${context.filePath}\n\n`
|
|
37
|
+
: '';
|
|
38
|
+
return {
|
|
39
|
+
content: [{
|
|
40
|
+
type: 'text',
|
|
41
|
+
text: `${info}${context.content}`,
|
|
42
|
+
}],
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
catch (err) {
|
|
46
|
+
return {
|
|
47
|
+
content: [{ type: 'text', text: `Error getting current document: ${err.message}` }],
|
|
48
|
+
isError: true,
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
// ─── jotx_report_errors ──────────────────────────────────────────
|
|
53
|
+
server.registerTool('jotx_report_errors', {
|
|
54
|
+
description: 'Receive validation errors from the editor. Use these errors to understand what is wrong with the current document and suggest fixes. The errors come from the Jotx parser/validator.',
|
|
55
|
+
inputSchema: ReportErrorsSchema,
|
|
56
|
+
}, async (args) => {
|
|
57
|
+
const editorErrors = args.errors; // Explicit cast for complex object array
|
|
58
|
+
if (editorErrors.length === 0) {
|
|
59
|
+
return {
|
|
60
|
+
content: [{
|
|
61
|
+
type: 'text',
|
|
62
|
+
text: '✅ No errors reported. The document appears to be valid.',
|
|
63
|
+
}],
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
const formatted = editorErrors.map((err, i) => {
|
|
67
|
+
const location = [
|
|
68
|
+
err.filePath ? `File: ${err.filePath}` : null,
|
|
69
|
+
err.line ? `Line: ${err.line}` : null,
|
|
70
|
+
err.blockId ? `Block: ${err.blockId}` : null,
|
|
71
|
+
].filter(Boolean).join(', ');
|
|
72
|
+
return `${i + 1}. ${err.message}${location ? ` (${location})` : ''}`;
|
|
73
|
+
});
|
|
74
|
+
return {
|
|
75
|
+
content: [{
|
|
76
|
+
type: 'text',
|
|
77
|
+
text: `⚠️ ${editorErrors.length} error(s) reported from the editor:\n\n${formatted.join('\n')}\n\nTo fix these, I can read the affected file(s) with jotx_read_file, make corrections, validate with jotx_validate, and write back with jotx_write_file.`,
|
|
78
|
+
}],
|
|
79
|
+
};
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
//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CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;YAE5B,OAAO,GAAG,CAAC,GAAG,CAAC,KAAK,GAAG,CAAC,OAAO,GAAG,QAAQ,CAAC,CAAC,CAAC,KAAK,QAAQ,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAA;QACxE,CAAC,CAAC,CAAA;QAEF,OAAO;YACH,OAAO,EAAE,CAAC;oBACN,IAAI,EAAE,MAAe;oBACrB,IAAI,EAAE,MAAM,YAAY,CAAC,MAAM,0CAA0C,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,4JAA4J;iBAC5P,CAAC;SACL,CAAA;IACL,CAAC,CACJ,CAAA;AACL,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* File Tools — MCP tools for file operations
|
|
3
|
+
*
|
|
4
|
+
* Tools: jotx_list_files, jotx_read_file, jotx_write_file
|
|
5
|
+
*/
|
|
6
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
7
|
+
import { JotxMCPConfig } from '../types';
|
|
8
|
+
/**
|
|
9
|
+
* Register file operation tools on the MCP server.
|
|
10
|
+
*/
|
|
11
|
+
export declare function registerFileTools(server: McpServer, config: JotxMCPConfig): void;
|
|
12
|
+
//# sourceMappingURL=file-tools.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-tools.d.ts","sourceRoot":"","sources":["../../src/tools/file-tools.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAA;AACnE,OAAO,EAAE,aAAa,EAAiB,MAAM,UAAU,CAAA;AAgBvD;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,aAAa,GAAG,IAAI,CA0IhF"}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* File Tools — MCP tools for file operations
|
|
4
|
+
*
|
|
5
|
+
* Tools: jotx_list_files, jotx_read_file, jotx_write_file
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.registerFileTools = registerFileTools;
|
|
9
|
+
const zod_1 = require("zod");
|
|
10
|
+
// Define schemas explicitly to avoid TS2589
|
|
11
|
+
const ListFilesSchema = {
|
|
12
|
+
directory: zod_1.z.string().optional().describe('Optional subdirectory to list. If empty, lists the entire workspace.'),
|
|
13
|
+
};
|
|
14
|
+
const ReadFileSchema = {
|
|
15
|
+
filePath: zod_1.z.string().describe('Path to the file, relative to the workspace root.'),
|
|
16
|
+
};
|
|
17
|
+
const WriteFileSchema = {
|
|
18
|
+
filePath: zod_1.z.string().describe('Path for the file, relative to workspace root. Must end in .jot'),
|
|
19
|
+
content: zod_1.z.string().describe('The full .jot file content to write. Must be valid Jotx format.'),
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Register file operation tools on the MCP server.
|
|
23
|
+
*/
|
|
24
|
+
function registerFileTools(server, config) {
|
|
25
|
+
const { fileOps, workspacePath } = config;
|
|
26
|
+
// ─── jotx_list_files ─────────────────────────────────────────────
|
|
27
|
+
server.registerTool('jotx_list_files', {
|
|
28
|
+
description: 'List all .jot files in the workspace directory recursively. Returns file paths relative to the workspace root.',
|
|
29
|
+
inputSchema: ListFilesSchema,
|
|
30
|
+
}, async (args) => {
|
|
31
|
+
const { directory } = args;
|
|
32
|
+
try {
|
|
33
|
+
const files = await fileOps.listFiles(directory);
|
|
34
|
+
if (files.length === 0) {
|
|
35
|
+
return {
|
|
36
|
+
content: [{ type: 'text', text: 'No .jot files found in the workspace.' }],
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
// Get file sizes if available
|
|
40
|
+
const fileEntries = [];
|
|
41
|
+
for (const file of files) {
|
|
42
|
+
if (fileOps.getFileSize) {
|
|
43
|
+
try {
|
|
44
|
+
const size = await fileOps.getFileSize(file);
|
|
45
|
+
fileEntries.push(` - ${file} (${formatBytes(size)})`);
|
|
46
|
+
}
|
|
47
|
+
catch {
|
|
48
|
+
fileEntries.push(` - ${file}`);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
fileEntries.push(` - ${file}`);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return {
|
|
56
|
+
content: [{
|
|
57
|
+
type: 'text',
|
|
58
|
+
text: `Found ${files.length} .jot file(s) in ${workspacePath}:\n${fileEntries.join('\n')}`,
|
|
59
|
+
}],
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
catch (err) {
|
|
63
|
+
return {
|
|
64
|
+
content: [{ type: 'text', text: `Error listing files: ${err.message}` }],
|
|
65
|
+
isError: true,
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
// ─── jotx_read_file ──────────────────────────────────────────────
|
|
70
|
+
server.registerTool('jotx_read_file', {
|
|
71
|
+
description: 'Read the full contents of a .jot file in the workspace. Use this to understand existing documents before modifying them.',
|
|
72
|
+
inputSchema: ReadFileSchema,
|
|
73
|
+
}, async (args) => {
|
|
74
|
+
const { filePath } = args;
|
|
75
|
+
try {
|
|
76
|
+
// Security: validate path doesn't escape workspace
|
|
77
|
+
if (filePath.includes('..') || filePath.startsWith('/')) {
|
|
78
|
+
return {
|
|
79
|
+
content: [{ type: 'text', text: 'Error: Cannot read files outside the workspace.' }],
|
|
80
|
+
isError: true,
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
const exists = await fileOps.fileExists(filePath);
|
|
84
|
+
if (!exists) {
|
|
85
|
+
return {
|
|
86
|
+
content: [{ type: 'text', text: `Error: File not found: ${filePath}` }],
|
|
87
|
+
isError: true,
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
const content = await fileOps.readFile(filePath);
|
|
91
|
+
const byteCount = Buffer.byteLength(content, 'utf-8');
|
|
92
|
+
return {
|
|
93
|
+
content: [{
|
|
94
|
+
type: 'text',
|
|
95
|
+
text: `File: ${filePath} (${formatBytes(byteCount)})\n\n${content}`,
|
|
96
|
+
}],
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
catch (err) {
|
|
100
|
+
return {
|
|
101
|
+
content: [{ type: 'text', text: `Error reading file: ${err.message}` }],
|
|
102
|
+
isError: true,
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
// ─── jotx_write_file ─────────────────────────────────────────────
|
|
107
|
+
server.registerTool('jotx_write_file', {
|
|
108
|
+
description: 'Create a new .jot file or overwrite an existing one. The content MUST be valid Jotx .jot format (use jotx_validate first to check). File path must end in .jot.',
|
|
109
|
+
inputSchema: WriteFileSchema,
|
|
110
|
+
}, async (args) => {
|
|
111
|
+
const { filePath, content } = args;
|
|
112
|
+
try {
|
|
113
|
+
// Security: validate path
|
|
114
|
+
if (filePath.includes('..') || filePath.startsWith('/')) {
|
|
115
|
+
return {
|
|
116
|
+
content: [{ type: 'text', text: 'Error: Cannot write files outside the workspace.' }],
|
|
117
|
+
isError: true,
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
if (!filePath.endsWith('.jot')) {
|
|
121
|
+
return {
|
|
122
|
+
content: [{ type: 'text', text: 'Error: File path must end in .jot' }],
|
|
123
|
+
isError: true,
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
await fileOps.writeFile(filePath, content);
|
|
127
|
+
return {
|
|
128
|
+
content: [{
|
|
129
|
+
type: 'text',
|
|
130
|
+
text: `✅ File written successfully: ${filePath}`,
|
|
131
|
+
}],
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
catch (err) {
|
|
135
|
+
return {
|
|
136
|
+
content: [{ type: 'text', text: `Error writing file: ${err.message}` }],
|
|
137
|
+
isError: true,
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
// ─── Helpers ─────────────────────────────────────────────────────────
|
|
143
|
+
function formatBytes(bytes) {
|
|
144
|
+
if (bytes < 1024)
|
|
145
|
+
return `${bytes} B`;
|
|
146
|
+
if (bytes < 1024 * 1024)
|
|
147
|
+
return `${(bytes / 1024).toFixed(1)} KB`;
|
|
148
|
+
return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
|
|
149
|
+
}
|
|
150
|
+
//# sourceMappingURL=file-tools.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-tools.js","sourceRoot":"","sources":["../../src/tools/file-tools.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;AAuBH,8CA0IC;AA/JD,6BAAuB;AAIvB,4CAA4C;AAC5C,MAAM,eAAe,GAAG;IACpB,SAAS,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,sEAAsE,CAAC;CACpH,CAAA;AAED,MAAM,cAAc,GAAG;IACnB,QAAQ,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,mDAAmD,CAAC;CACrF,CAAA;AAED,MAAM,eAAe,GAAG;IACpB,QAAQ,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,iEAAiE,CAAC;IAChG,OAAO,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,iEAAiE,CAAC;CAClG,CAAA;AAED;;GAEG;AACH,SAAgB,iBAAiB,CAAC,MAAiB,EAAE,MAAqB;IACtE,MAAM,EAAE,OAAO,EAAE,aAAa,EAAE,GAAG,MAAM,CAAA;IAEzC,oEAAoE;IAEpE,MAAM,CAAC,YAAY,CACf,iBAAiB,EACjB;QACI,WAAW,EAAE,gHAAgH;QAC7H,WAAW,EAAE,eAAsB;KACtC,EACD,KAAK,EAAE,IAAS,EAA0B,EAAE;QACxC,MAAM,EAAE,SAAS,EAAE,GAAG,IAAI,CAAA;QAC1B,IAAI,CAAC;YACD,MAAM,KAAK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AAW,CAAC,KAAa;IAC9B,IAAI,KAAK,GAAG,IAAI;QAAE,OAAO,GAAG,KAAK,IAAI,CAAA;IACrC,IAAI,KAAK,GAAG,IAAI,GAAG,IAAI;QAAE,OAAO,GAAG,CAAC,KAAK,GAAG,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAA;IACjE,OAAO,GAAG,CAAC,KAAK,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAA;AACrD,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Graph Tools — MCP tools for knowledge graph and workspace structure
|
|
3
|
+
*
|
|
4
|
+
* Tools: jotx_get_graph, jotx_get_document_info, jotx_get_workspace_stats, jotx_get_backlinks
|
|
5
|
+
*/
|
|
6
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
7
|
+
import { JotxMCPConfig } from '../types';
|
|
8
|
+
/**
|
|
9
|
+
* Register graph tools on the MCP server.
|
|
10
|
+
*/
|
|
11
|
+
export declare function registerGraphTools(server: McpServer, config: JotxMCPConfig): void;
|
|
12
|
+
//# sourceMappingURL=graph-tools.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graph-tools.d.ts","sourceRoot":"","sources":["../../src/tools/graph-tools.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAA;AAEnE,OAAO,EAAE,aAAa,EAAiB,MAAM,UAAU,CAAA;AAkBvD;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,aAAa,GAAG,IAAI,CA0OjF"}
|