@graph-ir/mcp-server 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +105 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +257 -0
- package/dist/index.js.map +1 -0
- package/dist/tools/generate.d.ts +33 -0
- package/dist/tools/generate.d.ts.map +1 -0
- package/dist/tools/generate.js +160 -0
- package/dist/tools/generate.js.map +1 -0
- package/dist/tools/layout.d.ts +100 -0
- package/dist/tools/layout.d.ts.map +1 -0
- package/dist/tools/layout.js +262 -0
- package/dist/tools/layout.js.map +1 -0
- package/dist/tools/list-notations.d.ts +24 -0
- package/dist/tools/list-notations.d.ts.map +1 -0
- package/dist/tools/list-notations.js +34 -0
- package/dist/tools/list-notations.js.map +1 -0
- package/dist/tools/list-symbols.d.ts +30 -0
- package/dist/tools/list-symbols.d.ts.map +1 -0
- package/dist/tools/list-symbols.js +48 -0
- package/dist/tools/list-symbols.js.map +1 -0
- package/dist/tools/validate-notation.d.ts +23 -0
- package/dist/tools/validate-notation.d.ts.map +1 -0
- package/dist/tools/validate-notation.js +146 -0
- package/dist/tools/validate-notation.js.map +1 -0
- package/dist/tools/validate.d.ts +17 -0
- package/dist/tools/validate.d.ts.map +1 -0
- package/dist/tools/validate.js +19 -0
- package/dist/tools/validate.js.map +1 -0
- package/dist/tools/visualize.d.ts +15 -0
- package/dist/tools/visualize.d.ts.map +1 -0
- package/dist/tools/visualize.js +151 -0
- package/dist/tools/visualize.js.map +1 -0
- package/package.json +54 -0
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Graph-IR Layout Tool
|
|
3
|
+
*
|
|
4
|
+
* Computes graph layout using ELK algorithms.
|
|
5
|
+
*/
|
|
6
|
+
import type { ElkNode } from 'elkjs';
|
|
7
|
+
export interface LayoutResult {
|
|
8
|
+
success: boolean;
|
|
9
|
+
ir?: LayoutedGraphIR;
|
|
10
|
+
errors: string[];
|
|
11
|
+
algorithm: string;
|
|
12
|
+
}
|
|
13
|
+
interface GraphIRNode {
|
|
14
|
+
id: string;
|
|
15
|
+
type: string;
|
|
16
|
+
label?: string;
|
|
17
|
+
children?: GraphIRNode[];
|
|
18
|
+
ports?: Array<{
|
|
19
|
+
id: string;
|
|
20
|
+
side: 'NORTH' | 'SOUTH' | 'EAST' | 'WEST';
|
|
21
|
+
label?: string;
|
|
22
|
+
position?: number;
|
|
23
|
+
[key: string]: unknown;
|
|
24
|
+
}>;
|
|
25
|
+
[key: string]: unknown;
|
|
26
|
+
}
|
|
27
|
+
interface GraphIR {
|
|
28
|
+
version?: string;
|
|
29
|
+
id?: string;
|
|
30
|
+
nodes: GraphIRNode[];
|
|
31
|
+
edges: Array<{
|
|
32
|
+
id: string;
|
|
33
|
+
source: string;
|
|
34
|
+
target: string;
|
|
35
|
+
sourcePort?: string;
|
|
36
|
+
targetPort?: string;
|
|
37
|
+
[key: string]: unknown;
|
|
38
|
+
}>;
|
|
39
|
+
[key: string]: unknown;
|
|
40
|
+
}
|
|
41
|
+
interface LayoutedNode {
|
|
42
|
+
id: string;
|
|
43
|
+
type: string;
|
|
44
|
+
label?: string;
|
|
45
|
+
children?: LayoutedNode[];
|
|
46
|
+
layout: {
|
|
47
|
+
x: number;
|
|
48
|
+
y: number;
|
|
49
|
+
width: number;
|
|
50
|
+
height: number;
|
|
51
|
+
};
|
|
52
|
+
[key: string]: unknown;
|
|
53
|
+
}
|
|
54
|
+
interface LayoutedEdge {
|
|
55
|
+
id: string;
|
|
56
|
+
source: string;
|
|
57
|
+
target: string;
|
|
58
|
+
sourcePort?: string;
|
|
59
|
+
targetPort?: string;
|
|
60
|
+
layout?: {
|
|
61
|
+
points: Array<{
|
|
62
|
+
x: number;
|
|
63
|
+
y: number;
|
|
64
|
+
}>;
|
|
65
|
+
};
|
|
66
|
+
[key: string]: unknown;
|
|
67
|
+
}
|
|
68
|
+
interface LayoutedGraphIR {
|
|
69
|
+
version?: string;
|
|
70
|
+
id?: string;
|
|
71
|
+
nodes: LayoutedNode[];
|
|
72
|
+
edges: LayoutedEdge[];
|
|
73
|
+
layout: {
|
|
74
|
+
width: number;
|
|
75
|
+
height: number;
|
|
76
|
+
algorithm: string;
|
|
77
|
+
};
|
|
78
|
+
[key: string]: unknown;
|
|
79
|
+
}
|
|
80
|
+
export interface LayoutOptions {
|
|
81
|
+
nodeWidth?: number;
|
|
82
|
+
nodeHeight?: number;
|
|
83
|
+
horizontalSpacing?: number;
|
|
84
|
+
verticalSpacing?: number;
|
|
85
|
+
direction?: 'RIGHT' | 'DOWN' | 'LEFT' | 'UP';
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Compute layout for Graph-IR using ELK
|
|
89
|
+
*/
|
|
90
|
+
export declare function layoutIR(irJson: string, algorithm?: string, options?: Record<string, unknown>): Promise<LayoutResult>;
|
|
91
|
+
/**
|
|
92
|
+
* Convert Graph-IR to ELK graph format
|
|
93
|
+
*/
|
|
94
|
+
export declare function graphIRToELK(ir: GraphIR, options: LayoutOptions, algorithm?: string): ElkNode;
|
|
95
|
+
/**
|
|
96
|
+
* Convert ELK result back to Graph-IR format
|
|
97
|
+
*/
|
|
98
|
+
export declare function elkToGraphIR(elkResult: ElkNode, originalIR: GraphIR, algorithm: string): LayoutedGraphIR;
|
|
99
|
+
export {};
|
|
100
|
+
//# sourceMappingURL=layout.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"layout.d.ts","sourceRoot":"","sources":["../../src/tools/layout.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EAAE,OAAO,EAAoE,MAAM,OAAO,CAAC;AAWvG,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,OAAO,CAAC;IACjB,EAAE,CAAC,EAAE,eAAe,CAAC;IACrB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,SAAS,EAAE,MAAM,CA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OAAO,EAAE,aAAa,EACtB,SAAS,GAAE,MAAkB,GAC5B,OAAO,CAmBT;AAwED;;GAEG;AACH,wBAAgB,YAAY,CAC1B,SAAS,EAAE,OAAO,EAClB,UAAU,EAAE,OAAO,EACnB,SAAS,EAAE,MAAM,GAChB,eAAe,CA2BjB"}
|
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Graph-IR Layout Tool
|
|
3
|
+
*
|
|
4
|
+
* Computes graph layout using ELK algorithms.
|
|
5
|
+
*/
|
|
6
|
+
import ELKConstructor from 'elkjs/lib/elk.bundled.js';
|
|
7
|
+
// Initialize ELK instance (handle ESM default export)
|
|
8
|
+
const ELKClass = ELKConstructor.default ?? ELKConstructor;
|
|
9
|
+
// @ts-expect-error - ELK ESM/CJS interop
|
|
10
|
+
const elk = new ELKClass();
|
|
11
|
+
// ============================================================================
|
|
12
|
+
// Algorithm Mapping
|
|
13
|
+
// ============================================================================
|
|
14
|
+
const ALGORITHM_MAPPING = {
|
|
15
|
+
layered: 'org.eclipse.elk.layered',
|
|
16
|
+
force: 'org.eclipse.elk.force',
|
|
17
|
+
mrtree: 'org.eclipse.elk.mrtree',
|
|
18
|
+
box: 'org.eclipse.elk.box',
|
|
19
|
+
stress: 'org.eclipse.elk.stress',
|
|
20
|
+
};
|
|
21
|
+
const DIRECTION_MAPPING = {
|
|
22
|
+
RIGHT: 'RIGHT',
|
|
23
|
+
DOWN: 'DOWN',
|
|
24
|
+
LEFT: 'LEFT',
|
|
25
|
+
UP: 'UP',
|
|
26
|
+
};
|
|
27
|
+
const DEFAULT_OPTIONS = {
|
|
28
|
+
nodeWidth: 150,
|
|
29
|
+
nodeHeight: 50,
|
|
30
|
+
horizontalSpacing: 50,
|
|
31
|
+
verticalSpacing: 50,
|
|
32
|
+
direction: 'RIGHT',
|
|
33
|
+
};
|
|
34
|
+
// ============================================================================
|
|
35
|
+
// Main Layout Function
|
|
36
|
+
// ============================================================================
|
|
37
|
+
/**
|
|
38
|
+
* Compute layout for Graph-IR using ELK
|
|
39
|
+
*/
|
|
40
|
+
export async function layoutIR(irJson, algorithm = 'layered', options = {}) {
|
|
41
|
+
// Parse JSON
|
|
42
|
+
let ir;
|
|
43
|
+
try {
|
|
44
|
+
ir = JSON.parse(irJson);
|
|
45
|
+
}
|
|
46
|
+
catch (e) {
|
|
47
|
+
return {
|
|
48
|
+
success: false,
|
|
49
|
+
errors: [`Invalid JSON: ${e instanceof Error ? e.message : 'Parse error'}`],
|
|
50
|
+
algorithm,
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
// Validate structure
|
|
54
|
+
if (!ir.nodes || !Array.isArray(ir.nodes)) {
|
|
55
|
+
return {
|
|
56
|
+
success: false,
|
|
57
|
+
errors: ['Invalid Graph-IR structure: missing nodes array'],
|
|
58
|
+
algorithm,
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
if (!ir.edges || !Array.isArray(ir.edges)) {
|
|
62
|
+
return {
|
|
63
|
+
success: false,
|
|
64
|
+
errors: ['Invalid Graph-IR structure: missing edges array'],
|
|
65
|
+
algorithm,
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
const layoutOptions = {
|
|
69
|
+
...DEFAULT_OPTIONS,
|
|
70
|
+
...options,
|
|
71
|
+
};
|
|
72
|
+
try {
|
|
73
|
+
// Convert to ELK format
|
|
74
|
+
const elkGraph = graphIRToELK(ir, layoutOptions, algorithm);
|
|
75
|
+
// Run ELK layout
|
|
76
|
+
const layoutedElk = await elk.layout(elkGraph);
|
|
77
|
+
// Convert back to Graph-IR
|
|
78
|
+
const layoutedIR = elkToGraphIR(layoutedElk, ir, algorithm);
|
|
79
|
+
return {
|
|
80
|
+
success: true,
|
|
81
|
+
ir: layoutedIR,
|
|
82
|
+
errors: [],
|
|
83
|
+
algorithm,
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
catch (e) {
|
|
87
|
+
return {
|
|
88
|
+
success: false,
|
|
89
|
+
errors: [`Layout failed: ${e instanceof Error ? e.message : 'Unknown error'}`],
|
|
90
|
+
algorithm,
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
// ============================================================================
|
|
95
|
+
// Conversion Functions
|
|
96
|
+
// ============================================================================
|
|
97
|
+
/**
|
|
98
|
+
* Convert Graph-IR to ELK graph format
|
|
99
|
+
*/
|
|
100
|
+
export function graphIRToELK(ir, options, algorithm = 'layered') {
|
|
101
|
+
const opts = { ...DEFAULT_OPTIONS, ...options };
|
|
102
|
+
// Build root ELK graph
|
|
103
|
+
const elkLayoutOptions = {
|
|
104
|
+
'elk.algorithm': ALGORITHM_MAPPING[algorithm] || ALGORITHM_MAPPING.layered,
|
|
105
|
+
'elk.direction': DIRECTION_MAPPING[opts.direction] || 'RIGHT',
|
|
106
|
+
'elk.spacing.nodeNode': String(opts.horizontalSpacing),
|
|
107
|
+
'elk.layered.spacing.nodeNodeBetweenLayers': String(opts.verticalSpacing),
|
|
108
|
+
};
|
|
109
|
+
const elkGraph = {
|
|
110
|
+
id: 'root',
|
|
111
|
+
layoutOptions: elkLayoutOptions,
|
|
112
|
+
children: ir.nodes.map((node) => convertNodeToELK(node, opts)),
|
|
113
|
+
edges: ir.edges.map((edge) => convertEdgeToELK(edge)),
|
|
114
|
+
};
|
|
115
|
+
return elkGraph;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Convert a Graph-IR node to ELK format
|
|
119
|
+
*/
|
|
120
|
+
function convertNodeToELK(node, opts) {
|
|
121
|
+
const elkNode = {
|
|
122
|
+
id: node.id,
|
|
123
|
+
width: opts.nodeWidth,
|
|
124
|
+
height: opts.nodeHeight,
|
|
125
|
+
labels: node.label ? [{ text: node.label }] : undefined,
|
|
126
|
+
};
|
|
127
|
+
// Convert ports
|
|
128
|
+
if (node.ports && node.ports.length > 0) {
|
|
129
|
+
elkNode.ports = node.ports.map((port) => convertPortToELK(port));
|
|
130
|
+
elkNode.layoutOptions = {
|
|
131
|
+
...elkNode.layoutOptions,
|
|
132
|
+
'elk.portConstraints': 'FIXED_SIDE',
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
// Convert children (compound nodes)
|
|
136
|
+
if (node.children && node.children.length > 0) {
|
|
137
|
+
elkNode.children = node.children.map((child) => convertNodeToELK(child, opts));
|
|
138
|
+
elkNode.layoutOptions = {
|
|
139
|
+
...elkNode.layoutOptions,
|
|
140
|
+
'elk.padding': '[top=10,left=10,bottom=10,right=10]',
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
return elkNode;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Convert a Graph-IR port to ELK format
|
|
147
|
+
*/
|
|
148
|
+
function convertPortToELK(port) {
|
|
149
|
+
const sideMapping = {
|
|
150
|
+
NORTH: 'NORTH',
|
|
151
|
+
SOUTH: 'SOUTH',
|
|
152
|
+
EAST: 'EAST',
|
|
153
|
+
WEST: 'WEST',
|
|
154
|
+
};
|
|
155
|
+
return {
|
|
156
|
+
id: port.id,
|
|
157
|
+
layoutOptions: {
|
|
158
|
+
'elk.port.side': sideMapping[port.side] || 'EAST',
|
|
159
|
+
},
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Convert a Graph-IR edge to ELK format
|
|
164
|
+
*/
|
|
165
|
+
function convertEdgeToELK(edge) {
|
|
166
|
+
const elkEdge = {
|
|
167
|
+
id: edge.id,
|
|
168
|
+
sources: [edge.sourcePort ? `${edge.source}.${edge.sourcePort}` : edge.source],
|
|
169
|
+
targets: [edge.targetPort ? `${edge.target}.${edge.targetPort}` : edge.target],
|
|
170
|
+
};
|
|
171
|
+
return elkEdge;
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Convert ELK result back to Graph-IR format
|
|
175
|
+
*/
|
|
176
|
+
export function elkToGraphIR(elkResult, originalIR, algorithm) {
|
|
177
|
+
// Build lookup for ELK nodes
|
|
178
|
+
const elkNodeMap = new Map();
|
|
179
|
+
collectElkNodes(elkResult, elkNodeMap);
|
|
180
|
+
// Build lookup for original edges
|
|
181
|
+
const originalEdgeMap = new Map(originalIR.edges.map((e) => [e.id, e]));
|
|
182
|
+
// Convert nodes
|
|
183
|
+
const layoutedNodes = convertElkNodesToGraphIR(originalIR.nodes, elkNodeMap);
|
|
184
|
+
// Convert edges
|
|
185
|
+
const layoutedEdges = convertElkEdgesToGraphIR(elkResult.edges || [], originalEdgeMap);
|
|
186
|
+
return {
|
|
187
|
+
...originalIR,
|
|
188
|
+
nodes: layoutedNodes,
|
|
189
|
+
edges: layoutedEdges,
|
|
190
|
+
layout: {
|
|
191
|
+
width: elkResult.width || 0,
|
|
192
|
+
height: elkResult.height || 0,
|
|
193
|
+
algorithm,
|
|
194
|
+
},
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Collect all ELK nodes into a map for quick lookup
|
|
199
|
+
*/
|
|
200
|
+
function collectElkNodes(node, map) {
|
|
201
|
+
if (node.id !== 'root') {
|
|
202
|
+
map.set(node.id, node);
|
|
203
|
+
}
|
|
204
|
+
if (node.children) {
|
|
205
|
+
for (const child of node.children) {
|
|
206
|
+
collectElkNodes(child, map);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* Convert ELK nodes back to Graph-IR nodes with layout info
|
|
212
|
+
*/
|
|
213
|
+
function convertElkNodesToGraphIR(originalNodes, elkNodeMap) {
|
|
214
|
+
return originalNodes.map((node) => {
|
|
215
|
+
const elkNode = elkNodeMap.get(node.id);
|
|
216
|
+
// Build the layouted node without children first
|
|
217
|
+
const { children: _, ...nodeWithoutChildren } = node;
|
|
218
|
+
const layoutedNode = {
|
|
219
|
+
...nodeWithoutChildren,
|
|
220
|
+
layout: {
|
|
221
|
+
x: elkNode?.x ?? 0,
|
|
222
|
+
y: elkNode?.y ?? 0,
|
|
223
|
+
width: elkNode?.width ?? 150,
|
|
224
|
+
height: elkNode?.height ?? 50,
|
|
225
|
+
},
|
|
226
|
+
};
|
|
227
|
+
// Handle children recursively
|
|
228
|
+
if (node.children && node.children.length > 0) {
|
|
229
|
+
layoutedNode.children = convertElkNodesToGraphIR(node.children, elkNodeMap);
|
|
230
|
+
}
|
|
231
|
+
return layoutedNode;
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* Convert ELK edges back to Graph-IR edges with routing info
|
|
236
|
+
*/
|
|
237
|
+
function convertElkEdgesToGraphIR(elkEdges, originalEdgeMap) {
|
|
238
|
+
return elkEdges.map((elkEdge) => {
|
|
239
|
+
const originalEdge = originalEdgeMap.get(elkEdge.id);
|
|
240
|
+
// Extract routing points from sections
|
|
241
|
+
const points = [];
|
|
242
|
+
if (elkEdge.sections) {
|
|
243
|
+
for (const section of elkEdge.sections) {
|
|
244
|
+
points.push(section.startPoint);
|
|
245
|
+
if (section.bendPoints) {
|
|
246
|
+
points.push(...section.bendPoints);
|
|
247
|
+
}
|
|
248
|
+
points.push(section.endPoint);
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
return {
|
|
252
|
+
...originalEdge,
|
|
253
|
+
id: elkEdge.id,
|
|
254
|
+
source: originalEdge?.source ?? '',
|
|
255
|
+
target: originalEdge?.target ?? '',
|
|
256
|
+
layout: {
|
|
257
|
+
points,
|
|
258
|
+
},
|
|
259
|
+
};
|
|
260
|
+
});
|
|
261
|
+
}
|
|
262
|
+
//# sourceMappingURL=layout.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"layout.js","sourceRoot":"","sources":["../../src/tools/layout.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,cAAc,MAAM,0BAA0B,CAAC;AAGtD,sDAAsD;AACtD,MAAM,QAAQ,GAAI,cAAiE,CAAC,OAAO,IAAI,cAAc,CAAC;AAC9G,yCAAyC;AACzC,MAAM,GAAG,GAAQ,IAAI,QAAQ,EAAE,CAAC;AA0FhC,+E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BAChC,IAAI,OAAO,CAAC,UAAU,EAAE,CAAC;oBACvB,MAAM,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;gBACrC,CAAC;gBACD,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;YAChC,CAAC;QACH,CAAC;QAED,OAAO;YACL,GAAG,YAAY;YACf,EAAE,EAAE,OAAO,CAAC,EAAE;YACd,MAAM,EAAE,YAAY,EAAE,MAAM,IAAI,EAAE;YAClC,MAAM,EAAE,YAAY,EAAE,MAAM,IAAI,EAAE;YAClC,MAAM,EAAE;gBACN,MAAM;aACP;SACF,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* list_notations MCP tool
|
|
3
|
+
*
|
|
4
|
+
* Query available notations.
|
|
5
|
+
*/
|
|
6
|
+
import { NotationRegistry, NotationDefinition } from '@graph-ir/core';
|
|
7
|
+
export interface ListNotationsParams {
|
|
8
|
+
/** Include full definitions or just IDs */
|
|
9
|
+
full?: boolean;
|
|
10
|
+
}
|
|
11
|
+
export interface ListNotationsResult {
|
|
12
|
+
notations: NotationDefinition[] | string[];
|
|
13
|
+
count: number;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Get the global notation registry.
|
|
17
|
+
* Used for registering notations from external sources (Coral, Armada).
|
|
18
|
+
*/
|
|
19
|
+
export declare function getNotationRegistry(): NotationRegistry;
|
|
20
|
+
/**
|
|
21
|
+
* List notations with optional full details.
|
|
22
|
+
*/
|
|
23
|
+
export declare function listNotations(params: ListNotationsParams): Promise<ListNotationsResult>;
|
|
24
|
+
//# sourceMappingURL=list-notations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list-notations.d.ts","sourceRoot":"","sources":["../../src/tools/list-notations.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,gBAAgB,EAChB,kBAAkB,EACnB,MAAM,gBAAgB,CAAC;AAGxB,MAAM,WAAW,mBAAmB;IAClC,2CAA2C;IAC3C,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,MAAM,WAAW,mBAAmB;IAClC,SAAS,EAAE,kBAAkB,EAAE,GAAG,MAAM,EAAE,CAAC;IAC3C,KAAK,EAAE,MAAM,CAAC;CACf;AAKD;;;GAGG;AACH,wBAAgB,mBAAmB,IAAI,gBAAgB,CAEtD;AAED;;GAEG;AACH,wBAAsB,aAAa,CAAC,MAAM,EAAE,mBAAmB,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAe7F"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* list_notations MCP tool
|
|
3
|
+
*
|
|
4
|
+
* Query available notations.
|
|
5
|
+
*/
|
|
6
|
+
import { NotationRegistry, } from '@graph-ir/core';
|
|
7
|
+
import { getSymbolRegistry } from './list-symbols.js';
|
|
8
|
+
// Global notation registry - shares symbol registry with list-symbols
|
|
9
|
+
const notationRegistry = new NotationRegistry(getSymbolRegistry());
|
|
10
|
+
/**
|
|
11
|
+
* Get the global notation registry.
|
|
12
|
+
* Used for registering notations from external sources (Coral, Armada).
|
|
13
|
+
*/
|
|
14
|
+
export function getNotationRegistry() {
|
|
15
|
+
return notationRegistry;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* List notations with optional full details.
|
|
19
|
+
*/
|
|
20
|
+
export async function listNotations(params) {
|
|
21
|
+
const notations = notationRegistry.all();
|
|
22
|
+
// Return full definitions or just IDs
|
|
23
|
+
if (params.full) {
|
|
24
|
+
return {
|
|
25
|
+
notations,
|
|
26
|
+
count: notations.length,
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
return {
|
|
30
|
+
notations: notations.map((n) => n.id),
|
|
31
|
+
count: notations.length,
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=list-notations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list-notations.js","sourceRoot":"","sources":["../../src/tools/list-notations.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,gBAAgB,GAEjB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAYtD,sEAAsE;AACtE,MAAM,gBAAgB,GAAG,IAAI,gBAAgB,CAAC,iBAAiB,EAAE,CAAC,CAAC;AAEnE;;;GAGG;AACH,MAAM,UAAU,mBAAmB;IACjC,OAAO,gBAAgB,CAAC;AAC1B,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,MAA2B;IAC7D,MAAM,SAAS,GAAG,gBAAgB,CAAC,GAAG,EAAE,CAAC;IAEzC,sCAAsC;IACtC,IAAI,MAAM,CAAC,IAAI,EAAE,CAAC;QAChB,OAAO;YACL,SAAS;YACT,KAAK,EAAE,SAAS,CAAC,MAAM;SACxB,CAAC;IACJ,CAAC;IAED,OAAO;QACL,SAAS,EAAE,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACrC,KAAK,EAAE,SAAS,CAAC,MAAM;KACxB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* list_symbols MCP tool
|
|
3
|
+
*
|
|
4
|
+
* Query available symbols with filtering options.
|
|
5
|
+
*/
|
|
6
|
+
import { SymbolRegistry, SymbolDefinition } from '@graph-ir/core';
|
|
7
|
+
export interface ListSymbolsParams {
|
|
8
|
+
/** Filter by notation */
|
|
9
|
+
notation?: string;
|
|
10
|
+
/** Filter by tag */
|
|
11
|
+
tag?: string;
|
|
12
|
+
/** Search query (matches name/description) */
|
|
13
|
+
query?: string;
|
|
14
|
+
/** Include full definitions or just IDs */
|
|
15
|
+
full?: boolean;
|
|
16
|
+
}
|
|
17
|
+
export interface ListSymbolsResult {
|
|
18
|
+
symbols: SymbolDefinition[] | string[];
|
|
19
|
+
count: number;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Get the global symbol registry.
|
|
23
|
+
* Used for registering symbols from external sources (Coral, Armada).
|
|
24
|
+
*/
|
|
25
|
+
export declare function getSymbolRegistry(): SymbolRegistry;
|
|
26
|
+
/**
|
|
27
|
+
* List symbols with optional filtering.
|
|
28
|
+
*/
|
|
29
|
+
export declare function listSymbols(params: ListSymbolsParams): Promise<ListSymbolsResult>;
|
|
30
|
+
//# sourceMappingURL=list-symbols.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list-symbols.d.ts","sourceRoot":"","sources":["../../src/tools/list-symbols.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,cAAc,EACd,gBAAgB,EACjB,MAAM,gBAAgB,CAAC;AAExB,MAAM,WAAW,iBAAiB;IAChC,yBAAyB;IACzB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,oBAAoB;IACpB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,8CAA8C;IAC9C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,2CAA2C;IAC3C,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,gBAAgB,EAAE,GAAG,MAAM,EAAE,CAAC;IACvC,KAAK,EAAE,MAAM,CAAC;CACf;AAKD;;;GAGG;AACH,wBAAgB,iBAAiB,IAAI,cAAc,CAElD;AAED;;GAEG;AACH,wBAAsB,WAAW,CAAC,MAAM,EAAE,iBAAiB,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAiCvF"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* list_symbols MCP tool
|
|
3
|
+
*
|
|
4
|
+
* Query available symbols with filtering options.
|
|
5
|
+
*/
|
|
6
|
+
import { SymbolRegistry, } from '@graph-ir/core';
|
|
7
|
+
// Global symbol registry - can be populated by loading symbol definitions
|
|
8
|
+
const symbolRegistry = new SymbolRegistry();
|
|
9
|
+
/**
|
|
10
|
+
* Get the global symbol registry.
|
|
11
|
+
* Used for registering symbols from external sources (Coral, Armada).
|
|
12
|
+
*/
|
|
13
|
+
export function getSymbolRegistry() {
|
|
14
|
+
return symbolRegistry;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* List symbols with optional filtering.
|
|
18
|
+
*/
|
|
19
|
+
export async function listSymbols(params) {
|
|
20
|
+
let symbols = symbolRegistry.all();
|
|
21
|
+
// Apply filters
|
|
22
|
+
if (params.notation) {
|
|
23
|
+
symbols = symbols.filter((s) => s.notations.includes(params.notation));
|
|
24
|
+
}
|
|
25
|
+
if (params.tag) {
|
|
26
|
+
symbols = symbols.filter((s) => s.tags?.includes(params.tag));
|
|
27
|
+
}
|
|
28
|
+
if (params.query) {
|
|
29
|
+
const lowerQuery = params.query.toLowerCase();
|
|
30
|
+
symbols = symbols.filter((s) => {
|
|
31
|
+
const nameMatch = s.name.toLowerCase().includes(lowerQuery);
|
|
32
|
+
const descMatch = s.description?.toLowerCase().includes(lowerQuery);
|
|
33
|
+
return nameMatch || descMatch;
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
// Return full definitions or just IDs
|
|
37
|
+
if (params.full) {
|
|
38
|
+
return {
|
|
39
|
+
symbols,
|
|
40
|
+
count: symbols.length,
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
return {
|
|
44
|
+
symbols: symbols.map((s) => s.id),
|
|
45
|
+
count: symbols.length,
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=list-symbols.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list-symbols.js","sourceRoot":"","sources":["../../src/tools/list-symbols.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,cAAc,GAEf,M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OAAO,CAAC,MAAM;SACtB,CAAC;IACJ,CAAC;IAED,OAAO;QACL,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACjC,KAAK,EAAE,OAAO,CAAC,MAAM;KACtB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* validate_notation MCP tool
|
|
3
|
+
*
|
|
4
|
+
* Validate a Graph-IR against notation rules.
|
|
5
|
+
*/
|
|
6
|
+
import type { NotationValidationResult } from '@graph-ir/core';
|
|
7
|
+
export interface ValidateNotationParams {
|
|
8
|
+
/** The Graph-IR to validate (JSON string) */
|
|
9
|
+
ir: string;
|
|
10
|
+
/** Notation to validate against (overrides metadata.notation) */
|
|
11
|
+
notation?: string;
|
|
12
|
+
/** Treat warnings as errors */
|
|
13
|
+
strict?: boolean;
|
|
14
|
+
}
|
|
15
|
+
export interface ValidateNotationResult extends NotationValidationResult {
|
|
16
|
+
/** The notation that was validated against */
|
|
17
|
+
notation: string | null;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Validate a Graph-IR against notation rules.
|
|
21
|
+
*/
|
|
22
|
+
export declare function validateNotation(params: ValidateNotationParams): Promise<ValidateNotationResult>;
|
|
23
|
+
//# sourceMappingURL=validate-notation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate-notation.d.ts","sourceRoot":"","sources":["../../src/tools/validate-notation.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAEV,wBAAwB,EAGzB,MAAM,gBAAgB,CAAC;AAIxB,MAAM,WAAW,sBAAsB;IACrC,6CAA6C;IAC7C,EAAE,EAAE,MAAM,CAAC;IACX,iEAAiE;IACjE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,+BAA+B;IAC/B,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,WAAW,sBAAuB,SAAQ,wBAAwB;IACtE,8CAA8C;IAC9C,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;CACzB;AAED;;GAEG;AACH,wBAAsB,gBAAgB,CACpC,MAAM,EAAE,sBAAsB,GAC7B,OAAO,CAAC,sBAAsB,CAAC,CAqJjC"}
|