@grafema/mcp 0.2.11 → 0.3.0-beta
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/analysis-worker.d.ts +4 -3
- package/dist/analysis-worker.d.ts.map +1 -1
- package/dist/analysis-worker.js +8 -203
- package/dist/analysis-worker.js.map +1 -1
- package/dist/analysis.d.ts +10 -3
- package/dist/analysis.d.ts.map +1 -1
- package/dist/analysis.js +130 -62
- package/dist/analysis.js.map +1 -1
- package/dist/config.d.ts +5 -11
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +6 -128
- package/dist/config.js.map +1 -1
- package/dist/definitions/analysis-tools.d.ts +6 -0
- package/dist/definitions/analysis-tools.d.ts.map +1 -0
- package/dist/definitions/analysis-tools.js +125 -0
- package/dist/definitions/analysis-tools.js.map +1 -0
- package/dist/definitions/context-tools.d.ts +6 -0
- package/dist/definitions/context-tools.d.ts.map +1 -0
- package/dist/definitions/context-tools.js +144 -0
- package/dist/definitions/context-tools.js.map +1 -0
- package/dist/definitions/graph-tools.d.ts +7 -0
- package/dist/definitions/graph-tools.d.ts.map +1 -0
- package/dist/definitions/graph-tools.js +124 -0
- package/dist/definitions/graph-tools.js.map +1 -0
- package/dist/definitions/graphql-tools.d.ts +6 -0
- package/dist/definitions/graphql-tools.d.ts.map +1 -0
- package/dist/definitions/graphql-tools.js +62 -0
- package/dist/definitions/graphql-tools.js.map +1 -0
- package/dist/definitions/guarantee-tools.d.ts +6 -0
- package/dist/definitions/guarantee-tools.d.ts.map +1 -0
- package/dist/definitions/guarantee-tools.js +136 -0
- package/dist/definitions/guarantee-tools.js.map +1 -0
- package/dist/definitions/index.d.ts +7 -0
- package/dist/definitions/index.d.ts.map +1 -0
- package/dist/definitions/index.js +24 -0
- package/dist/definitions/index.js.map +1 -0
- package/dist/definitions/knowledge-tools.d.ts +10 -0
- package/dist/definitions/knowledge-tools.d.ts.map +1 -0
- package/dist/definitions/knowledge-tools.js +300 -0
- package/dist/definitions/knowledge-tools.js.map +1 -0
- package/dist/definitions/notation-tools.d.ts +9 -0
- package/dist/definitions/notation-tools.d.ts.map +1 -0
- package/dist/definitions/notation-tools.js +62 -0
- package/dist/definitions/notation-tools.js.map +1 -0
- package/dist/definitions/project-tools.d.ts +6 -0
- package/dist/definitions/project-tools.d.ts.map +1 -0
- package/dist/definitions/project-tools.js +181 -0
- package/dist/definitions/project-tools.js.map +1 -0
- package/dist/definitions/query-tools.d.ts +6 -0
- package/dist/definitions/query-tools.d.ts.map +1 -0
- package/dist/definitions/query-tools.js +245 -0
- package/dist/definitions/query-tools.js.map +1 -0
- package/dist/definitions/types.d.ts +21 -0
- package/dist/definitions/types.d.ts.map +1 -0
- package/dist/definitions/types.js +5 -0
- package/dist/definitions/types.js.map +1 -0
- package/dist/dev-proxy.d.ts +29 -0
- package/dist/dev-proxy.d.ts.map +1 -0
- package/dist/dev-proxy.js +267 -0
- package/dist/dev-proxy.js.map +1 -0
- package/dist/handlers/analysis-handlers.d.ts.map +1 -1
- package/dist/handlers/analysis-handlers.js +34 -4
- package/dist/handlers/analysis-handlers.js.map +1 -1
- package/dist/handlers/context-handlers.d.ts +5 -6
- package/dist/handlers/context-handlers.d.ts.map +1 -1
- package/dist/handlers/context-handlers.js +19 -16
- package/dist/handlers/context-handlers.js.map +1 -1
- package/dist/handlers/coverage-handlers.js +1 -1
- package/dist/handlers/dataflow-handlers.d.ts +2 -0
- package/dist/handlers/dataflow-handlers.d.ts.map +1 -1
- package/dist/handlers/dataflow-handlers.js +68 -46
- package/dist/handlers/dataflow-handlers.js.map +1 -1
- package/dist/handlers/documentation-handlers.d.ts.map +1 -1
- package/dist/handlers/documentation-handlers.js +56 -2
- package/dist/handlers/documentation-handlers.js.map +1 -1
- package/dist/handlers/graph-handlers.d.ts +23 -0
- package/dist/handlers/graph-handlers.d.ts.map +1 -0
- package/dist/handlers/graph-handlers.js +155 -0
- package/dist/handlers/graph-handlers.js.map +1 -0
- package/dist/handlers/graphql-handlers.d.ts +9 -0
- package/dist/handlers/graphql-handlers.d.ts.map +1 -0
- package/dist/handlers/graphql-handlers.js +57 -0
- package/dist/handlers/graphql-handlers.js.map +1 -0
- package/dist/handlers/guarantee-handlers.js +1 -1
- package/dist/handlers/guard-handlers.d.ts.map +1 -1
- package/dist/handlers/guard-handlers.js +6 -3
- package/dist/handlers/guard-handlers.js.map +1 -1
- package/dist/handlers/index.d.ts +4 -0
- package/dist/handlers/index.d.ts.map +1 -1
- package/dist/handlers/index.js +6 -0
- package/dist/handlers/index.js.map +1 -1
- package/dist/handlers/issue-handlers.d.ts.map +1 -1
- package/dist/handlers/issue-handlers.js +10 -15
- package/dist/handlers/issue-handlers.js.map +1 -1
- package/dist/handlers/knowledge-handlers.d.ts +25 -0
- package/dist/handlers/knowledge-handlers.d.ts.map +1 -0
- package/dist/handlers/knowledge-handlers.js +208 -0
- package/dist/handlers/knowledge-handlers.js.map +1 -0
- package/dist/handlers/notation-handlers.d.ts +6 -0
- package/dist/handlers/notation-handlers.d.ts.map +1 -0
- package/dist/handlers/notation-handlers.js +53 -0
- package/dist/handlers/notation-handlers.js.map +1 -0
- package/dist/handlers/project-handlers.js +1 -1
- package/dist/handlers/query-handlers.d.ts.map +1 -1
- package/dist/handlers/query-handlers.js +166 -20
- package/dist/handlers/query-handlers.js.map +1 -1
- package/dist/prompts.js +1 -1
- package/dist/server.d.ts +19 -1
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +93 -3
- package/dist/server.js.map +1 -1
- package/dist/state.d.ts +10 -1
- package/dist/state.d.ts.map +1 -1
- package/dist/state.js +61 -8
- package/dist/state.js.map +1 -1
- package/dist/types.d.ts +75 -3
- package/dist/types.d.ts.map +1 -1
- package/dist/utils.d.ts +4 -0
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +18 -1
- package/dist/utils.js.map +1 -1
- package/package.json +4 -3
- package/src/analysis-worker.ts +9 -301
- package/src/analysis.ts +151 -77
- package/src/config.ts +6 -193
- package/src/definitions/analysis-tools.ts +127 -0
- package/src/definitions/context-tools.ts +147 -0
- package/src/definitions/graph-tools.ts +126 -0
- package/src/definitions/graphql-tools.ts +64 -0
- package/src/definitions/guarantee-tools.ts +138 -0
- package/src/definitions/index.ts +28 -0
- package/src/definitions/knowledge-tools.ts +302 -0
- package/src/definitions/notation-tools.ts +64 -0
- package/src/definitions/project-tools.ts +183 -0
- package/src/definitions/query-tools.ts +247 -0
- package/src/definitions/types.ts +22 -0
- package/src/dev-proxy.ts +336 -0
- package/src/handlers/analysis-handlers.ts +35 -4
- package/src/handlers/context-handlers.ts +19 -15
- package/src/handlers/coverage-handlers.ts +1 -1
- package/src/handlers/dataflow-handlers.ts +74 -56
- package/src/handlers/documentation-handlers.ts +56 -2
- package/src/handlers/graph-handlers.ts +212 -0
- package/src/handlers/graphql-handlers.ts +70 -0
- package/src/handlers/guarantee-handlers.ts +1 -1
- package/src/handlers/guard-handlers.ts +7 -3
- package/src/handlers/index.ts +6 -0
- package/src/handlers/issue-handlers.ts +10 -15
- package/src/handlers/knowledge-handlers.ts +242 -0
- package/src/handlers/notation-handlers.ts +71 -0
- package/src/handlers/project-handlers.ts +1 -1
- package/src/handlers/query-handlers.ts +186 -22
- package/src/prompts.ts +1 -1
- package/src/server.ts +126 -2
- package/src/state.ts +68 -8
- package/src/types.ts +98 -3
- package/src/utils.ts +22 -1
- package/src/definitions.ts +0 -665
package/src/definitions.ts
DELETED
|
@@ -1,665 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* MCP Tool Definitions
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import { DEFAULT_LIMIT, MAX_LIMIT } from './utils.js';
|
|
6
|
-
|
|
7
|
-
interface SchemaProperty {
|
|
8
|
-
type: string;
|
|
9
|
-
description?: string;
|
|
10
|
-
enum?: string[];
|
|
11
|
-
items?: SchemaProperty;
|
|
12
|
-
properties?: Record<string, SchemaProperty>;
|
|
13
|
-
required?: string[];
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export interface ToolDefinition {
|
|
17
|
-
name: string;
|
|
18
|
-
description: string;
|
|
19
|
-
inputSchema: {
|
|
20
|
-
type: 'object';
|
|
21
|
-
properties: Record<string, SchemaProperty>;
|
|
22
|
-
required?: string[];
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export const TOOLS: ToolDefinition[] = [
|
|
27
|
-
{
|
|
28
|
-
name: 'query_graph',
|
|
29
|
-
description: `Execute a Datalog query on the code graph.
|
|
30
|
-
|
|
31
|
-
Available predicates:
|
|
32
|
-
- node(Id, Type) - match nodes by type
|
|
33
|
-
- edge(Src, Dst, Type) - match edges
|
|
34
|
-
- attr(Id, Name, Value) - match node attributes (name, file, line, etc.)
|
|
35
|
-
|
|
36
|
-
NODE TYPES:
|
|
37
|
-
- MODULE, FUNCTION, METHOD, CLASS, VARIABLE, PARAMETER
|
|
38
|
-
- CALL, PROPERTY_ACCESS, METHOD_CALL, CALL_SITE
|
|
39
|
-
- http:route, http:request, db:query, socketio:emit, socketio:on
|
|
40
|
-
|
|
41
|
-
EDGE TYPES:
|
|
42
|
-
- CONTAINS, CALLS, DEPENDS_ON, ASSIGNED_FROM, INSTANCE_OF, PASSES_ARGUMENT
|
|
43
|
-
|
|
44
|
-
EXAMPLES:
|
|
45
|
-
violation(X) :- node(X, "MODULE").
|
|
46
|
-
violation(X) :- node(X, "FUNCTION"), attr(X, "file", "src/api.js").
|
|
47
|
-
violation(X) :- node(X, "CALL"), \\+ edge(X, _, "CALLS").`,
|
|
48
|
-
inputSchema: {
|
|
49
|
-
type: 'object',
|
|
50
|
-
properties: {
|
|
51
|
-
query: {
|
|
52
|
-
type: 'string',
|
|
53
|
-
description: 'Datalog query. Must define violation/1 predicate for results.',
|
|
54
|
-
},
|
|
55
|
-
limit: {
|
|
56
|
-
type: 'number',
|
|
57
|
-
description: `Max results to return (default: ${DEFAULT_LIMIT}, max: ${MAX_LIMIT})`,
|
|
58
|
-
},
|
|
59
|
-
offset: {
|
|
60
|
-
type: 'number',
|
|
61
|
-
description: 'Skip first N results for pagination (default: 0)',
|
|
62
|
-
},
|
|
63
|
-
explain: {
|
|
64
|
-
type: 'boolean',
|
|
65
|
-
description: 'Show step-by-step query execution to debug empty results',
|
|
66
|
-
},
|
|
67
|
-
},
|
|
68
|
-
required: ['query'],
|
|
69
|
-
},
|
|
70
|
-
},
|
|
71
|
-
{
|
|
72
|
-
name: 'find_calls',
|
|
73
|
-
description: `Find all calls to a specific function or method.
|
|
74
|
-
Returns call sites with file locations and whether they're resolved.`,
|
|
75
|
-
inputSchema: {
|
|
76
|
-
type: 'object',
|
|
77
|
-
properties: {
|
|
78
|
-
name: {
|
|
79
|
-
type: 'string',
|
|
80
|
-
description: 'Function or method name to find calls for',
|
|
81
|
-
},
|
|
82
|
-
className: {
|
|
83
|
-
type: 'string',
|
|
84
|
-
description: 'Optional: class name for method calls',
|
|
85
|
-
},
|
|
86
|
-
limit: {
|
|
87
|
-
type: 'number',
|
|
88
|
-
description: `Max results (default: ${DEFAULT_LIMIT}, max: ${MAX_LIMIT})`,
|
|
89
|
-
},
|
|
90
|
-
offset: {
|
|
91
|
-
type: 'number',
|
|
92
|
-
description: 'Skip first N results (default: 0)',
|
|
93
|
-
},
|
|
94
|
-
},
|
|
95
|
-
required: ['name'],
|
|
96
|
-
},
|
|
97
|
-
},
|
|
98
|
-
{
|
|
99
|
-
name: 'find_nodes',
|
|
100
|
-
description: `Find nodes in the graph by type, name, or file.`,
|
|
101
|
-
inputSchema: {
|
|
102
|
-
type: 'object',
|
|
103
|
-
properties: {
|
|
104
|
-
type: {
|
|
105
|
-
type: 'string',
|
|
106
|
-
description: 'Node type (e.g., FUNCTION, CLASS, MODULE, PROPERTY_ACCESS)',
|
|
107
|
-
},
|
|
108
|
-
name: {
|
|
109
|
-
type: 'string',
|
|
110
|
-
description: 'Node name pattern',
|
|
111
|
-
},
|
|
112
|
-
file: {
|
|
113
|
-
type: 'string',
|
|
114
|
-
description: 'File path pattern',
|
|
115
|
-
},
|
|
116
|
-
limit: {
|
|
117
|
-
type: 'number',
|
|
118
|
-
description: `Max results (default: ${DEFAULT_LIMIT}, max: ${MAX_LIMIT})`,
|
|
119
|
-
},
|
|
120
|
-
offset: {
|
|
121
|
-
type: 'number',
|
|
122
|
-
description: 'Skip first N results (default: 0)',
|
|
123
|
-
},
|
|
124
|
-
},
|
|
125
|
-
},
|
|
126
|
-
},
|
|
127
|
-
{
|
|
128
|
-
name: 'trace_alias',
|
|
129
|
-
description: `Trace an alias chain to find the original source.
|
|
130
|
-
For code like: const alias = obj.method; alias();
|
|
131
|
-
This traces "alias" back to "obj.method".`,
|
|
132
|
-
inputSchema: {
|
|
133
|
-
type: 'object',
|
|
134
|
-
properties: {
|
|
135
|
-
variableName: {
|
|
136
|
-
type: 'string',
|
|
137
|
-
description: 'Variable name to trace',
|
|
138
|
-
},
|
|
139
|
-
file: {
|
|
140
|
-
type: 'string',
|
|
141
|
-
description: 'File path where the variable is defined',
|
|
142
|
-
},
|
|
143
|
-
},
|
|
144
|
-
required: ['variableName', 'file'],
|
|
145
|
-
},
|
|
146
|
-
},
|
|
147
|
-
{
|
|
148
|
-
name: 'trace_dataflow',
|
|
149
|
-
description: `Trace data flow from/to a variable or expression.`,
|
|
150
|
-
inputSchema: {
|
|
151
|
-
type: 'object',
|
|
152
|
-
properties: {
|
|
153
|
-
source: {
|
|
154
|
-
type: 'string',
|
|
155
|
-
description: 'Variable or node ID to trace from',
|
|
156
|
-
},
|
|
157
|
-
file: {
|
|
158
|
-
type: 'string',
|
|
159
|
-
description: 'File path',
|
|
160
|
-
},
|
|
161
|
-
direction: {
|
|
162
|
-
type: 'string',
|
|
163
|
-
description: 'forward, backward, or both (default: forward)',
|
|
164
|
-
enum: ['forward', 'backward', 'both'],
|
|
165
|
-
},
|
|
166
|
-
max_depth: {
|
|
167
|
-
type: 'number',
|
|
168
|
-
description: 'Maximum trace depth (default: 10)',
|
|
169
|
-
},
|
|
170
|
-
limit: {
|
|
171
|
-
type: 'number',
|
|
172
|
-
description: `Max results (default: ${DEFAULT_LIMIT})`,
|
|
173
|
-
},
|
|
174
|
-
},
|
|
175
|
-
required: ['source'],
|
|
176
|
-
},
|
|
177
|
-
},
|
|
178
|
-
{
|
|
179
|
-
name: 'check_invariant',
|
|
180
|
-
description: `Check a code invariant using a Datalog rule.
|
|
181
|
-
Returns violations if the invariant is broken.`,
|
|
182
|
-
inputSchema: {
|
|
183
|
-
type: 'object',
|
|
184
|
-
properties: {
|
|
185
|
-
rule: {
|
|
186
|
-
type: 'string',
|
|
187
|
-
description: 'Datalog rule defining violation/1',
|
|
188
|
-
},
|
|
189
|
-
description: {
|
|
190
|
-
type: 'string',
|
|
191
|
-
description: 'Human-readable description',
|
|
192
|
-
},
|
|
193
|
-
limit: {
|
|
194
|
-
type: 'number',
|
|
195
|
-
description: `Max violations (default: ${DEFAULT_LIMIT})`,
|
|
196
|
-
},
|
|
197
|
-
offset: {
|
|
198
|
-
type: 'number',
|
|
199
|
-
description: 'Skip first N violations (default: 0)',
|
|
200
|
-
},
|
|
201
|
-
},
|
|
202
|
-
required: ['rule'],
|
|
203
|
-
},
|
|
204
|
-
},
|
|
205
|
-
{
|
|
206
|
-
name: 'discover_services',
|
|
207
|
-
description: `Discover services in the project without full analysis.`,
|
|
208
|
-
inputSchema: {
|
|
209
|
-
type: 'object',
|
|
210
|
-
properties: {},
|
|
211
|
-
},
|
|
212
|
-
},
|
|
213
|
-
{
|
|
214
|
-
name: 'analyze_project',
|
|
215
|
-
description: `Run full analysis on the project or a specific service.`,
|
|
216
|
-
inputSchema: {
|
|
217
|
-
type: 'object',
|
|
218
|
-
properties: {
|
|
219
|
-
service: {
|
|
220
|
-
type: 'string',
|
|
221
|
-
description: 'Optional: analyze only this service',
|
|
222
|
-
},
|
|
223
|
-
force: {
|
|
224
|
-
type: 'boolean',
|
|
225
|
-
description: 'Force re-analysis even if already analyzed',
|
|
226
|
-
},
|
|
227
|
-
index_only: {
|
|
228
|
-
type: 'boolean',
|
|
229
|
-
description: 'Only index modules, skip full analysis',
|
|
230
|
-
},
|
|
231
|
-
},
|
|
232
|
-
},
|
|
233
|
-
},
|
|
234
|
-
{
|
|
235
|
-
name: 'get_analysis_status',
|
|
236
|
-
description: `Get the current analysis status and progress.`,
|
|
237
|
-
inputSchema: {
|
|
238
|
-
type: 'object',
|
|
239
|
-
properties: {},
|
|
240
|
-
},
|
|
241
|
-
},
|
|
242
|
-
{
|
|
243
|
-
name: 'get_stats',
|
|
244
|
-
description: `Get graph statistics: node and edge counts by type.`,
|
|
245
|
-
inputSchema: {
|
|
246
|
-
type: 'object',
|
|
247
|
-
properties: {},
|
|
248
|
-
},
|
|
249
|
-
},
|
|
250
|
-
{
|
|
251
|
-
name: 'get_schema',
|
|
252
|
-
description: `Get the graph schema: available node and edge types.`,
|
|
253
|
-
inputSchema: {
|
|
254
|
-
type: 'object',
|
|
255
|
-
properties: {
|
|
256
|
-
type: {
|
|
257
|
-
type: 'string',
|
|
258
|
-
description: 'nodes, edges, or all (default: all)',
|
|
259
|
-
enum: ['nodes', 'edges', 'all'],
|
|
260
|
-
},
|
|
261
|
-
},
|
|
262
|
-
},
|
|
263
|
-
},
|
|
264
|
-
// Guarantee tools
|
|
265
|
-
{
|
|
266
|
-
name: 'create_guarantee',
|
|
267
|
-
description: `Create a new code guarantee.
|
|
268
|
-
|
|
269
|
-
Two types supported:
|
|
270
|
-
1. Datalog-based: Uses rule field with Datalog query (violation/1)
|
|
271
|
-
2. Contract-based: Uses type + schema for JSON validation
|
|
272
|
-
|
|
273
|
-
Examples:
|
|
274
|
-
- Datalog: name="no-eval" rule="violation(X) :- node(X, \"CALL\"), attr(X, \"name\", \"eval\")."
|
|
275
|
-
- Contract: name="orders" type="guarantee:queue" priority="critical" schema={...}`,
|
|
276
|
-
inputSchema: {
|
|
277
|
-
type: 'object',
|
|
278
|
-
properties: {
|
|
279
|
-
name: {
|
|
280
|
-
type: 'string',
|
|
281
|
-
description: 'Unique name for the guarantee',
|
|
282
|
-
},
|
|
283
|
-
// Datalog-based fields
|
|
284
|
-
rule: {
|
|
285
|
-
type: 'string',
|
|
286
|
-
description: 'Datalog rule defining violation/1 (for Datalog-based guarantees)',
|
|
287
|
-
},
|
|
288
|
-
severity: {
|
|
289
|
-
type: 'string',
|
|
290
|
-
description: 'Severity for Datalog guarantees: error, warning, or info',
|
|
291
|
-
enum: ['error', 'warning', 'info'],
|
|
292
|
-
},
|
|
293
|
-
// Contract-based fields
|
|
294
|
-
type: {
|
|
295
|
-
type: 'string',
|
|
296
|
-
description: 'Guarantee type for contract-based: guarantee:queue, guarantee:api, guarantee:permission',
|
|
297
|
-
enum: ['guarantee:queue', 'guarantee:api', 'guarantee:permission'],
|
|
298
|
-
},
|
|
299
|
-
priority: {
|
|
300
|
-
type: 'string',
|
|
301
|
-
description: 'Priority level: critical, important, observed, tracked',
|
|
302
|
-
enum: ['critical', 'important', 'observed', 'tracked'],
|
|
303
|
-
},
|
|
304
|
-
status: {
|
|
305
|
-
type: 'string',
|
|
306
|
-
description: 'Lifecycle status: discovered, reviewed, active, changing, deprecated',
|
|
307
|
-
enum: ['discovered', 'reviewed', 'active', 'changing', 'deprecated'],
|
|
308
|
-
},
|
|
309
|
-
owner: {
|
|
310
|
-
type: 'string',
|
|
311
|
-
description: 'Owner of the guarantee (team or person)',
|
|
312
|
-
},
|
|
313
|
-
schema: {
|
|
314
|
-
type: 'object',
|
|
315
|
-
description: 'JSON Schema for contract-based validation',
|
|
316
|
-
},
|
|
317
|
-
condition: {
|
|
318
|
-
type: 'string',
|
|
319
|
-
description: 'Condition expression for the guarantee',
|
|
320
|
-
},
|
|
321
|
-
description: {
|
|
322
|
-
type: 'string',
|
|
323
|
-
description: 'Human-readable description',
|
|
324
|
-
},
|
|
325
|
-
governs: {
|
|
326
|
-
type: 'array',
|
|
327
|
-
items: { type: 'string' },
|
|
328
|
-
description: 'Node IDs that this guarantee governs',
|
|
329
|
-
},
|
|
330
|
-
},
|
|
331
|
-
required: ['name'],
|
|
332
|
-
},
|
|
333
|
-
},
|
|
334
|
-
{
|
|
335
|
-
name: 'list_guarantees',
|
|
336
|
-
description: `List all defined guarantees.`,
|
|
337
|
-
inputSchema: {
|
|
338
|
-
type: 'object',
|
|
339
|
-
properties: {},
|
|
340
|
-
},
|
|
341
|
-
},
|
|
342
|
-
{
|
|
343
|
-
name: 'check_guarantees',
|
|
344
|
-
description: `Check all guarantees or specific ones.`,
|
|
345
|
-
inputSchema: {
|
|
346
|
-
type: 'object',
|
|
347
|
-
properties: {
|
|
348
|
-
names: {
|
|
349
|
-
type: 'array',
|
|
350
|
-
items: { type: 'string' },
|
|
351
|
-
description: 'List of guarantee names to check (omit to check all)',
|
|
352
|
-
},
|
|
353
|
-
},
|
|
354
|
-
},
|
|
355
|
-
},
|
|
356
|
-
{
|
|
357
|
-
name: 'delete_guarantee',
|
|
358
|
-
description: `Delete a guarantee by name.`,
|
|
359
|
-
inputSchema: {
|
|
360
|
-
type: 'object',
|
|
361
|
-
properties: {
|
|
362
|
-
name: {
|
|
363
|
-
type: 'string',
|
|
364
|
-
description: 'Name of guarantee to delete',
|
|
365
|
-
},
|
|
366
|
-
},
|
|
367
|
-
required: ['name'],
|
|
368
|
-
},
|
|
369
|
-
},
|
|
370
|
-
{
|
|
371
|
-
name: 'get_coverage',
|
|
372
|
-
description: `Get analysis coverage for a path.`,
|
|
373
|
-
inputSchema: {
|
|
374
|
-
type: 'object',
|
|
375
|
-
properties: {
|
|
376
|
-
path: {
|
|
377
|
-
type: 'string',
|
|
378
|
-
description: 'Path to check coverage for',
|
|
379
|
-
},
|
|
380
|
-
depth: {
|
|
381
|
-
type: 'number',
|
|
382
|
-
description: 'Directory depth to report (default: 2)',
|
|
383
|
-
},
|
|
384
|
-
},
|
|
385
|
-
},
|
|
386
|
-
},
|
|
387
|
-
{
|
|
388
|
-
name: 'get_documentation',
|
|
389
|
-
description: `Get documentation about Grafema usage.`,
|
|
390
|
-
inputSchema: {
|
|
391
|
-
type: 'object',
|
|
392
|
-
properties: {
|
|
393
|
-
topic: {
|
|
394
|
-
type: 'string',
|
|
395
|
-
description: 'Topic: queries, types, guarantees, onboarding, or overview',
|
|
396
|
-
},
|
|
397
|
-
},
|
|
398
|
-
},
|
|
399
|
-
},
|
|
400
|
-
{
|
|
401
|
-
name: 'report_issue',
|
|
402
|
-
description: `Report a bug or issue with Grafema to GitHub.
|
|
403
|
-
|
|
404
|
-
Use this tool when you encounter:
|
|
405
|
-
- Unexpected errors or crashes
|
|
406
|
-
- Incorrect analysis results
|
|
407
|
-
- Missing features that should exist
|
|
408
|
-
- Documentation issues
|
|
409
|
-
|
|
410
|
-
The tool will create a GitHub issue automatically if GITHUB_TOKEN is configured.
|
|
411
|
-
If not configured, it will return a pre-formatted issue template that the user
|
|
412
|
-
can manually submit at https://github.com/Disentinel/grafema/issues/new
|
|
413
|
-
|
|
414
|
-
IMPORTANT: Always ask the user for permission before reporting an issue.
|
|
415
|
-
Include relevant context: error messages, file paths, query used, etc.`,
|
|
416
|
-
inputSchema: {
|
|
417
|
-
type: 'object',
|
|
418
|
-
properties: {
|
|
419
|
-
title: {
|
|
420
|
-
type: 'string',
|
|
421
|
-
description: 'Brief issue title (e.g., "Query returns empty results for FUNCTION nodes")',
|
|
422
|
-
},
|
|
423
|
-
description: {
|
|
424
|
-
type: 'string',
|
|
425
|
-
description: 'Detailed description of the issue',
|
|
426
|
-
},
|
|
427
|
-
context: {
|
|
428
|
-
type: 'string',
|
|
429
|
-
description: 'Relevant context: error messages, queries, file paths, etc.',
|
|
430
|
-
},
|
|
431
|
-
labels: {
|
|
432
|
-
type: 'array',
|
|
433
|
-
items: { type: 'string' },
|
|
434
|
-
description: 'Labels: bug, enhancement, documentation, question',
|
|
435
|
-
},
|
|
436
|
-
},
|
|
437
|
-
required: ['title', 'description'],
|
|
438
|
-
},
|
|
439
|
-
},
|
|
440
|
-
{
|
|
441
|
-
name: 'find_guards',
|
|
442
|
-
description: `Find conditional guards protecting a node.
|
|
443
|
-
|
|
444
|
-
Returns all SCOPE nodes that guard the given node, walking from inner to outer scope.
|
|
445
|
-
Useful for answering "what conditions must be true for this code to execute?"
|
|
446
|
-
|
|
447
|
-
Each guard includes:
|
|
448
|
-
- scopeId: The SCOPE node ID
|
|
449
|
-
- scopeType: Type of conditional (if_statement, else_statement, etc.)
|
|
450
|
-
- condition: Raw condition text (e.g., "user !== null")
|
|
451
|
-
- constraints: Parsed constraints (if available)
|
|
452
|
-
- file/line: Location in source
|
|
453
|
-
|
|
454
|
-
Example use cases:
|
|
455
|
-
- "What conditions guard this API call?"
|
|
456
|
-
- "Is this code protected by a null check?"
|
|
457
|
-
- "What's the full guard chain for this function call?"`,
|
|
458
|
-
inputSchema: {
|
|
459
|
-
type: 'object',
|
|
460
|
-
properties: {
|
|
461
|
-
nodeId: {
|
|
462
|
-
type: 'string',
|
|
463
|
-
description: 'ID of the node to find guards for (e.g., CALL, VARIABLE)',
|
|
464
|
-
},
|
|
465
|
-
},
|
|
466
|
-
required: ['nodeId'],
|
|
467
|
-
},
|
|
468
|
-
},
|
|
469
|
-
{
|
|
470
|
-
name: 'get_function_details',
|
|
471
|
-
description: `Get comprehensive details about a function, including what it calls and who calls it.
|
|
472
|
-
|
|
473
|
-
Graph structure:
|
|
474
|
-
FUNCTION -[HAS_SCOPE]-> SCOPE -[CONTAINS]-> CALL/METHOD_CALL
|
|
475
|
-
CALL -[CALLS]-> FUNCTION (target)
|
|
476
|
-
|
|
477
|
-
Returns:
|
|
478
|
-
- Function metadata (name, file, line, async)
|
|
479
|
-
- calls: What functions/methods this function calls
|
|
480
|
-
- calledBy: What functions call this one
|
|
481
|
-
|
|
482
|
-
For calls array:
|
|
483
|
-
- resolved=true means target function was found
|
|
484
|
-
- resolved=false means unknown target (external/dynamic)
|
|
485
|
-
- type='CALL' for function calls like foo()
|
|
486
|
-
- type='METHOD_CALL' for method calls like obj.method()
|
|
487
|
-
- depth field shows transitive level (0=direct, 1+=indirect)
|
|
488
|
-
|
|
489
|
-
Use transitive=true to follow call chains (A calls B calls C).
|
|
490
|
-
Max transitive depth is 5 to prevent explosion.`,
|
|
491
|
-
inputSchema: {
|
|
492
|
-
type: 'object',
|
|
493
|
-
properties: {
|
|
494
|
-
name: {
|
|
495
|
-
type: 'string',
|
|
496
|
-
description: 'Function name to look up',
|
|
497
|
-
},
|
|
498
|
-
file: {
|
|
499
|
-
type: 'string',
|
|
500
|
-
description: 'Optional: file path to disambiguate (partial match)',
|
|
501
|
-
},
|
|
502
|
-
transitive: {
|
|
503
|
-
type: 'boolean',
|
|
504
|
-
description: 'Follow call chains recursively (default: false)',
|
|
505
|
-
},
|
|
506
|
-
},
|
|
507
|
-
required: ['name'],
|
|
508
|
-
},
|
|
509
|
-
},
|
|
510
|
-
{
|
|
511
|
-
name: 'get_context',
|
|
512
|
-
description: `Get deep context for a graph node: source code + full graph neighborhood.
|
|
513
|
-
|
|
514
|
-
Shows ALL incoming and outgoing edges grouped by type, with source code
|
|
515
|
-
at each connected node's location. Works for ANY node type.
|
|
516
|
-
|
|
517
|
-
Use this after find_nodes or query_graph to deep-dive into a specific node.
|
|
518
|
-
|
|
519
|
-
Output includes:
|
|
520
|
-
- Node info (type, name, semantic ID, location)
|
|
521
|
-
- Source code at the node's location
|
|
522
|
-
- All outgoing edges (what this node connects to)
|
|
523
|
-
- All incoming edges (what connects to this node)
|
|
524
|
-
- Code context at each connected node's location
|
|
525
|
-
|
|
526
|
-
Primary edges (CALLS, ASSIGNED_FROM, DEPENDS_ON, etc.) include code context.
|
|
527
|
-
Structural edges (CONTAINS, HAS_SCOPE, etc.) are shown in compact form.`,
|
|
528
|
-
inputSchema: {
|
|
529
|
-
type: 'object',
|
|
530
|
-
properties: {
|
|
531
|
-
semanticId: {
|
|
532
|
-
type: 'string',
|
|
533
|
-
description: 'Exact semantic ID of the node (from find_nodes or query_graph)',
|
|
534
|
-
},
|
|
535
|
-
contextLines: {
|
|
536
|
-
type: 'number',
|
|
537
|
-
description: 'Lines of code context around each reference (default: 3)',
|
|
538
|
-
},
|
|
539
|
-
edgeType: {
|
|
540
|
-
type: 'string',
|
|
541
|
-
description: 'Filter by edge type (comma-separated, e.g., "CALLS,ASSIGNED_FROM")',
|
|
542
|
-
},
|
|
543
|
-
},
|
|
544
|
-
required: ['semanticId'],
|
|
545
|
-
},
|
|
546
|
-
},
|
|
547
|
-
{
|
|
548
|
-
name: 'get_file_overview',
|
|
549
|
-
description: `Get a structured overview of all entities in a file with their relationships.
|
|
550
|
-
|
|
551
|
-
Shows imports, exports, classes, functions, and variables with key edges
|
|
552
|
-
(CALLS, EXTENDS, ASSIGNED_FROM). Use this for file-level understanding
|
|
553
|
-
before diving into specific nodes with get_context.
|
|
554
|
-
|
|
555
|
-
Output includes:
|
|
556
|
-
- Imports: module sources and imported names
|
|
557
|
-
- Exports: named and default exports
|
|
558
|
-
- Classes: with methods and their call targets
|
|
559
|
-
- Functions: with call targets
|
|
560
|
-
- Variables: with assignment sources
|
|
561
|
-
|
|
562
|
-
This is the recommended first step when exploring a file.
|
|
563
|
-
After using this, use get_context with specific node IDs for details.`,
|
|
564
|
-
inputSchema: {
|
|
565
|
-
type: 'object',
|
|
566
|
-
properties: {
|
|
567
|
-
file: {
|
|
568
|
-
type: 'string',
|
|
569
|
-
description: 'File path (relative to project root or absolute)',
|
|
570
|
-
},
|
|
571
|
-
include_edges: {
|
|
572
|
-
type: 'boolean',
|
|
573
|
-
description:
|
|
574
|
-
'Include relationship edges like CALLS, EXTENDS (default: true). Set false for faster results.',
|
|
575
|
-
},
|
|
576
|
-
},
|
|
577
|
-
required: ['file'],
|
|
578
|
-
},
|
|
579
|
-
},
|
|
580
|
-
{
|
|
581
|
-
name: 'read_project_structure',
|
|
582
|
-
description: `Get the directory structure of the project.
|
|
583
|
-
Returns a tree of files and directories, useful for understanding
|
|
584
|
-
project layout during onboarding.
|
|
585
|
-
|
|
586
|
-
Excludes: node_modules, .git, dist, build, .grafema, coverage, .next, .nuxt
|
|
587
|
-
|
|
588
|
-
Use this tool when studying a new project to identify services,
|
|
589
|
-
packages, and entry points.`,
|
|
590
|
-
inputSchema: {
|
|
591
|
-
type: 'object',
|
|
592
|
-
properties: {
|
|
593
|
-
path: {
|
|
594
|
-
type: 'string',
|
|
595
|
-
description: 'Subdirectory to scan (relative to project root). Default: project root.',
|
|
596
|
-
},
|
|
597
|
-
depth: {
|
|
598
|
-
type: 'number',
|
|
599
|
-
description: 'Maximum directory depth (default: 3, max: 5)',
|
|
600
|
-
},
|
|
601
|
-
include_files: {
|
|
602
|
-
type: 'boolean',
|
|
603
|
-
description: 'Include files in output, not just directories (default: true)',
|
|
604
|
-
},
|
|
605
|
-
},
|
|
606
|
-
},
|
|
607
|
-
},
|
|
608
|
-
{
|
|
609
|
-
name: 'write_config',
|
|
610
|
-
description: `Write or update the Grafema configuration file (.grafema/config.yaml).
|
|
611
|
-
Validates all inputs before writing. Creates .grafema/ directory if needed.
|
|
612
|
-
|
|
613
|
-
Use this tool after studying the project to save the discovered configuration.
|
|
614
|
-
Only include fields you want to override — defaults are used for omitted fields.`,
|
|
615
|
-
inputSchema: {
|
|
616
|
-
type: 'object',
|
|
617
|
-
properties: {
|
|
618
|
-
services: {
|
|
619
|
-
type: 'array',
|
|
620
|
-
items: {
|
|
621
|
-
type: 'object',
|
|
622
|
-
properties: {
|
|
623
|
-
name: { type: 'string', description: 'Service name (e.g., "backend")' },
|
|
624
|
-
path: { type: 'string', description: 'Path relative to project root (e.g., "apps/backend")' },
|
|
625
|
-
entryPoint: { type: 'string', description: 'Entry point file relative to service path (e.g., "src/index.ts")' },
|
|
626
|
-
},
|
|
627
|
-
required: ['name', 'path'],
|
|
628
|
-
},
|
|
629
|
-
description: 'Service definitions (leave empty to use auto-discovery)',
|
|
630
|
-
},
|
|
631
|
-
plugins: {
|
|
632
|
-
type: 'object',
|
|
633
|
-
properties: {
|
|
634
|
-
indexing: { type: 'array', items: { type: 'string' }, description: 'Indexing plugins' },
|
|
635
|
-
analysis: { type: 'array', items: { type: 'string' }, description: 'Analysis plugins' },
|
|
636
|
-
enrichment: { type: 'array', items: { type: 'string' }, description: 'Enrichment plugins' },
|
|
637
|
-
validation: { type: 'array', items: { type: 'string' }, description: 'Validation plugins' },
|
|
638
|
-
},
|
|
639
|
-
description: 'Plugin configuration (omit to use defaults)',
|
|
640
|
-
},
|
|
641
|
-
include: {
|
|
642
|
-
type: 'array',
|
|
643
|
-
items: { type: 'string' },
|
|
644
|
-
description: 'Glob patterns for files to include (e.g., ["src/**/*.ts"])',
|
|
645
|
-
},
|
|
646
|
-
exclude: {
|
|
647
|
-
type: 'array',
|
|
648
|
-
items: { type: 'string' },
|
|
649
|
-
description: 'Glob patterns for files to exclude (e.g., ["**/*.test.ts"])',
|
|
650
|
-
},
|
|
651
|
-
workspace: {
|
|
652
|
-
type: 'object',
|
|
653
|
-
properties: {
|
|
654
|
-
roots: {
|
|
655
|
-
type: 'array',
|
|
656
|
-
items: { type: 'string' },
|
|
657
|
-
description: 'Root directories for multi-root workspace',
|
|
658
|
-
},
|
|
659
|
-
},
|
|
660
|
-
description: 'Multi-root workspace config (only for workspaces)',
|
|
661
|
-
},
|
|
662
|
-
},
|
|
663
|
-
},
|
|
664
|
-
},
|
|
665
|
-
];
|