@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.
Files changed (158) hide show
  1. package/dist/analysis-worker.d.ts +4 -3
  2. package/dist/analysis-worker.d.ts.map +1 -1
  3. package/dist/analysis-worker.js +8 -203
  4. package/dist/analysis-worker.js.map +1 -1
  5. package/dist/analysis.d.ts +10 -3
  6. package/dist/analysis.d.ts.map +1 -1
  7. package/dist/analysis.js +130 -62
  8. package/dist/analysis.js.map +1 -1
  9. package/dist/config.d.ts +5 -11
  10. package/dist/config.d.ts.map +1 -1
  11. package/dist/config.js +6 -128
  12. package/dist/config.js.map +1 -1
  13. package/dist/definitions/analysis-tools.d.ts +6 -0
  14. package/dist/definitions/analysis-tools.d.ts.map +1 -0
  15. package/dist/definitions/analysis-tools.js +125 -0
  16. package/dist/definitions/analysis-tools.js.map +1 -0
  17. package/dist/definitions/context-tools.d.ts +6 -0
  18. package/dist/definitions/context-tools.d.ts.map +1 -0
  19. package/dist/definitions/context-tools.js +144 -0
  20. package/dist/definitions/context-tools.js.map +1 -0
  21. package/dist/definitions/graph-tools.d.ts +7 -0
  22. package/dist/definitions/graph-tools.d.ts.map +1 -0
  23. package/dist/definitions/graph-tools.js +124 -0
  24. package/dist/definitions/graph-tools.js.map +1 -0
  25. package/dist/definitions/graphql-tools.d.ts +6 -0
  26. package/dist/definitions/graphql-tools.d.ts.map +1 -0
  27. package/dist/definitions/graphql-tools.js +62 -0
  28. package/dist/definitions/graphql-tools.js.map +1 -0
  29. package/dist/definitions/guarantee-tools.d.ts +6 -0
  30. package/dist/definitions/guarantee-tools.d.ts.map +1 -0
  31. package/dist/definitions/guarantee-tools.js +136 -0
  32. package/dist/definitions/guarantee-tools.js.map +1 -0
  33. package/dist/definitions/index.d.ts +7 -0
  34. package/dist/definitions/index.d.ts.map +1 -0
  35. package/dist/definitions/index.js +24 -0
  36. package/dist/definitions/index.js.map +1 -0
  37. package/dist/definitions/knowledge-tools.d.ts +10 -0
  38. package/dist/definitions/knowledge-tools.d.ts.map +1 -0
  39. package/dist/definitions/knowledge-tools.js +300 -0
  40. package/dist/definitions/knowledge-tools.js.map +1 -0
  41. package/dist/definitions/notation-tools.d.ts +9 -0
  42. package/dist/definitions/notation-tools.d.ts.map +1 -0
  43. package/dist/definitions/notation-tools.js +62 -0
  44. package/dist/definitions/notation-tools.js.map +1 -0
  45. package/dist/definitions/project-tools.d.ts +6 -0
  46. package/dist/definitions/project-tools.d.ts.map +1 -0
  47. package/dist/definitions/project-tools.js +181 -0
  48. package/dist/definitions/project-tools.js.map +1 -0
  49. package/dist/definitions/query-tools.d.ts +6 -0
  50. package/dist/definitions/query-tools.d.ts.map +1 -0
  51. package/dist/definitions/query-tools.js +245 -0
  52. package/dist/definitions/query-tools.js.map +1 -0
  53. package/dist/definitions/types.d.ts +21 -0
  54. package/dist/definitions/types.d.ts.map +1 -0
  55. package/dist/definitions/types.js +5 -0
  56. package/dist/definitions/types.js.map +1 -0
  57. package/dist/dev-proxy.d.ts +29 -0
  58. package/dist/dev-proxy.d.ts.map +1 -0
  59. package/dist/dev-proxy.js +267 -0
  60. package/dist/dev-proxy.js.map +1 -0
  61. package/dist/handlers/analysis-handlers.d.ts.map +1 -1
  62. package/dist/handlers/analysis-handlers.js +34 -4
  63. package/dist/handlers/analysis-handlers.js.map +1 -1
  64. package/dist/handlers/context-handlers.d.ts +5 -6
  65. package/dist/handlers/context-handlers.d.ts.map +1 -1
  66. package/dist/handlers/context-handlers.js +19 -16
  67. package/dist/handlers/context-handlers.js.map +1 -1
  68. package/dist/handlers/coverage-handlers.js +1 -1
  69. package/dist/handlers/dataflow-handlers.d.ts +2 -0
  70. package/dist/handlers/dataflow-handlers.d.ts.map +1 -1
  71. package/dist/handlers/dataflow-handlers.js +68 -46
  72. package/dist/handlers/dataflow-handlers.js.map +1 -1
  73. package/dist/handlers/documentation-handlers.d.ts.map +1 -1
  74. package/dist/handlers/documentation-handlers.js +56 -2
  75. package/dist/handlers/documentation-handlers.js.map +1 -1
  76. package/dist/handlers/graph-handlers.d.ts +23 -0
  77. package/dist/handlers/graph-handlers.d.ts.map +1 -0
  78. package/dist/handlers/graph-handlers.js +155 -0
  79. package/dist/handlers/graph-handlers.js.map +1 -0
  80. package/dist/handlers/graphql-handlers.d.ts +9 -0
  81. package/dist/handlers/graphql-handlers.d.ts.map +1 -0
  82. package/dist/handlers/graphql-handlers.js +57 -0
  83. package/dist/handlers/graphql-handlers.js.map +1 -0
  84. package/dist/handlers/guarantee-handlers.js +1 -1
  85. package/dist/handlers/guard-handlers.d.ts.map +1 -1
  86. package/dist/handlers/guard-handlers.js +6 -3
  87. package/dist/handlers/guard-handlers.js.map +1 -1
  88. package/dist/handlers/index.d.ts +4 -0
  89. package/dist/handlers/index.d.ts.map +1 -1
  90. package/dist/handlers/index.js +6 -0
  91. package/dist/handlers/index.js.map +1 -1
  92. package/dist/handlers/issue-handlers.d.ts.map +1 -1
  93. package/dist/handlers/issue-handlers.js +10 -15
  94. package/dist/handlers/issue-handlers.js.map +1 -1
  95. package/dist/handlers/knowledge-handlers.d.ts +25 -0
  96. package/dist/handlers/knowledge-handlers.d.ts.map +1 -0
  97. package/dist/handlers/knowledge-handlers.js +208 -0
  98. package/dist/handlers/knowledge-handlers.js.map +1 -0
  99. package/dist/handlers/notation-handlers.d.ts +6 -0
  100. package/dist/handlers/notation-handlers.d.ts.map +1 -0
  101. package/dist/handlers/notation-handlers.js +53 -0
  102. package/dist/handlers/notation-handlers.js.map +1 -0
  103. package/dist/handlers/project-handlers.js +1 -1
  104. package/dist/handlers/query-handlers.d.ts.map +1 -1
  105. package/dist/handlers/query-handlers.js +166 -20
  106. package/dist/handlers/query-handlers.js.map +1 -1
  107. package/dist/prompts.js +1 -1
  108. package/dist/server.d.ts +19 -1
  109. package/dist/server.d.ts.map +1 -1
  110. package/dist/server.js +93 -3
  111. package/dist/server.js.map +1 -1
  112. package/dist/state.d.ts +10 -1
  113. package/dist/state.d.ts.map +1 -1
  114. package/dist/state.js +61 -8
  115. package/dist/state.js.map +1 -1
  116. package/dist/types.d.ts +75 -3
  117. package/dist/types.d.ts.map +1 -1
  118. package/dist/utils.d.ts +4 -0
  119. package/dist/utils.d.ts.map +1 -1
  120. package/dist/utils.js +18 -1
  121. package/dist/utils.js.map +1 -1
  122. package/package.json +4 -3
  123. package/src/analysis-worker.ts +9 -301
  124. package/src/analysis.ts +151 -77
  125. package/src/config.ts +6 -193
  126. package/src/definitions/analysis-tools.ts +127 -0
  127. package/src/definitions/context-tools.ts +147 -0
  128. package/src/definitions/graph-tools.ts +126 -0
  129. package/src/definitions/graphql-tools.ts +64 -0
  130. package/src/definitions/guarantee-tools.ts +138 -0
  131. package/src/definitions/index.ts +28 -0
  132. package/src/definitions/knowledge-tools.ts +302 -0
  133. package/src/definitions/notation-tools.ts +64 -0
  134. package/src/definitions/project-tools.ts +183 -0
  135. package/src/definitions/query-tools.ts +247 -0
  136. package/src/definitions/types.ts +22 -0
  137. package/src/dev-proxy.ts +336 -0
  138. package/src/handlers/analysis-handlers.ts +35 -4
  139. package/src/handlers/context-handlers.ts +19 -15
  140. package/src/handlers/coverage-handlers.ts +1 -1
  141. package/src/handlers/dataflow-handlers.ts +74 -56
  142. package/src/handlers/documentation-handlers.ts +56 -2
  143. package/src/handlers/graph-handlers.ts +212 -0
  144. package/src/handlers/graphql-handlers.ts +70 -0
  145. package/src/handlers/guarantee-handlers.ts +1 -1
  146. package/src/handlers/guard-handlers.ts +7 -3
  147. package/src/handlers/index.ts +6 -0
  148. package/src/handlers/issue-handlers.ts +10 -15
  149. package/src/handlers/knowledge-handlers.ts +242 -0
  150. package/src/handlers/notation-handlers.ts +71 -0
  151. package/src/handlers/project-handlers.ts +1 -1
  152. package/src/handlers/query-handlers.ts +186 -22
  153. package/src/prompts.ts +1 -1
  154. package/src/server.ts +126 -2
  155. package/src/state.ts +68 -8
  156. package/src/types.ts +98 -3
  157. package/src/utils.ts +22 -1
  158. package/src/definitions.ts +0 -665
@@ -0,0 +1 @@
1
+ {"version":3,"file":"notation-tools.js","sourceRoot":"","sources":["../../src/definitions/notation-tools.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,MAAM,CAAC,MAAM,cAAc,GAAqB;IAC9C;QACE,IAAI,EAAE,UAAU;QAChB,WAAW,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2EA8B0D;QACvE,WAAW,EAAE;YACX,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACV,MAAM,EAAE;oBACN,IAAI,EAAE,QAAQ;oBACd,WAAW,EAAE,kDAAkD;iBAChE;gBACD,KAAK,EAAE;oBACL,IAAI,EAAE,QAAQ;oBACd,WAAW,EAAE,yGAAyG;iBACvH;gBACD,WAAW,EAAE;oBACX,IAAI,EAAE,QAAQ;oBACd,WAAW,EAAE,wKAAwK;oBACrL,IAAI,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,CAAC;iBACtD;aACF;YACD,QAAQ,EAAE,CAAC,QAAQ,CAAC;SACrB;KACF;CACF,CAAC"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Project Tools — structure, config, coverage, documentation, issue reporting
3
+ */
4
+ import type { ToolDefinition } from './types.js';
5
+ export declare const PROJECT_TOOLS: ToolDefinition[];
6
+ //# sourceMappingURL=project-tools.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"project-tools.d.ts","sourceRoot":"","sources":["../../src/definitions/project-tools.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjD,eAAO,MAAM,aAAa,EAAE,cAAc,EAgLzC,CAAC"}
@@ -0,0 +1,181 @@
1
+ /**
2
+ * Project Tools — structure, config, coverage, documentation, issue reporting
3
+ */
4
+ export const PROJECT_TOOLS = [
5
+ {
6
+ name: 'read_project_structure',
7
+ description: `Get the directory structure of the project.
8
+ Returns a tree of files and directories, useful for understanding
9
+ project layout during onboarding.
10
+
11
+ Excludes: node_modules, .git, dist, build, .grafema, coverage, .next, .nuxt
12
+
13
+ Use this tool when studying a new project to identify services,
14
+ packages, and entry points.`,
15
+ inputSchema: {
16
+ type: 'object',
17
+ properties: {
18
+ path: {
19
+ type: 'string',
20
+ description: 'Subdirectory to scan (relative to project root). Default: project root.',
21
+ },
22
+ depth: {
23
+ type: 'number',
24
+ description: 'Maximum directory depth (default: 3, max: 5)',
25
+ },
26
+ include_files: {
27
+ type: 'boolean',
28
+ description: 'Include files in output, not just directories (default: true)',
29
+ },
30
+ },
31
+ },
32
+ },
33
+ {
34
+ name: 'write_config',
35
+ description: `Write or update the Grafema configuration file (.grafema/config.yaml).
36
+ Validates all inputs before writing. Creates .grafema/ directory if needed.
37
+
38
+ Use this tool after studying the project to save the discovered configuration.
39
+ Only include fields you want to override — defaults are used for omitted fields.`,
40
+ inputSchema: {
41
+ type: 'object',
42
+ properties: {
43
+ services: {
44
+ type: 'array',
45
+ items: {
46
+ type: 'object',
47
+ properties: {
48
+ name: { type: 'string', description: 'Service name (e.g., "backend")' },
49
+ path: { type: 'string', description: 'Path relative to project root (e.g., "apps/backend")' },
50
+ entryPoint: { type: 'string', description: 'Entry point file relative to service path (e.g., "src/index.ts")' },
51
+ },
52
+ required: ['name', 'path'],
53
+ },
54
+ description: 'Service definitions (leave empty to use auto-discovery)',
55
+ },
56
+ plugins: {
57
+ type: 'object',
58
+ properties: {
59
+ indexing: { type: 'array', items: { type: 'string' }, description: 'Indexing plugins' },
60
+ analysis: { type: 'array', items: { type: 'string' }, description: 'Analysis plugins' },
61
+ enrichment: { type: 'array', items: { type: 'string' }, description: 'Enrichment plugins' },
62
+ validation: { type: 'array', items: { type: 'string' }, description: 'Validation plugins' },
63
+ },
64
+ description: 'Plugin configuration (omit to use defaults)',
65
+ },
66
+ include: {
67
+ type: 'array',
68
+ items: { type: 'string' },
69
+ description: 'Glob patterns for files to include (e.g., ["src/**/*.ts"])',
70
+ },
71
+ exclude: {
72
+ type: 'array',
73
+ items: { type: 'string' },
74
+ description: 'Glob patterns for files to exclude (e.g., ["**/*.test.ts"])',
75
+ },
76
+ workspace: {
77
+ type: 'object',
78
+ properties: {
79
+ roots: {
80
+ type: 'array',
81
+ items: { type: 'string' },
82
+ description: 'Root directories for multi-root workspace',
83
+ },
84
+ },
85
+ description: 'Multi-root workspace config (only for workspaces)',
86
+ },
87
+ },
88
+ },
89
+ },
90
+ {
91
+ name: 'get_coverage',
92
+ description: `Check which files were analyzed and which were skipped.
93
+
94
+ Use this to:
95
+ - Find gaps: "Why doesn't query find this file?" — check if it was analyzed
96
+ - Verify include/exclude patterns work correctly
97
+ - Debug empty query results: file not in graph → not analyzed
98
+ - Identify unsupported file types or parse errors
99
+
100
+ Returns: analyzed/skipped file counts, coverage percentage, skip reasons.
101
+
102
+ Use AFTER analyze_project when queries return unexpected empty results.`,
103
+ inputSchema: {
104
+ type: 'object',
105
+ properties: {
106
+ path: {
107
+ type: 'string',
108
+ description: 'Path to check coverage for',
109
+ },
110
+ depth: {
111
+ type: 'number',
112
+ description: 'Directory depth to report (default: 2)',
113
+ },
114
+ },
115
+ },
116
+ },
117
+ {
118
+ name: 'get_documentation',
119
+ description: `Get documentation about Grafema usage and query syntax.
120
+
121
+ Topics available:
122
+ - queries: Datalog query syntax and examples
123
+ - types: Available node and edge types
124
+ - guarantees: How to create and manage code guarantees
125
+ - notation: DSL notation reference (archetypes, operators, LOD, perspectives)
126
+ - onboarding: Step-by-step guide for new projects
127
+ - overview: High-level Grafema architecture
128
+
129
+ Use this when you need to learn Datalog syntax, DSL notation, or understand available features.`,
130
+ inputSchema: {
131
+ type: 'object',
132
+ properties: {
133
+ topic: {
134
+ type: 'string',
135
+ description: 'Topic: queries, types, guarantees, notation, onboarding, or overview',
136
+ },
137
+ },
138
+ },
139
+ },
140
+ {
141
+ name: 'report_issue',
142
+ description: `Report a bug or issue with Grafema to GitHub.
143
+
144
+ Use this tool when you encounter:
145
+ - Unexpected errors or crashes
146
+ - Incorrect analysis results
147
+ - Missing features that should exist
148
+ - Documentation issues
149
+
150
+ The tool will create a GitHub issue automatically if GITHUB_TOKEN is configured.
151
+ If not configured, it will return a pre-formatted issue template that the user
152
+ can manually submit at https://github.com/Disentinel/grafema/issues/new
153
+
154
+ IMPORTANT: Always ask the user for permission before reporting an issue.
155
+ Include relevant context: error messages, file paths, query used, etc.`,
156
+ inputSchema: {
157
+ type: 'object',
158
+ properties: {
159
+ title: {
160
+ type: 'string',
161
+ description: 'Brief issue title (e.g., "Query returns empty results for FUNCTION nodes")',
162
+ },
163
+ description: {
164
+ type: 'string',
165
+ description: 'Detailed description of the issue',
166
+ },
167
+ context: {
168
+ type: 'string',
169
+ description: 'Relevant context: error messages, queries, file paths, etc.',
170
+ },
171
+ labels: {
172
+ type: 'array',
173
+ items: { type: 'string' },
174
+ description: 'Labels: bug, enhancement, documentation, question',
175
+ },
176
+ },
177
+ required: ['title', 'description'],
178
+ },
179
+ },
180
+ ];
181
+ //# sourceMappingURL=project-tools.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"project-tools.js","sourceRoot":"","sources":["../../src/definitions/project-tools.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,MAAM,CAAC,MAAM,aAAa,GAAqB;IAC7C;QACE,IAAI,EAAE,wBAAwB;QAC9B,WAAW,EAAE;;;;;;;4BAOW;QACxB,WAAW,EAAE;YACX,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACV,IAAI,EAAE;oBACJ,IAAI,EAAE,QAAQ;oBACd,WAAW,EAAE,yEAAyE;iBACvF;gBACD,KAAK,EAAE;oBACL,IAAI,EAAE,QAAQ;oBACd,WAAW,EAAE,8CAA8C;iBAC5D;gBACD,aAAa,EAAE;oBACb,IAAI,EAAE,SAAS;oBACf,WAAW,EAAE,+DAA+D;iBAC7E;aACF;SACF;KACF;IACD;QACE,IAAI,EAAE,cAAc;QACpB,WAAW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AAW,EAAE,6DAA6D;iBAC3E;gBACD,MAAM,EAAE;oBACN,IAAI,EAAE,OAAO;oBACb,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;oBACzB,WAAW,EAAE,mDAAmD;iBACjE;aACF;YACD,QAAQ,EAAE,CAAC,OAAO,EAAE,aAAa,CAAC;SACnC;KACF;CACF,CAAC"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Query Tools — graph querying and tracing
3
+ */
4
+ import type { ToolDefinition } from './types.js';
5
+ export declare const QUERY_TOOLS: ToolDefinition[];
6
+ //# sourceMappingURL=query-tools.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"query-tools.d.ts","sourceRoot":"","sources":["../../src/definitions/query-tools.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAGjD,eAAO,MAAM,WAAW,EAAE,cAAc,EA+OvC,CAAC"}
@@ -0,0 +1,245 @@
1
+ /**
2
+ * Query Tools — graph querying and tracing
3
+ */
4
+ import { DEFAULT_LIMIT, MAX_LIMIT } from '../utils.js';
5
+ export const QUERY_TOOLS = [
6
+ {
7
+ name: 'query_graph',
8
+ description: `Execute a Datalog or Cypher query on the code graph.
9
+
10
+ Set language to "cypher" for Cypher queries (e.g., MATCH (n:FUNCTION) RETURN n.name).
11
+ Default is Datalog.
12
+
13
+ Available Datalog predicates:
14
+ - type(Id, Type) - match nodes by type (alias: node)
15
+ - edge(Src, Dst, Type) - match edges
16
+ - attr(Id, Name, Value) - match node attributes (name, file, line, etc.)
17
+
18
+ NODE TYPES:
19
+ - MODULE, FUNCTION, METHOD, CLASS, VARIABLE, PARAMETER
20
+ - CALL, PROPERTY_ACCESS, METHOD_CALL, CALL_SITE
21
+ - http:route, http:request, db:query, socketio:emit, socketio:on
22
+
23
+ EDGE TYPES:
24
+ - CONTAINS, CALLS, DEPENDS_ON, ASSIGNED_FROM, INSTANCE_OF, PASSES_ARGUMENT
25
+
26
+ EXAMPLES:
27
+ violation(X) :- node(X, "MODULE").
28
+ violation(X) :- node(X, "FUNCTION"), attr(X, "file", "src/api.js").
29
+ violation(X) :- node(X, "CALL"), \\+ edge(X, _, "CALLS").`,
30
+ inputSchema: {
31
+ type: 'object',
32
+ properties: {
33
+ query: {
34
+ type: 'string',
35
+ description: 'Datalog query (must define violation/1 predicate) or Cypher query (when language is "cypher").',
36
+ },
37
+ language: {
38
+ type: 'string',
39
+ description: 'Query language: "datalog" (default) or "cypher"',
40
+ enum: ['datalog', 'cypher'],
41
+ },
42
+ limit: {
43
+ type: 'number',
44
+ description: `Max results to return (default: ${DEFAULT_LIMIT}, max: ${MAX_LIMIT})`,
45
+ },
46
+ offset: {
47
+ type: 'number',
48
+ description: 'Skip first N results for pagination (default: 0)',
49
+ },
50
+ explain: {
51
+ type: 'boolean',
52
+ description: 'Show step-by-step query execution to debug empty results',
53
+ },
54
+ count: {
55
+ type: 'boolean',
56
+ description: 'When true, returns only the count of matching results instead of the full result list',
57
+ },
58
+ },
59
+ required: ['query'],
60
+ },
61
+ },
62
+ {
63
+ name: 'find_calls',
64
+ description: `Find every place in the codebase that calls a specific function or method.
65
+
66
+ Use this when you need to answer:
67
+ - "Who calls getUserById?" → name="getUserById"
68
+ - "Where is redis.get used?" → name="get", className="redis"
69
+ - "Is this function dead code?" → if 0 calls found, likely unused
70
+
71
+ Returns file, line, and whether the call target is resolved (linked to its definition in the graph).`,
72
+ inputSchema: {
73
+ type: 'object',
74
+ properties: {
75
+ name: {
76
+ type: 'string',
77
+ description: 'Function or method name to find calls for',
78
+ },
79
+ className: {
80
+ type: 'string',
81
+ description: 'Optional: class name for method calls',
82
+ },
83
+ limit: {
84
+ type: 'number',
85
+ description: `Max results (default: ${DEFAULT_LIMIT}, max: ${MAX_LIMIT})`,
86
+ },
87
+ offset: {
88
+ type: 'number',
89
+ description: 'Skip first N results (default: 0)',
90
+ },
91
+ },
92
+ required: ['name'],
93
+ },
94
+ },
95
+ {
96
+ name: 'find_nodes',
97
+ description: `Find nodes in the graph by type, name, or file pattern.
98
+
99
+ Use this when you need to:
100
+ - Find all functions in a specific file: type="FUNCTION", file="src/api.js"
101
+ - Find a class by name: type="CLASS", name="UserService"
102
+ - List all HTTP routes: type="http:route"
103
+ - Get all modules in a directory: type="MODULE", file="services/"
104
+
105
+ Returns semantic IDs that you can pass to get_context, get_node, get_neighbors, or find_guards.
106
+
107
+ Supports partial matches on name and file. Use limit/offset for pagination.`,
108
+ inputSchema: {
109
+ type: 'object',
110
+ properties: {
111
+ type: {
112
+ type: 'string',
113
+ description: 'Node type (e.g., FUNCTION, CLASS, MODULE, PROPERTY_ACCESS)',
114
+ },
115
+ name: {
116
+ type: 'string',
117
+ description: 'Node name pattern',
118
+ },
119
+ file: {
120
+ type: 'string',
121
+ description: 'File path pattern',
122
+ },
123
+ limit: {
124
+ type: 'number',
125
+ description: `Max results (default: ${DEFAULT_LIMIT}, max: ${MAX_LIMIT})`,
126
+ },
127
+ offset: {
128
+ type: 'number',
129
+ description: 'Skip first N results (default: 0)',
130
+ },
131
+ },
132
+ },
133
+ },
134
+ {
135
+ name: 'trace_alias',
136
+ description: `Trace an alias chain to find the original source.
137
+ For code like: const alias = obj.method; alias();
138
+ This traces "alias" back to "obj.method".`,
139
+ inputSchema: {
140
+ type: 'object',
141
+ properties: {
142
+ variableName: {
143
+ type: 'string',
144
+ description: 'Variable name to trace',
145
+ },
146
+ file: {
147
+ type: 'string',
148
+ description: 'File path where the variable is defined',
149
+ },
150
+ },
151
+ required: ['variableName', 'file'],
152
+ },
153
+ },
154
+ {
155
+ name: 'trace_dataflow',
156
+ description: `Trace data flow paths from or to a variable/expression.
157
+
158
+ Use this when you need to:
159
+ - Forward trace: "Where does this value flow to?" (assignments, function calls, returns)
160
+ - Backward trace: "Where does this value come from?" (sources, assignments)
161
+ - Both: Full data lineage from sources to sinks
162
+
163
+ Direction options:
164
+ - forward: Follow ASSIGNED_FROM, PASSES_ARGUMENT, FLOWS_INTO edges downstream
165
+ - backward: Follow edges upstream to find data sources
166
+ - both: Trace in both directions for complete context
167
+
168
+ Use cases:
169
+ - Track tainted data: "Does user input reach database query?" (forward from input)
170
+ - Find data sources: "What feeds this API response?" (backward from response)
171
+ - Impact analysis: "If I change this variable, what breaks?" (forward trace)
172
+
173
+ Returns: List of nodes in the data flow chain with edge types and depth.
174
+ Tip: Start with max_depth=5, increase if needed.`,
175
+ inputSchema: {
176
+ type: 'object',
177
+ properties: {
178
+ source: {
179
+ type: 'string',
180
+ description: 'Variable or node ID to trace from',
181
+ },
182
+ file: {
183
+ type: 'string',
184
+ description: 'File path',
185
+ },
186
+ direction: {
187
+ type: 'string',
188
+ description: 'forward, backward, or both (default: forward)',
189
+ enum: ['forward', 'backward', 'both'],
190
+ },
191
+ max_depth: {
192
+ type: 'number',
193
+ description: 'Maximum trace depth (default: 10)',
194
+ },
195
+ limit: {
196
+ type: 'number',
197
+ description: `Max results (default: ${DEFAULT_LIMIT})`,
198
+ },
199
+ detail: {
200
+ type: 'string',
201
+ description: 'Level of detail: summary (counts only), normal (auto-compressed, default), full (every node)',
202
+ enum: ['summary', 'normal', 'full'],
203
+ },
204
+ },
205
+ required: ['source'],
206
+ },
207
+ },
208
+ {
209
+ name: 'check_invariant',
210
+ description: `Check a one-off code invariant using a Datalog rule. Returns violations if broken.
211
+
212
+ Use this for ad-hoc checks without saving a permanent guarantee.
213
+ For persistent rules, use create_guarantee + check_guarantees instead.
214
+
215
+ Use cases:
216
+ - Quick check: "Are there any eval() calls?" — rule: violation(X) :- node(X, "CALL"), attr(X, "name", "eval").
217
+ - Audit: "Functions over 100 lines?" — check for excessive complexity
218
+ - Pre-commit: "Any new SQL injection risks?" — one-time check before pushing
219
+
220
+ Returns: List of nodes violating the rule, with file and line info.`,
221
+ inputSchema: {
222
+ type: 'object',
223
+ properties: {
224
+ rule: {
225
+ type: 'string',
226
+ description: 'Datalog rule defining violation/1',
227
+ },
228
+ description: {
229
+ type: 'string',
230
+ description: 'Human-readable description',
231
+ },
232
+ limit: {
233
+ type: 'number',
234
+ description: `Max violations (default: ${DEFAULT_LIMIT})`,
235
+ },
236
+ offset: {
237
+ type: 'number',
238
+ description: 'Skip first N violations (default: 0)',
239
+ },
240
+ },
241
+ required: ['rule'],
242
+ },
243
+ },
244
+ ];
245
+ //# sourceMappingURL=query-tools.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"query-tools.js","sourceRoot":"","sources":["../../src/definitions/query-tools.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAEvD,MAAM,CAAC,MAAM,WAAW,GAAqB;IAC3C;QACE,IAAI,EAAE,aAAa;QACnB,WAAW,EAAE;;;;;;;;;;;;;;;;;;;;;4DAqB2C;QACxD,WAAW,EAAE;YACX,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACV,KAAK,EAAE;oBACL,IAAI,EAAE,QAAQ;oBACd,WAAW,EAAE,gGAAgG;iBAC9G;gBACD,QAAQ,EAAE;oBACR,IAAI,EAAE,QAAQ;oBACd,WAAW,EAAE,iDAAiD;oBAC9D,IAAI,EAAE,CAAC,SAAS,EAAE,QAAQ,CAAC;iBAC5B;gBACD,KAAK,EAAE;oBACL,IAAI,EAAE,QAAQ;oBACd,WAAW,EAAE,mCAAmC,aAAa,UAAU,SAAS,GAAG;iBACpF;gBACD,MAAM,EAAE;oBACN,IAAI,EAAE,QAAQ;oBACd,WAAW,EAAE,kDAAkD;iBAChE;gBACD,OAAO,EAAE;oBACP,IAAI,EAAE,SAAS;oBACf,WAAW,EAAE,0DAA0D;iBACxE;gBACD,KAAK,EAAE;oBACL,IAAI,EAAE,SAAS;oBACf,WAAW,EAAE,uFAAuF;iBACrG;aACF;YACD,QAAQ,EAAE,CAAC,OAAO,CAAC;SACpB;KACF;IACD;QACE,IAAI,EAAE,YAAY;QAClB,WAAW,EAAE;;;;;;;qGAOoF;QACjG,WA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4B,aAAa,GAAG;iBAC1D;gBACD,MAAM,EAAE;oBACN,IAAI,EAAE,QAAQ;oBACd,WAAW,EAAE,sCAAsC;iBACpD;aACF;YACD,QAAQ,EAAE,CAAC,MAAM,CAAC;SACnB;KACF;CACF,CAAC"}
@@ -0,0 +1,21 @@
1
+ /**
2
+ * MCP Tool Definition Types
3
+ */
4
+ export interface SchemaProperty {
5
+ type: string;
6
+ description?: string;
7
+ enum?: string[];
8
+ items?: SchemaProperty;
9
+ properties?: Record<string, SchemaProperty>;
10
+ required?: string[];
11
+ }
12
+ export interface ToolDefinition {
13
+ name: string;
14
+ description: string;
15
+ inputSchema: {
16
+ type: 'object';
17
+ properties: Record<string, SchemaProperty>;
18
+ required?: string[];
19
+ };
20
+ }
21
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/definitions/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,KAAK,CAAC,EAAE,cAAc,CAAC;IACvB,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IAC5C,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;CACrB;AAED,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE;QACX,IAAI,EAAE,QAAQ,CAAC;QACf,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;QAC3C,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;KACrB,CAAC;CACH"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * MCP Tool Definition Types
3
+ */
4
+ export {};
5
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/definitions/types.ts"],"names":[],"mappings":"AAAA;;GAEG"}
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Grafema MCP Dev Proxy
4
+ *
5
+ * A thin stdio proxy that sits between Claude Code and the real MCP server.
6
+ * It transparently forwards all JSON-RPC messages, with two exceptions:
7
+ *
8
+ * 1. Intercepts `tools/call` with `name: "reload"` — kills and respawns the
9
+ * child server process so it picks up new code from dist/ after `pnpm build`.
10
+ *
11
+ * 2. Injects a `reload` tool definition into `tools/list` responses from the
12
+ * real server.
13
+ *
14
+ * Architecture:
15
+ * Claude Code <--stdio--> dev-proxy <--stdio--> real server.js
16
+ *
17
+ * Usage in .claude/mcp.json:
18
+ * {
19
+ * "grafema-dev": {
20
+ * "command": "node",
21
+ * "args": ["packages/mcp/dist/dev-proxy.js", "--project", "/path/to/project"]
22
+ * }
23
+ * }
24
+ *
25
+ * The MCP SDK uses newline-delimited JSON framing (each message is a single
26
+ * JSON object followed by '\n'). No Content-Length headers.
27
+ */
28
+ export {};
29
+ //# sourceMappingURL=dev-proxy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dev-proxy.d.ts","sourceRoot":"","sources":["../src/dev-proxy.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG"}