sysmledgraph 0.7.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.
Files changed (309) hide show
  1. package/README.md +71 -0
  2. package/dist/bin/cli.d.ts +6 -0
  3. package/dist/bin/cli.d.ts.map +1 -0
  4. package/dist/bin/cli.js +61 -0
  5. package/dist/bin/cli.js.map +1 -0
  6. package/dist/mcp/index.d.ts +3 -0
  7. package/dist/mcp/index.d.ts.map +1 -0
  8. package/dist/mcp/index.js +8 -0
  9. package/dist/mcp/index.js.map +1 -0
  10. package/dist/src/cli/commands.d.ts +22 -0
  11. package/dist/src/cli/commands.d.ts.map +1 -0
  12. package/dist/src/cli/commands.js +87 -0
  13. package/dist/src/cli/commands.js.map +1 -0
  14. package/dist/src/discovery/find-sysml.d.ts +16 -0
  15. package/dist/src/discovery/find-sysml.d.ts.map +1 -0
  16. package/dist/src/discovery/find-sysml.js +30 -0
  17. package/dist/src/discovery/find-sysml.js.map +1 -0
  18. package/dist/src/discovery/load-order.d.ts +11 -0
  19. package/dist/src/discovery/load-order.d.ts.map +1 -0
  20. package/dist/src/discovery/load-order.js +85 -0
  21. package/dist/src/discovery/load-order.js.map +1 -0
  22. package/dist/src/graph/connection.d.ts +6 -0
  23. package/dist/src/graph/connection.d.ts.map +1 -0
  24. package/dist/src/graph/connection.js +7 -0
  25. package/dist/src/graph/connection.js.map +1 -0
  26. package/dist/src/graph/graph-store.d.ts +37 -0
  27. package/dist/src/graph/graph-store.d.ts.map +1 -0
  28. package/dist/src/graph/graph-store.js +108 -0
  29. package/dist/src/graph/graph-store.js.map +1 -0
  30. package/dist/src/graph/schema.d.ts +13 -0
  31. package/dist/src/graph/schema.d.ts.map +1 -0
  32. package/dist/src/graph/schema.js +21 -0
  33. package/dist/src/graph/schema.js.map +1 -0
  34. package/dist/src/index.d.ts +14 -0
  35. package/dist/src/index.d.ts.map +1 -0
  36. package/dist/src/index.js +14 -0
  37. package/dist/src/index.js.map +1 -0
  38. package/dist/src/indexer/indexer.d.ts +20 -0
  39. package/dist/src/indexer/indexer.d.ts.map +1 -0
  40. package/dist/src/indexer/indexer.js +56 -0
  41. package/dist/src/indexer/indexer.js.map +1 -0
  42. package/dist/src/indexer/pipeline-phases.d.ts +8 -0
  43. package/dist/src/indexer/pipeline-phases.d.ts.map +1 -0
  44. package/dist/src/indexer/pipeline-phases.js +14 -0
  45. package/dist/src/indexer/pipeline-phases.js.map +1 -0
  46. package/dist/src/mcp/resources/context.d.ts +6 -0
  47. package/dist/src/mcp/resources/context.d.ts.map +1 -0
  48. package/dist/src/mcp/resources/context.js +45 -0
  49. package/dist/src/mcp/resources/context.js.map +1 -0
  50. package/dist/src/mcp/resources/schema.d.ts +6 -0
  51. package/dist/src/mcp/resources/schema.d.ts.map +1 -0
  52. package/dist/src/mcp/resources/schema.js +14 -0
  53. package/dist/src/mcp/resources/schema.js.map +1 -0
  54. package/dist/src/mcp/server.d.ts +8 -0
  55. package/dist/src/mcp/server.d.ts.map +1 -0
  56. package/dist/src/mcp/server.js +175 -0
  57. package/dist/src/mcp/server.js.map +1 -0
  58. package/dist/src/mcp/tools/clean-index.d.ts +12 -0
  59. package/dist/src/mcp/tools/clean-index.d.ts.map +1 -0
  60. package/dist/src/mcp/tools/clean-index.js +22 -0
  61. package/dist/src/mcp/tools/clean-index.js.map +1 -0
  62. package/dist/src/mcp/tools/context.d.ts +14 -0
  63. package/dist/src/mcp/tools/context.d.ts.map +1 -0
  64. package/dist/src/mcp/tools/context.js +51 -0
  65. package/dist/src/mcp/tools/context.js.map +1 -0
  66. package/dist/src/mcp/tools/cypher.d.ts +13 -0
  67. package/dist/src/mcp/tools/cypher.d.ts.map +1 -0
  68. package/dist/src/mcp/tools/cypher.js +25 -0
  69. package/dist/src/mcp/tools/cypher.js.map +1 -0
  70. package/dist/src/mcp/tools/generate-map.d.ts +13 -0
  71. package/dist/src/mcp/tools/generate-map.d.ts.map +1 -0
  72. package/dist/src/mcp/tools/generate-map.js +96 -0
  73. package/dist/src/mcp/tools/generate-map.js.map +1 -0
  74. package/dist/src/mcp/tools/impact.d.ts +14 -0
  75. package/dist/src/mcp/tools/impact.d.ts.map +1 -0
  76. package/dist/src/mcp/tools/impact.js +47 -0
  77. package/dist/src/mcp/tools/impact.js.map +1 -0
  78. package/dist/src/mcp/tools/index-db-graph.d.ts +14 -0
  79. package/dist/src/mcp/tools/index-db-graph.d.ts.map +1 -0
  80. package/dist/src/mcp/tools/index-db-graph.js +32 -0
  81. package/dist/src/mcp/tools/index-db-graph.js.map +1 -0
  82. package/dist/src/mcp/tools/list-indexed.d.ts +9 -0
  83. package/dist/src/mcp/tools/list-indexed.d.ts.map +1 -0
  84. package/dist/src/mcp/tools/list-indexed.js +14 -0
  85. package/dist/src/mcp/tools/list-indexed.js.map +1 -0
  86. package/dist/src/mcp/tools/query.d.ts +14 -0
  87. package/dist/src/mcp/tools/query.d.ts.map +1 -0
  88. package/dist/src/mcp/tools/query.js +47 -0
  89. package/dist/src/mcp/tools/query.js.map +1 -0
  90. package/dist/src/mcp/tools/rename.d.ts +19 -0
  91. package/dist/src/mcp/tools/rename.d.ts.map +1 -0
  92. package/dist/src/mcp/tools/rename.js +46 -0
  93. package/dist/src/mcp/tools/rename.js.map +1 -0
  94. package/dist/src/parser/lsp-client.d.ts +52 -0
  95. package/dist/src/parser/lsp-client.d.ts.map +1 -0
  96. package/dist/src/parser/lsp-client.js +230 -0
  97. package/dist/src/parser/lsp-client.js.map +1 -0
  98. package/dist/src/parser/lsp-server-path.d.ts +10 -0
  99. package/dist/src/parser/lsp-server-path.d.ts.map +1 -0
  100. package/dist/src/parser/lsp-server-path.js +29 -0
  101. package/dist/src/parser/lsp-server-path.js.map +1 -0
  102. package/dist/src/parser/symbols.d.ts +13 -0
  103. package/dist/src/parser/symbols.d.ts.map +1 -0
  104. package/dist/src/parser/symbols.js +150 -0
  105. package/dist/src/parser/symbols.js.map +1 -0
  106. package/dist/src/parser/sysml-mcp-client.d.ts +109 -0
  107. package/dist/src/parser/sysml-mcp-client.d.ts.map +1 -0
  108. package/dist/src/parser/sysml-mcp-client.js +185 -0
  109. package/dist/src/parser/sysml-mcp-client.js.map +1 -0
  110. package/dist/src/storage/clean.d.ts +15 -0
  111. package/dist/src/storage/clean.d.ts.map +1 -0
  112. package/dist/src/storage/clean.js +44 -0
  113. package/dist/src/storage/clean.js.map +1 -0
  114. package/dist/src/storage/list.d.ts +9 -0
  115. package/dist/src/storage/list.d.ts.map +1 -0
  116. package/dist/src/storage/list.js +12 -0
  117. package/dist/src/storage/list.js.map +1 -0
  118. package/dist/src/storage/location.d.ts +22 -0
  119. package/dist/src/storage/location.d.ts.map +1 -0
  120. package/dist/src/storage/location.js +36 -0
  121. package/dist/src/storage/location.js.map +1 -0
  122. package/dist/src/storage/registry.d.ts +14 -0
  123. package/dist/src/storage/registry.d.ts.map +1 -0
  124. package/dist/src/storage/registry.js +59 -0
  125. package/dist/src/storage/registry.js.map +1 -0
  126. package/dist/src/symbol-to-graph/mapping.d.ts +17 -0
  127. package/dist/src/symbol-to-graph/mapping.d.ts.map +1 -0
  128. package/dist/src/symbol-to-graph/mapping.js +102 -0
  129. package/dist/src/symbol-to-graph/mapping.js.map +1 -0
  130. package/dist/src/types.d.ts +40 -0
  131. package/dist/src/types.d.ts.map +1 -0
  132. package/dist/src/types.js +35 -0
  133. package/dist/src/types.js.map +1 -0
  134. package/dist/src/worker/client.d.ts +21 -0
  135. package/dist/src/worker/client.d.ts.map +1 -0
  136. package/dist/src/worker/client.js +126 -0
  137. package/dist/src/worker/client.js.map +1 -0
  138. package/dist/src/worker/gateway.d.ts +79 -0
  139. package/dist/src/worker/gateway.d.ts.map +1 -0
  140. package/dist/src/worker/gateway.js +93 -0
  141. package/dist/src/worker/gateway.js.map +1 -0
  142. package/dist/src/worker/graph-worker.d.ts +7 -0
  143. package/dist/src/worker/graph-worker.d.ts.map +1 -0
  144. package/dist/src/worker/graph-worker.js +91 -0
  145. package/dist/src/worker/graph-worker.js.map +1 -0
  146. package/dist/src/worker/protocol.d.ts +21 -0
  147. package/dist/src/worker/protocol.d.ts.map +1 -0
  148. package/dist/src/worker/protocol.js +9 -0
  149. package/dist/src/worker/protocol.js.map +1 -0
  150. package/docs/INSTALL.md +16 -0
  151. package/docs/MCP_CLIENT_TEMPLATE_ANALYSIS.md +196 -0
  152. package/docs/MCP_INTERACTION_GUIDE.md +201 -0
  153. package/docs/MCP_SERVER_FOR_CURSOR.md +124 -0
  154. package/docs/PLAN.md +58 -0
  155. package/docs/PLAN_INDEPENDENT_LSP.md +145 -0
  156. package/docs/SKILL_DESIGN_PATTERNS.md +305 -0
  157. package/docs/TOOLS.md +317 -0
  158. package/lsp/README.md +41 -0
  159. package/lsp/node_modules/.bin/sysml-mcp +12 -0
  160. package/lsp/node_modules/.bin/sysml-mcp.cmd +9 -0
  161. package/lsp/node_modules/.bin/sysml-mcp.ps1 +16 -0
  162. package/lsp/node_modules/.package-lock.json +22 -0
  163. package/lsp/node_modules/sysml-v2-lsp/CHANGELOG.md +188 -0
  164. package/lsp/node_modules/sysml-v2-lsp/LICENSE +21 -0
  165. package/lsp/node_modules/sysml-v2-lsp/README.md +172 -0
  166. package/lsp/node_modules/sysml-v2-lsp/dist/server/mcpServer.js +167 -0
  167. package/lsp/node_modules/sysml-v2-lsp/dist/server/server.js +142 -0
  168. package/lsp/node_modules/sysml-v2-lsp/index.cjs +23 -0
  169. package/lsp/node_modules/sysml-v2-lsp/package.json +131 -0
  170. package/lsp/node_modules/sysml-v2-lsp/sysml.library/.project +17 -0
  171. package/lsp/node_modules/sysml-v2-lsp/sysml.library/.settings/org.eclipse.jdt.core.prefs +11 -0
  172. package/lsp/node_modules/sysml-v2-lsp/sysml.library/Domain Libraries/Analysis/.meta.json +10 -0
  173. package/lsp/node_modules/sysml-v2-lsp/sysml.library/Domain Libraries/Analysis/.project.json +27 -0
  174. package/lsp/node_modules/sysml-v2-lsp/sysml.library/Domain Libraries/Analysis/AnalysisTooling.sysml +34 -0
  175. package/lsp/node_modules/sysml-v2-lsp/sysml.library/Domain Libraries/Analysis/SampledFunctions.sysml +119 -0
  176. package/lsp/node_modules/sysml-v2-lsp/sysml.library/Domain Libraries/Analysis/StateSpaceRepresentation.sysml +143 -0
  177. package/lsp/node_modules/sysml-v2-lsp/sysml.library/Domain Libraries/Analysis/TradeStudies.sysml +171 -0
  178. package/lsp/node_modules/sysml-v2-lsp/sysml.library/Domain Libraries/Cause and Effect/.meta.json +8 -0
  179. package/lsp/node_modules/sysml-v2-lsp/sysml.library/Domain Libraries/Cause and Effect/.project.json +23 -0
  180. package/lsp/node_modules/sysml-v2-lsp/sysml.library/Domain Libraries/Cause and Effect/CausationConnections.sysml +83 -0
  181. package/lsp/node_modules/sysml-v2-lsp/sysml.library/Domain Libraries/Cause and Effect/CauseAndEffect.sysml +81 -0
  182. package/lsp/node_modules/sysml-v2-lsp/sysml.library/Domain Libraries/Geometry/.meta.json +8 -0
  183. package/lsp/node_modules/sysml-v2-lsp/sysml.library/Domain Libraries/Geometry/.project.json +27 -0
  184. package/lsp/node_modules/sysml-v2-lsp/sysml.library/Domain Libraries/Geometry/ShapeItems.sysml +899 -0
  185. package/lsp/node_modules/sysml-v2-lsp/sysml.library/Domain Libraries/Geometry/SpatialItems.sysml +168 -0
  186. package/lsp/node_modules/sysml-v2-lsp/sysml.library/Domain Libraries/Metadata/.meta.json +10 -0
  187. package/lsp/node_modules/sysml-v2-lsp/sysml.library/Domain Libraries/Metadata/.project.json +19 -0
  188. package/lsp/node_modules/sysml-v2-lsp/sysml.library/Domain Libraries/Metadata/ImageMetadata.sysml +78 -0
  189. package/lsp/node_modules/sysml-v2-lsp/sysml.library/Domain Libraries/Metadata/ModelingMetadata.sysml +143 -0
  190. package/lsp/node_modules/sysml-v2-lsp/sysml.library/Domain Libraries/Metadata/ParametersOfInterestMetadata.sysml +39 -0
  191. package/lsp/node_modules/sysml-v2-lsp/sysml.library/Domain Libraries/Metadata/RiskMetadata.sysml +100 -0
  192. package/lsp/node_modules/sysml-v2-lsp/sysml.library/Domain Libraries/Quantities and Units/.meta.json +29 -0
  193. package/lsp/node_modules/sysml-v2-lsp/sysml.library/Domain Libraries/Quantities and Units/.project.json +23 -0
  194. package/lsp/node_modules/sysml-v2-lsp/sysml.library/Domain Libraries/Quantities and Units/ISQ.sysml +42 -0
  195. package/lsp/node_modules/sysml-v2-lsp/sysml.library/Domain Libraries/Quantities and Units/ISQAcoustics.sysml +439 -0
  196. package/lsp/node_modules/sysml-v2-lsp/sysml.library/Domain Libraries/Quantities and Units/ISQAtomicNuclear.sysml +2726 -0
  197. package/lsp/node_modules/sysml-v2-lsp/sysml.library/Domain Libraries/Quantities and Units/ISQBase.sysml +206 -0
  198. package/lsp/node_modules/sysml-v2-lsp/sysml.library/Domain Libraries/Quantities and Units/ISQCharacteristicNumbers.sysml +1991 -0
  199. package/lsp/node_modules/sysml-v2-lsp/sysml.library/Domain Libraries/Quantities and Units/ISQChemistryMolecular.sysml +1353 -0
  200. package/lsp/node_modules/sysml-v2-lsp/sysml.library/Domain Libraries/Quantities and Units/ISQCondensedMatter.sysml +1223 -0
  201. package/lsp/node_modules/sysml-v2-lsp/sysml.library/Domain Libraries/Quantities and Units/ISQElectromagnetism.sysml +2333 -0
  202. package/lsp/node_modules/sysml-v2-lsp/sysml.library/Domain Libraries/Quantities and Units/ISQInformation.sysml +958 -0
  203. package/lsp/node_modules/sysml-v2-lsp/sysml.library/Domain Libraries/Quantities and Units/ISQLight.sysml +1537 -0
  204. package/lsp/node_modules/sysml-v2-lsp/sysml.library/Domain Libraries/Quantities and Units/ISQMechanics.sysml +1564 -0
  205. package/lsp/node_modules/sysml-v2-lsp/sysml.library/Domain Libraries/Quantities and Units/ISQSpaceTime.sysml +1169 -0
  206. package/lsp/node_modules/sysml-v2-lsp/sysml.library/Domain Libraries/Quantities and Units/ISQThermodynamics.sysml +1256 -0
  207. package/lsp/node_modules/sysml-v2-lsp/sysml.library/Domain Libraries/Quantities and Units/MeasurementRefCalculations.sysml +30 -0
  208. package/lsp/node_modules/sysml-v2-lsp/sysml.library/Domain Libraries/Quantities and Units/MeasurementReferences.sysml +526 -0
  209. package/lsp/node_modules/sysml-v2-lsp/sysml.library/Domain Libraries/Quantities and Units/Quantities.sysml +107 -0
  210. package/lsp/node_modules/sysml-v2-lsp/sysml.library/Domain Libraries/Quantities and Units/QuantityCalculations.sysml +70 -0
  211. package/lsp/node_modules/sysml-v2-lsp/sysml.library/Domain Libraries/Quantities and Units/SI.sysml +378 -0
  212. package/lsp/node_modules/sysml-v2-lsp/sysml.library/Domain Libraries/Quantities and Units/SIPrefixes.sysml +48 -0
  213. package/lsp/node_modules/sysml-v2-lsp/sysml.library/Domain Libraries/Quantities and Units/TensorCalculations.sysml +50 -0
  214. package/lsp/node_modules/sysml-v2-lsp/sysml.library/Domain Libraries/Quantities and Units/Time.sysml +274 -0
  215. package/lsp/node_modules/sysml-v2-lsp/sysml.library/Domain Libraries/Quantities and Units/USCustomaryUnits.sysml +260 -0
  216. package/lsp/node_modules/sysml-v2-lsp/sysml.library/Domain Libraries/Quantities and Units/VectorCalculations.sysml +62 -0
  217. package/lsp/node_modules/sysml-v2-lsp/sysml.library/Domain Libraries/Requirement Derivation/.meta.json +8 -0
  218. package/lsp/node_modules/sysml-v2-lsp/sysml.library/Domain Libraries/Requirement Derivation/.project.json +19 -0
  219. package/lsp/node_modules/sysml-v2-lsp/sysml.library/Domain Libraries/Requirement Derivation/DerivationConnections.sysml +63 -0
  220. package/lsp/node_modules/sysml-v2-lsp/sysml.library/Domain Libraries/Requirement Derivation/RequirementDerivation.sysml +39 -0
  221. package/lsp/node_modules/sysml-v2-lsp/sysml.library/Kernel Libraries/Kernel Data Type Library/.meta.json +9 -0
  222. package/lsp/node_modules/sysml-v2-lsp/sysml.library/Kernel Libraries/Kernel Data Type Library/.project.json +11 -0
  223. package/lsp/node_modules/sysml-v2-lsp/sysml.library/Kernel Libraries/Kernel Data Type Library/Collections.kerml +147 -0
  224. package/lsp/node_modules/sysml-v2-lsp/sysml.library/Kernel Libraries/Kernel Data Type Library/ScalarValues.kerml +23 -0
  225. package/lsp/node_modules/sysml-v2-lsp/sysml.library/Kernel Libraries/Kernel Data Type Library/VectorValues.kerml +64 -0
  226. package/lsp/node_modules/sysml-v2-lsp/sysml.library/Kernel Libraries/Kernel Function Library/.meta.json +23 -0
  227. package/lsp/node_modules/sysml-v2-lsp/sysml.library/Kernel Libraries/Kernel Function Library/.project.json +15 -0
  228. package/lsp/node_modules/sysml-v2-lsp/sysml.library/Kernel Libraries/Kernel Function Library/BaseFunctions.kerml +80 -0
  229. package/lsp/node_modules/sysml-v2-lsp/sysml.library/Kernel Libraries/Kernel Function Library/BooleanFunctions.kerml +22 -0
  230. package/lsp/node_modules/sysml-v2-lsp/sysml.library/Kernel Libraries/Kernel Function Library/CollectionFunctions.kerml +68 -0
  231. package/lsp/node_modules/sysml-v2-lsp/sysml.library/Kernel Libraries/Kernel Function Library/ComplexFunctions.kerml +47 -0
  232. package/lsp/node_modules/sysml-v2-lsp/sysml.library/Kernel Libraries/Kernel Function Library/ControlFunctions.kerml +117 -0
  233. package/lsp/node_modules/sysml-v2-lsp/sysml.library/Kernel Libraries/Kernel Function Library/DataFunctions.kerml +43 -0
  234. package/lsp/node_modules/sysml-v2-lsp/sysml.library/Kernel Libraries/Kernel Function Library/IntegerFunctions.kerml +43 -0
  235. package/lsp/node_modules/sysml-v2-lsp/sysml.library/Kernel Libraries/Kernel Function Library/NaturalFunctions.kerml +27 -0
  236. package/lsp/node_modules/sysml-v2-lsp/sysml.library/Kernel Libraries/Kernel Function Library/NumericalFunctions.kerml +43 -0
  237. package/lsp/node_modules/sysml-v2-lsp/sysml.library/Kernel Libraries/Kernel Function Library/OccurrenceFunctions.kerml +154 -0
  238. package/lsp/node_modules/sysml-v2-lsp/sysml.library/Kernel Libraries/Kernel Function Library/RationalFunctions.kerml +49 -0
  239. package/lsp/node_modules/sysml-v2-lsp/sysml.library/Kernel Libraries/Kernel Function Library/RealFunctions.kerml +56 -0
  240. package/lsp/node_modules/sysml-v2-lsp/sysml.library/Kernel Libraries/Kernel Function Library/ScalarFunctions.kerml +33 -0
  241. package/lsp/node_modules/sysml-v2-lsp/sysml.library/Kernel Libraries/Kernel Function Library/SequenceFunctions.kerml +111 -0
  242. package/lsp/node_modules/sysml-v2-lsp/sysml.library/Kernel Libraries/Kernel Function Library/StringFunctions.kerml +25 -0
  243. package/lsp/node_modules/sysml-v2-lsp/sysml.library/Kernel Libraries/Kernel Function Library/TrigFunctions.kerml +35 -0
  244. package/lsp/node_modules/sysml-v2-lsp/sysml.library/Kernel Libraries/Kernel Function Library/VectorFunctions.kerml +273 -0
  245. package/lsp/node_modules/sysml-v2-lsp/sysml.library/Kernel Libraries/Kernel Semantic Library/.meta.json +22 -0
  246. package/lsp/node_modules/sysml-v2-lsp/sysml.library/Kernel Libraries/Kernel Semantic Library/.project.json +15 -0
  247. package/lsp/node_modules/sysml-v2-lsp/sysml.library/Kernel Libraries/Kernel Semantic Library/Base.kerml +95 -0
  248. package/lsp/node_modules/sysml-v2-lsp/sysml.library/Kernel Libraries/Kernel Semantic Library/Clocks.kerml +156 -0
  249. package/lsp/node_modules/sysml-v2-lsp/sysml.library/Kernel Libraries/Kernel Semantic Library/ControlPerformances.kerml +135 -0
  250. package/lsp/node_modules/sysml-v2-lsp/sysml.library/Kernel Libraries/Kernel Semantic Library/FeatureReferencingPerformances.kerml +190 -0
  251. package/lsp/node_modules/sysml-v2-lsp/sysml.library/Kernel Libraries/Kernel Semantic Library/KerML.kerml +483 -0
  252. package/lsp/node_modules/sysml-v2-lsp/sysml.library/Kernel Libraries/Kernel Semantic Library/Links.kerml +67 -0
  253. package/lsp/node_modules/sysml-v2-lsp/sysml.library/Kernel Libraries/Kernel Semantic Library/Metaobjects.kerml +58 -0
  254. package/lsp/node_modules/sysml-v2-lsp/sysml.library/Kernel Libraries/Kernel Semantic Library/Objects.kerml +212 -0
  255. package/lsp/node_modules/sysml-v2-lsp/sysml.library/Kernel Libraries/Kernel Semantic Library/Observation.kerml +161 -0
  256. package/lsp/node_modules/sysml-v2-lsp/sysml.library/Kernel Libraries/Kernel Semantic Library/Occurrences.kerml +992 -0
  257. package/lsp/node_modules/sysml-v2-lsp/sysml.library/Kernel Libraries/Kernel Semantic Library/Performances.kerml +293 -0
  258. package/lsp/node_modules/sysml-v2-lsp/sysml.library/Kernel Libraries/Kernel Semantic Library/SpatialFrames.kerml +197 -0
  259. package/lsp/node_modules/sysml-v2-lsp/sysml.library/Kernel Libraries/Kernel Semantic Library/StatePerformances.kerml +145 -0
  260. package/lsp/node_modules/sysml-v2-lsp/sysml.library/Kernel Libraries/Kernel Semantic Library/Transfers.kerml +281 -0
  261. package/lsp/node_modules/sysml-v2-lsp/sysml.library/Kernel Libraries/Kernel Semantic Library/TransitionPerformances.kerml +66 -0
  262. package/lsp/node_modules/sysml-v2-lsp/sysml.library/Kernel Libraries/Kernel Semantic Library/Triggers.kerml +188 -0
  263. package/lsp/node_modules/sysml-v2-lsp/sysml.library/Systems Library/.meta.json +27 -0
  264. package/lsp/node_modules/sysml-v2-lsp/sysml.library/Systems Library/.project.json +19 -0
  265. package/lsp/node_modules/sysml-v2-lsp/sysml.library/Systems Library/Actions.sysml +552 -0
  266. package/lsp/node_modules/sysml-v2-lsp/sysml.library/Systems Library/Allocations.sysml +29 -0
  267. package/lsp/node_modules/sysml-v2-lsp/sysml.library/Systems Library/AnalysisCases.sysml +38 -0
  268. package/lsp/node_modules/sysml-v2-lsp/sysml.library/Systems Library/Attributes.sysml +25 -0
  269. package/lsp/node_modules/sysml-v2-lsp/sysml.library/Systems Library/Calculations.sysml +37 -0
  270. package/lsp/node_modules/sysml-v2-lsp/sysml.library/Systems Library/Cases.sysml +71 -0
  271. package/lsp/node_modules/sysml-v2-lsp/sysml.library/Systems Library/Connections.sysml +60 -0
  272. package/lsp/node_modules/sysml-v2-lsp/sysml.library/Systems Library/Constraints.sysml +44 -0
  273. package/lsp/node_modules/sysml-v2-lsp/sysml.library/Systems Library/Flows.sysml +126 -0
  274. package/lsp/node_modules/sysml-v2-lsp/sysml.library/Systems Library/Interfaces.sysml +89 -0
  275. package/lsp/node_modules/sysml-v2-lsp/sysml.library/Systems Library/Items.sysml +153 -0
  276. package/lsp/node_modules/sysml-v2-lsp/sysml.library/Systems Library/Metadata.sysml +32 -0
  277. package/lsp/node_modules/sysml-v2-lsp/sysml.library/Systems Library/Parts.sysml +81 -0
  278. package/lsp/node_modules/sysml-v2-lsp/sysml.library/Systems Library/Ports.sysml +54 -0
  279. package/lsp/node_modules/sysml-v2-lsp/sysml.library/Systems Library/Requirements.sysml +194 -0
  280. package/lsp/node_modules/sysml-v2-lsp/sysml.library/Systems Library/StandardViewDefinitions.sysml +123 -0
  281. package/lsp/node_modules/sysml-v2-lsp/sysml.library/Systems Library/States.sysml +103 -0
  282. package/lsp/node_modules/sysml-v2-lsp/sysml.library/Systems Library/SysML.sysml +539 -0
  283. package/lsp/node_modules/sysml-v2-lsp/sysml.library/Systems Library/UseCases.sysml +57 -0
  284. package/lsp/node_modules/sysml-v2-lsp/sysml.library/Systems Library/VerificationCases.sysml +103 -0
  285. package/lsp/node_modules/sysml-v2-lsp/sysml.library/Systems Library/Views.sysml +164 -0
  286. package/lsp/package-lock.json +30 -0
  287. package/lsp/package.json +15 -0
  288. package/lsp/test-server.mjs +120 -0
  289. package/package.json +61 -0
  290. package/scripts/access-sysml-mcp.mjs +45 -0
  291. package/scripts/check-sysml-v2-lsp-version.mjs +39 -0
  292. package/scripts/clean.mjs +14 -0
  293. package/scripts/compare-mcp-vs-lsp-symbols.mjs +76 -0
  294. package/scripts/debug-index.mjs +23 -0
  295. package/scripts/debug-lsp-symbols.mjs +62 -0
  296. package/scripts/deploy-skills.mjs +43 -0
  297. package/scripts/example-sysml-mcp.mjs +27 -0
  298. package/scripts/export-graph.mjs +80 -0
  299. package/scripts/generate-map.mjs +110 -0
  300. package/scripts/index-and-map.mjs +43 -0
  301. package/scripts/index-and-query.mjs +39 -0
  302. package/scripts/query-one.mjs +34 -0
  303. package/scripts/setup-lsp.mjs +36 -0
  304. package/scripts/test-lsp.mjs +55 -0
  305. package/scripts/test-mcp-debug.mjs +32 -0
  306. package/scripts/test-mcp-sysml.mjs +75 -0
  307. package/scripts/test-mcp-tools.mjs +185 -0
  308. package/scripts/test-sysml-mcp-from-node_modules.mjs +56 -0
  309. package/scripts/validate-sysml-file.mjs +69 -0
@@ -0,0 +1,196 @@
1
+ # MCP Client Template Analysis
2
+
3
+ Analysis of [andrea9293/mcp-client-template](https://github.com/andrea9293/mcp-client-template) patterns, protocol, and behavior.
4
+
5
+ ## Architecture
6
+
7
+ **Two-tier web app:**
8
+ - **Frontend** (Vite + TypeScript): Web UI for managing servers and sending commands
9
+ - **Backend** (Express + TypeScript): REST API that wraps MCP SDK client operations
10
+
11
+ **Data persistence:**
12
+ - `data/mcp-servers.json` — Server configurations (command, type, args)
13
+ - `data/auth-tokens.json` — OAuth tokens per server
14
+
15
+ ## Protocol & Transport
16
+
17
+ ### Transport Types Supported
18
+
19
+ 1. **`stdio`** — Newline-delimited JSON over stdin/stdout
20
+ - Uses `StdioClientTransport` from SDK
21
+ - Spawns process: `{ command, args }`
22
+ - Example: `{ type: 'stdio', command: 'node', args: ['server.js'] }`
23
+
24
+ 2. **`httpstream`** — Streamable HTTP (long-polling or streaming)
25
+ - Uses `StreamableHTTPClientTransport` from SDK
26
+ - Command is the server URL
27
+ - Example: `{ type: 'httpstream', command: 'https://mcp-server.example.com' }`
28
+
29
+ 3. **`sse`** — Server-Sent Events
30
+ - Uses `SSEClientTransport` from SDK
31
+ - Command is the server URL
32
+ - Example: `{ type: 'sse', command: 'https://mcp-server.example.com/events' }`
33
+
34
+ ### MCP SDK Usage
35
+
36
+ ```typescript
37
+ import { Client } from '@modelcontextprotocol/sdk/client/index.js';
38
+ import { StdioClientTransport } from '@modelcontextprotocol/sdk/client/stdio.js';
39
+
40
+ const client = new Client({ name: 'my-client', version: '1.0.0' });
41
+ const transport = new StdioClientTransport({ command: 'node', args: ['server.js'] });
42
+ await client.connect(transport); // ← initialize happens here
43
+ // Then: client.request({ method: 'tools/list' }, schema)
44
+ ```
45
+
46
+ **Key point:** The SDK `Client.connect(transport)` handles the full MCP lifecycle:
47
+ 1. Spawns process (for stdio) or opens connection (for HTTP/SSE)
48
+ 2. Sends `initialize` request
49
+ 3. Waits for `initialize` response
50
+ 4. Sends `notifications/initialized`
51
+ 5. Client is ready for `tools/list`, `tools/call`, etc.
52
+
53
+ ## Connection Pattern
54
+
55
+ **Per-request connection:**
56
+ - Each `/mcp` API call creates a new `Client` + `Transport`
57
+ - Connects, makes request(s), then closes
58
+ - No connection pooling or reuse
59
+
60
+ **Why:** Simpler error handling; each request is isolated. Trade-off: slower (reconnect cost per request).
61
+
62
+ ## OAuth2.1 Flow
63
+
64
+ 1. **First connect attempt** → `UnauthorizedError` thrown
65
+ 2. **Extract auth URL** from `OAuthClientProvider.redirectToAuthorization()`
66
+ 3. **Return 401 with `authUrl`** to frontend
67
+ 4. **User completes OAuth** in browser → redirects to `/oauth/callback`
68
+ 5. **Backend calls `transport.finishAuth(code)`**
69
+ 6. **Reconnect** with authenticated transport
70
+ 7. **Save tokens** to `auth-tokens.json` for future use
71
+
72
+ **Token reuse:** On subsequent connects, if tokens exist, they're loaded into the OAuth provider before connecting.
73
+
74
+ ## API Endpoints
75
+
76
+ ### `POST /add-server`
77
+ - Adds server config to `mcp-servers.json`
78
+ - Body: `{ id, command, type, args }`
79
+ - Persists immediately
80
+
81
+ ### `GET /servers`
82
+ - Lists all servers from `mcp-servers.json`
83
+ - Returns array of `{ name, command, type, args }`
84
+
85
+ ### `POST /mcp`
86
+ - **Body:** `{ server: string, command: string, args?: any[] }`
87
+ - **Command format:** `"list"` or `"call <toolName> [json-args]"`
88
+ - **Flow:**
89
+ 1. Load server config
90
+ 2. `autoDetectTransport()` → create Client + Transport
91
+ 3. `client.connect()` → initialize handshake
92
+ 4. Parse command:
93
+ - `"list"` → `client.request({ method: 'tools/list' }, ListToolsResultSchema)`
94
+ - `"call <name> [args]"` → `client.request({ method: 'tools/call', params: { name, arguments } }, CallToolResultSchema)`
95
+ 5. Return result as JSON
96
+ 6. Close transport
97
+
98
+ ### `POST /oauth/callback`
99
+ - Receives OAuth code from frontend
100
+ - Calls `transport.finishAuth(code)`
101
+ - Reconnects with authenticated transport
102
+ - Saves tokens
103
+
104
+ ## Key Patterns
105
+
106
+ ### 1. Transport Auto-Detection
107
+
108
+ ```typescript
109
+ async function autoDetectTransport(serverConfig) {
110
+ const client = new Client({ name: serverConfig.name, version: '1.0.0' });
111
+ const oauthProvider = new InMemoryOAuthProvider();
112
+
113
+ if (type === 'stdio') {
114
+ const transport = new StdioClientTransport({ command, args });
115
+ await client.connect(transport);
116
+ } else if (type === 'httpstream' || type === 'sse') {
117
+ const TransportClass = type === 'httpstream'
118
+ ? StreamableHTTPClientTransport
119
+ : SSEClientTransport;
120
+ const transport = new TransportClass(new URL(command), { authProvider: oauthProvider });
121
+ await client.connect(transport);
122
+ }
123
+ return { client, transport };
124
+ }
125
+ ```
126
+
127
+ **Pattern:** Factory that creates the right transport based on `type`, handles OAuth for HTTP transports.
128
+
129
+ ### 2. Request Schema Validation
130
+
131
+ Uses Zod schemas from SDK:
132
+ - `ListToolsResultSchema` for `tools/list`
133
+ - `CallToolResultSchema` for `tools/call`
134
+ - `LoggingMessageNotificationSchema` for notifications
135
+
136
+ **Pattern:** Type-safe request/response validation via SDK schemas.
137
+
138
+ ### 3. Error Handling
139
+
140
+ - **UnauthorizedError** → Return 401 with `authUrl` for OAuth flow
141
+ - **Other errors** → Return 500 with error details
142
+ - **Connection errors** → Caught and returned as JSON
143
+
144
+ **Pattern:** HTTP status codes map to MCP/auth errors; frontend handles 401 specially.
145
+
146
+ ### 4. Notification Handling
147
+
148
+ ```typescript
149
+ client.setNotificationHandler(LoggingMessageNotificationSchema, (notification) => {
150
+ // Log notification (template doesn't do much here)
151
+ });
152
+ ```
153
+
154
+ **Pattern:** Register handlers for server notifications (e.g. `logging/message`); template logs them.
155
+
156
+ ## Comparison with Our LSP Client
157
+
158
+ | Aspect | MCP Template | Our LSP Client |
159
+ |--------|-------------|----------------|
160
+ | **SDK** | Uses `@modelcontextprotocol/sdk` Client | Custom Content-Length transport |
161
+ | **Framing** | Newline-delimited (SDK default) | Content-Length (LSP-style) |
162
+ | **Lifecycle** | `client.connect()` handles initialize | Manual: `initialize` → `initialized` → requests |
163
+ | **Connection** | Per-request (new client each time) | Shared client (reused across requests) |
164
+ | **Protocol** | MCP (`tools/list`, `tools/call`) | LSP (`textDocument/documentSymbol`) |
165
+ | **Transport** | stdio, HTTP, SSE | stdio only (Content-Length) |
166
+ | **OAuth** | Full OAuth2.1 support | None (LSP doesn't use OAuth) |
167
+
168
+ ## Takeaways for Our Codebase
169
+
170
+ 1. **SDK vs Custom:** We can't use SDK `StdioClientTransport` because sysml-v2-lsp uses Content-Length, not newline-delimited. Our custom transport is correct.
171
+
172
+ 2. **Connection Reuse:** Template creates per-request connections; we reuse a shared client. Our approach is better for performance (no reconnect cost), but we need to handle errors/restarts.
173
+
174
+ 3. **Lifecycle:** Template relies on SDK's `connect()` to do initialize; we do it manually. Both are valid—SDK abstracts it, we have explicit control.
175
+
176
+ 4. **Error Handling:** Template maps MCP errors to HTTP status codes; we throw/return errors directly. Our approach fits our use case (CLI/scripts, not REST API).
177
+
178
+ 5. **OAuth:** Template has full OAuth flow; we don't need it for LSP (LSP doesn't use OAuth).
179
+
180
+ ## What We Should Adopt
181
+
182
+ 1. **Notification handlers:** If the LSP server sends notifications (e.g. `window/logMessage`), we should register handlers instead of ignoring them.
183
+
184
+ 2. **Request timeout:** Template doesn't show explicit timeouts, but we added 30s timeout—good practice.
185
+
186
+ 3. **Error mapping:** Template maps `UnauthorizedError` to 401; we could map LSP errors to more specific error types.
187
+
188
+ 4. **Connection retry:** Template doesn't retry; we could add retry logic for transient failures.
189
+
190
+ ## What We Shouldn't Adopt
191
+
192
+ 1. **Per-request connections:** Too slow for indexing (many files). Our shared client is better.
193
+
194
+ 2. **REST API wrapper:** We're a CLI/library, not a web service. Direct function calls are appropriate.
195
+
196
+ 3. **OAuth:** Not needed for LSP protocol.
@@ -0,0 +1,201 @@
1
+ # MCP Client–Server Interaction Guide
2
+
3
+ This guide describes how MCP (Model Context Protocol) clients and servers interact, the two stdio framing styles, and how to access the **sysml-v2-lsp** MCP server from code.
4
+
5
+ ## 1. Lifecycle
6
+
7
+ MCP follows a fixed handshake before any tool or resource calls:
8
+
9
+ ```
10
+ Client Server
11
+ | |
12
+ | initialize (request) |
13
+ |------------------------------>|
14
+ | initialize (response) |
15
+ |<------------------------------|
16
+ | notifications/initialized |
17
+ |------------------------------>|
18
+ | |
19
+ | tools/call, etc. |
20
+ |<=============================>|
21
+ ```
22
+
23
+ 1. **Initialize request**
24
+ Client sends a JSON-RPC request with `method: "initialize"` and params: `protocolVersion`, `capabilities`, `clientInfo`.
25
+ Example: `{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{},"clientInfo":{"name":"my-client","version":"1.0.0"}}}`
26
+
27
+ 2. **Initialize response**
28
+ Server replies with the same `id`, `result` with `serverInfo`, `capabilities`, and `protocolVersion`.
29
+
30
+ 3. **Initialized notification**
31
+ Client sends a notification (no `id`): `{"jsonrpc":"2.0","method":"notifications/initialized"}`.
32
+ Only after this may the client send other requests (e.g. `tools/call`).
33
+
34
+ 4. **Operation**
35
+ Client calls `tools/call` with `name` and `arguments`; server returns `result.content` (e.g. `[{ type: "text", text: "<json>" }]`).
36
+
37
+ References: [MCP Lifecycle](https://modelcontextprotocol.io/specification/2024-11-05/basic/lifecycle), [Building a client (Node)](https://modelcontextprotocol.io/tutorials/building-a-client-node).
38
+
39
+ ---
40
+
41
+ ## 2. Stdio transport: two framing styles
42
+
43
+ Over stdio, the **framing** (how messages are delimited) must match between client and server.
44
+
45
+ ### 2.1 Newline-delimited (MCP spec / SDK)
46
+
47
+ - **Format:** One JSON-RPC message per line. Each message is `JSON.stringify(msg)` followed by `\n`. No embedded newlines.
48
+ - **Used by:** Official [@modelcontextprotocol/sdk](https://www.npmjs.com/package/@modelcontextprotocol/sdk) **client** and **server** (e.g. [modelcontextprotocol/servers](https://github.com/modelcontextprotocol/servers)).
49
+ - **Client in code:** Use the SDK’s `Client` and `StdioClientTransport`; they handle framing and lifecycle.
50
+
51
+ ```ts
52
+ import { Client } from "@modelcontextprotocol/sdk/client/index.js";
53
+ import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js";
54
+
55
+ const transport = new StdioClientTransport({ command: "node", args: ["server.js"] });
56
+ const client = new Client({ name: "my-client", version: "1.0.0" }, { capabilities: {} });
57
+ await client.connect(transport);
58
+ // then: client.request({ method: "tools/call", params: { name, arguments } }, schema)
59
+ ```
60
+
61
+ ### 2.2 Content-Length (LSP-style)
62
+
63
+ - **Format:** For each message: a header line `Content-Length: <N>` (and optional other headers), then `\r\n\r\n`, then exactly N bytes of UTF-8 JSON. Same as LSP.
64
+ - **Used by:** **sysml-v2-lsp** MCP server (its bundled transport uses this format).
65
+ - **Client in code:** A custom client that sends and parses this framing (e.g. this repo’s `createSysmlMcpClient()`).
66
+ - **MCP Client Pattern:** Even though we use LSP protocol messages (`textDocument/documentSymbol`), the client follows MCP client lifecycle patterns (initialize → initialized → requests). See [MCP client template](https://github.com/andrea9293/mcp-client-template) for reference. We can’t use `@modelcontextprotocol/sdk` `StdioClientTransport` directly because it expects newline-delimited JSON, not Content-Length framing.
67
+
68
+ | Server / client | Framing | Use in code |
69
+ |--------------------------|------------------|--------------------------------------|
70
+ | modelcontextprotocol/servers, SDK demos | Newline-delimited | SDK `Client` + `StdioClientTransport` |
71
+ | sysml-v2-lsp | Content-Length | `createSysmlMcpClient()` (this repo) |
72
+
73
+ ---
74
+
75
+ ## 3. How Cursor runs the MCP server
76
+
77
+ Cursor starts the server as a **subprocess** from the **project root** (the folder that contains `.cursor/mcp.json`):
78
+
79
+ - **Config:** In `.cursor/mcp.json`, `mcpServers.<name>.command` and `args` (and optional `cwd`).
80
+ - **Example (sysml-v2):**
81
+ `"command": "node"`,
82
+ `"args": ["node_modules/sysml-v2-lsp/dist/server/mcpServer.js"]`
83
+ with **cwd** = project root so `node_modules` resolves.
84
+ - On Windows, if the OS would open `.js` with another app, the same process is often run via `cmd /c node ...` so Node executes the script.
85
+
86
+ Cursor’s client then talks to that process over stdio using whatever framing the server expects (for sysml-v2-lsp, Content-Length).
87
+
88
+ ---
89
+
90
+ ## 4. sysml-v2-lsp server
91
+
92
+ - **Package:** [sysml-v2-lsp](https://www.npmjs.com/package/sysml-v2-lsp) (npm); LobeHub: [daltskin-sysml-v2-lsp](https://lobehub.com/zh-TW/mcp/daltskin-sysml-v2-lsp).
93
+ - **Two entry points:**
94
+ - **MCP:** `node_modules/sysml-v2-lsp/dist/server/mcpServer.js` — used by Cursor MCP and by this repo’s `createSysmlMcpClient()` (tools: parse, validate, getSymbols, etc.).
95
+ - **LSP:** `node_modules/sysml-v2-lsp/dist/server/server.js` — used by the **analyze** (index) CLI via `SYSMLLSP_SERVER_PATH`; same Content-Length framing, different protocol (LSP documentSymbol, etc.).
96
+ - **Transport:** **Content-Length** framing on stdin/stdout (LSP-style) for both.
97
+ - **Tools (MCP examples):** `parse`, `validate`, `getDiagnostics`, `diagnostics`, `validateFile`, `getSymbols`, `getDefinition`, `getReferences`, `getHierarchy`, `getModelSummary`, `getComplexity`, `preview`.
98
+
99
+ ---
100
+
101
+ ## 5. Accessing sysml-v2-lsp from code
102
+
103
+ ### 5.1 From Cursor (MCP tools)
104
+
105
+ When the **sysml-v2** MCP server is enabled in this project, Cursor can call its tools directly. No extra code: use the MCP tool API with server name and `tools/call` (e.g. `parse`, `validate`). This is the most reliable way to “access” the server in practice.
106
+
107
+ ### 5.2 Programmatic client (this repo)
108
+
109
+ For scripts or tests, use the **SysML MCP client** that speaks Content-Length and the same lifecycle as above:
110
+
111
+ ```ts
112
+ import { createSysmlMcpClient, getMcpServerPath } from "./parser/sysml-mcp-client.js";
113
+
114
+ const client = await createSysmlMcpClient();
115
+ try {
116
+ const result = await client.parse(code, "file:///example.sysml");
117
+ console.log(result);
118
+ const valid = await client.validate(code, "file:///example.sysml");
119
+ console.log(valid);
120
+ } finally {
121
+ client.close();
122
+ }
123
+ ```
124
+
125
+ - **Options:** `createSysmlMcpClient({ serverPath?, initTimeout?, debug? })`.
126
+ - `serverPath`: defaults to `getMcpServerPath()` (from `sysml-v2-lsp` package or `node_modules/.../mcpServer.js`).
127
+ - `initTimeout`: ms to wait for initialize response (default 20000).
128
+ - `debug`: log raw stdout/stderr.
129
+ - **Spawn:** Server is started with `process.execPath` (node) and `serverPath`, **cwd = process.cwd()** (project root), so behaviour matches Cursor. On Windows, the client may use `cmd /c node <path>` if needed to avoid the OS opening `.js` with another app.
130
+ - **Framing:** Content-Length only (required for sysml-v2-lsp). Do not use the SDK’s `StdioClientTransport` for sysml-v2-lsp; it uses newline-delimited and will not interoperate.
131
+
132
+ ### 5.3 Example and access scripts
133
+
134
+ From repo root after `npm run build`:
135
+
136
+ ```bash
137
+ node scripts/example-sysml-mcp.mjs
138
+ node scripts/access-sysml-mcp.mjs
139
+ ```
140
+
141
+ - **example-sysml-mcp.mjs** — Calls `parse`, `validate`, and `getSymbols` on a small snippet.
142
+ - **access-sysml-mcp.mjs** — Same idea; use `--debug` to log server stdout/stderr. Optional `initTimeout` (default 30s) can be increased in code if the server is slow to start.
143
+
144
+ **If the script hits “initialize timeout”:**
145
+ When the MCP server is started from a Node script, it may not send the initialize response in time (cold start, stdout buffering, or load). In that case:
146
+
147
+ 1. **Use Cursor MCP** — With the sysml-v2 server enabled in `.cursor/mcp.json`, call the tools from Cursor (e.g. via the MCP tool API). This is the most reliable way to use the server.
148
+ 2. **Increase `initTimeout`** — e.g. `createSysmlMcpClient({ initTimeout: 60000 })`.
149
+ 3. **Run from the same conditions as Cursor** — Same working directory and `node`; the client already uses `cwd: process.cwd()` to match.
150
+
151
+ ---
152
+
153
+ ## 6. Index and graph map (LSP, not MCP)
154
+
155
+ Indexing and generating the graph map use the **LSP** server (`server.js`), not the MCP server. The CLI runs `analyze` (which spawns the LSP and uses documentSymbol), then you can run `generate-map` to produce a markdown map.
156
+
157
+ - **Kuzu:** The graph DB is backed by [kuzu](https://www.npmjs.com/package/kuzu). Ensure it is built: run `npm install` without `--ignore-scripts`, or `node node_modules/kuzu/install.js` so that `index.js` / `index.mjs` and the native addon are present. Without this, analyze and generate-map will fail with module-not-found.
158
+ - **LSP path:** The canonical LSP for this repo is in **`lsp/`**. Run **`npm run setup-lsp`** (or `cd lsp && npm install`) once; the indexer then uses `lsp/node_modules/sysml-v2-lsp/dist/server/server.js` by default (then root `node_modules/...` as fallback). No need to set **`SYSMLLSP_SERVER_PATH`** when using the default. See docs/PLAN_INDEPENDENT_LSP.md.
159
+ - **Commands (from repo root, after `npm run build`):**
160
+ - `npm run index-and-map` — Index default path `test/fixtures/sysml`, then write **graph-map.md**.
161
+ - `npm run index-and-map <path>` — Index the given path, then generate the map.
162
+ - `npm run generate-map [outFile]` — Generate map only (reads from existing DB under `~/.sysmledgraph/db/` or `SYSMEDGRAPH_STORAGE_ROOT`).
163
+ - **Output:** `graph-map.md` (or the file you pass to generate-map) lists documents, nodes by label, and edges (interconnection view).
164
+
165
+ **Why no edges (interconnection empty)?**
166
+ Edges come from **symbols** (Package, PartDef, etc.). The indexer gets symbols via the LSP **textDocument/documentSymbol** request. If the LSP returns no symbols (or only symbols we don’t map to a label), you get Document nodes but no symbol nodes and no edges.
167
+
168
+ - **Optional MCP fallback:** Set **`SYSMEDGRAPH_USE_MCP_SYMBOLS=1`** and run index-and-map again. When the LSP returns no symbols, the indexer will try the **MCP** `getSymbols` tool (same sysml-v2-lsp server, different API). If the MCP returns symbols, they are mapped to nodes and edges. Note: spawning the MCP server from a script can be slow or hit init timeouts; if that happens, use Cursor MCP for ad‑hoc symbol queries and rely on the LSP for indexing when your LSP build supports documentSymbol.
169
+ - **LSP behaviour:** Some builds of sysml-v2-lsp may not implement `documentSymbol` or may return a different response shape. We now pass `rootUri` and `workspaceFolders` in initialize and support both array and wrapped `{ data: [] }` responses; we also map LSP **SymbolKind** (number) to a label when `detail` is missing.
170
+
171
+ ---
172
+
173
+ ## 7. Debugging
174
+
175
+ - **`DEBUG_SYSMLEGRAPH_SYMBOLS=1`** — Log to stderr per file whether symbols came from **LSP** or **MCP** (and count for MCP). Use when indexing to see which path is used.
176
+ - **`DEBUG_LSP_NOTIFICATIONS=1`** — Log LSP `window/logMessage` and `window/showMessage` to stderr when using the LSP client.
177
+
178
+ ---
179
+
180
+ ## 8. Troubleshooting
181
+
182
+ | Issue | What to do |
183
+ |-------|------------|
184
+ | **No edges in graph-map.md** | Edges come from LSP (or MCP fallback) symbols. Ensure **SYSMLLSP_SERVER_PATH** points to a built `server.js` (with `--stdio`). Run `node scripts/debug-lsp-symbols.mjs <file.sysml>` to see raw LSP output. Use **DEBUG_SYSMLEGRAPH_SYMBOLS=1** when indexing to see if LSP or MCP is used. |
185
+ | **LSP server not found** | Run `npm install` (or in `lsp/` for a dedicated install). On Windows, if install fails use `npm install --ignore-scripts` then build; set **SYSMLLSP_SERVER_PATH** to your built `dist/server/server.js`. |
186
+ | **Kuzu "Could not set lock on file"** | Only one process can open the same DB. Close Cursor (or disable the sysmledgraph MCP) before running CLI analyze/export, or use a different **SYSMEDGRAPH_STORAGE_ROOT** (e.g. a temp folder) for the run. |
187
+ | **Validate a SysML file** | `node scripts/validate-sysml-file.mjs <path-to.sysml>`. Exit 0 = no issues; exit 1 = syntax/semantic issues or script error. Requires sysml-v2-lsp MCP server (same as indexing). |
188
+
189
+ ---
190
+
191
+ ## 9. Summary
192
+
193
+ | Goal | Approach |
194
+ |-----------------------------|---------------------------------------------------------------------------|
195
+ | Understand MCP interaction | Lifecycle: initialize → response → notifications/initialized → tools/call |
196
+ | Talk to standard MCP servers| SDK `Client` + `StdioClientTransport` (newline-delimited) |
197
+ | Talk to sysml-v2-lsp | Content-Length client; in this repo: `createSysmlMcpClient()` |
198
+ | Use from Cursor | Enable sysml-v2 in `.cursor/mcp.json` and call MCP tools |
199
+ | Use from Node/scripts | `createSysmlMcpClient()` and call methods; run from project root |
200
+ | Index and see the map | LSP (`server.js`); kuzu built; `npm run index-and-map` (see §6) |
201
+ | Validate a file | `node scripts/validate-sysml-file.mjs <path>` (exit 0/1) |
@@ -0,0 +1,124 @@
1
+ # MCP Server for Cursor AI
2
+
3
+ This repo works as an **MCP server** so Cursor (and other MCP clients) can use the SysML knowledge graph: query symbols, context, impact, generate map, index paths, and run Cypher.
4
+
5
+ ## 1. What the server provides
6
+
7
+ - **Server name:** `sysmledgraph`
8
+ - **Transport:** stdio (Cursor spawns the process and talks over stdin/stdout)
9
+ - **Tools:** indexDbGraph, list_indexed, clean_index, cypher, query, context, impact, rename, generate_map
10
+ - **Resources:** `sysmledgraph://context`, `sysmledgraph://schema` (and per-path variants when paths are indexed)
11
+
12
+ Cursor AI can call these tools when you ask about your SysML model (e.g. “what uses Modelbase?”, “show me the graph map”, “list symbols in the deploy model”).
13
+
14
+ ## 2. Prerequisites
15
+
16
+ 1. **Index at least one path** so the graph has data. Either:
17
+ - **CLI:** `npx sysmledgraph analyze <path>` (e.g. `modelbase-development/models`), or
18
+ - **MCP tool:** After the server is running in Cursor, use the **indexDbGraph** tool with the same path(s).
19
+ 2. **Kuzu:** Built (e.g. `npm install` without `--ignore-scripts`). See docs/INSTALL_NOTES.md if needed.
20
+ 3. **LSP:** For indexing, the LSP is in **`lsp/`**. Run **`npm run setup-lsp`** (or `cd lsp && npm install`) once; it is then picked automatically. No need to set **SYSMLLSP_SERVER_PATH** if the server isn’t in the default location (see docs/PLAN_INDEPENDENT_LSP.md).
21
+
22
+ ## 3. Enable in Cursor
23
+
24
+ Add the sysmledgraph MCP server to Cursor’s MCP config.
25
+
26
+ **Option A — Project-local (this repo as workspace)**
27
+
28
+ Create or edit **`.cursor/mcp.json`** in the project root:
29
+
30
+ ```json
31
+ {
32
+ "mcpServers": {
33
+ "sysmledgraph": {
34
+ "command": "node",
35
+ "args": ["dist/mcp/index.js"],
36
+ "cwd": ".",
37
+ "env": {
38
+ "SYSMEDGRAPH_STORAGE_ROOT": "C:/Users/YOU/.sysmledgraph"
39
+ }
40
+ }
41
+ }
42
+ }
43
+ ```
44
+
45
+ - **cwd** must be the **workspace root** (where `dist/` and the indexed paths live). Use `"."` when opening this repo as the workspace.
46
+ - **SYSMEDGRAPH_STORAGE_ROOT:** Default is `~/.sysmledgraph`. Set to a custom path if you use one for the CLI.
47
+ - **SYSMLLSP_SERVER_PATH (optional):** Only if not using the default. When running from this repo, the LSP in **`lsp/`** is used automatically after **`npm run setup-lsp`**.
48
+
49
+ **Option B — Absolute path to built server**
50
+
51
+ If the built server lives elsewhere (e.g. a global tools folder):
52
+
53
+ ```json
54
+ {
55
+ "mcpServers": {
56
+ "sysmledgraph": {
57
+ "command": "node",
58
+ "args": ["C:/path/to/sysmledgraph/dist/mcp/index.js"],
59
+ "env": {
60
+ "SYSMEDGRAPH_STORAGE_ROOT": "C:/Users/YOU/.sysmledgraph"
61
+ }
62
+ }
63
+ }
64
+ }
65
+ ```
66
+
67
+ **Option C — npx (when published)**
68
+
69
+ ```json
70
+ {
71
+ "mcpServers": {
72
+ "sysmledgraph": {
73
+ "command": "npx",
74
+ "args": ["-y", "sysmledgraph-mcp"]
75
+ }
76
+ }
77
+ }
78
+ ```
79
+
80
+ After saving, (re)start Cursor or reload MCP so it picks up the new server.
81
+
82
+ ## 4. Tools Cursor AI can use
83
+
84
+ | Tool | Purpose |
85
+ |------|--------|
86
+ | **list_indexed** | List indexed root paths (so AI knows what’s in the graph). |
87
+ | **query** | Concept search over symbol names/labels; optional `kind` filter (e.g. PartDef, Package). |
88
+ | **context** | 360° view for one symbol: node + edges (IN_DOCUMENT, IN_PACKAGE, etc.). |
89
+ | **impact** | Blast radius: upstream (what references this) or downstream (what this references). |
90
+ | **generate_map** | Get Markdown of the graph (documents, nodes by label, interconnection edges). |
91
+ | **cypher** | Run a Cypher query on the graph (advanced). |
92
+ | **indexDbGraph** | Index path(s) (same as CLI analyze). Use when the graph is empty or you add a new folder. |
93
+ | **clean_index** | Remove index for one path or all. |
94
+ | **rename** | Preview or perform a symbol rename across the graph. |
95
+
96
+ For “show the map of this file” or “what depends on X”, the AI can call **generate_map** or **context** / **impact** after **list_indexed** to see what’s available.
97
+
98
+ ## 5. Storage and LSP
99
+
100
+ - **Storage:** Same as CLI. Default `~/.sysmledgraph`; override with **SYSMEDGRAPH_STORAGE_ROOT**. The MCP server uses the same DB as `sysmledgraph analyze` and `scripts/generate-map.mjs`.
101
+ - **LSP:** Used by **indexDbGraph** and CLI analyze. The canonical LSP is in **`lsp/`**. Run **`npm run setup-lsp`** once; the indexer then uses it by default (no **SYSMLLSP_SERVER_PATH** needed). If unset and lsp/ not installed, indexing falls back to MCP getSymbols.
102
+
103
+ ## 6. Kuzu lock
104
+
105
+ Only one process can open the same Kuzu DB at a time. If the sysmledgraph MCP is running in Cursor, it holds the DB open. To run **CLI** analyze or **scripts/export-graph.mjs** / **generate-map.mjs** without “Could not set lock on file”, either:
106
+
107
+ - Close Cursor (or disable the sysmledgraph MCP), run the CLI/script, then reopen Cursor, or
108
+ - Use a **different** **SYSMEDGRAPH_STORAGE_ROOT** for the CLI run (e.g. a temp folder), then point the MCP at the same root if you want Cursor to see that data.
109
+
110
+ See **docs/MCP_INTERACTION_GUIDE.md** §8 Troubleshooting and **docs/MCP-AND-KUZU.md** (if present).
111
+
112
+ ## 7. Checklist
113
+
114
+ 1. `npm install` and `npm run build` in this repo.
115
+ 2. Run **`npm run setup-lsp`** (or `cd lsp && npm install`) so the LSP used for indexing is installed in **`lsp/`**.
116
+ 3. Index at least one path: `npx sysmledgraph analyze modelbase-development/models` (or use **indexDbGraph** after MCP is on).
117
+ 4. Add **sysmledgraph** to `.cursor/mcp.json` with `command`/`args`/`cwd`/`env` as above.
118
+ 5. Restart Cursor or reload MCP; confirm the server appears (e.g. in Cursor MCP settings).
119
+ 6. In chat, ask e.g. “List indexed paths for sysmledgraph”, “Show the graph map”, “What is the context of Modelbase?” to confirm tools work.
120
+
121
+ ## 8. Next (optional)
122
+
123
+ - **Prompts:** Add a Cursor rule or AGENTS.md note so the AI knows to use sysmledgraph tools for SysML/graph questions.
124
+ - **Resources:** Expose `sysmledgraph://context` or `sysmledgraph://schema` in Cursor so the AI can pull index stats and schema when relevant.
package/docs/PLAN.md ADDED
@@ -0,0 +1,58 @@
1
+ # Plan: LSP Client Fixes & Indexing
2
+
3
+ **Released:** v0.4.3 (2026-03-19) — see `release-notes-v0.4.3.md`.
4
+
5
+ ## Current Status
6
+
7
+ ✅ **Completed:**
8
+ - Fixed LSP client: added `--stdio` flag, Windows spawn (`cmd /c`), timeouts, error handling
9
+ - Created `lsp/` folder with dedicated npm install for isolated LSP server init
10
+ - Added MCP fallback: when LSP returns no symbols, automatically tries MCP `getSymbols` (shared client per index run)
11
+ - Added LSP capabilities: `hierarchicalDocumentSymbolSupport`, `workspaceFolders`
12
+ - Added SymbolInformation support: normalize flat list with `containerName` to DocumentSymbol-like shape
13
+ - Added LSP SymbolKind fallback: map numeric `kind` to label when `detail` is missing
14
+ - Enhanced symbol mapping: added MCP-style kind strings ("Part Definition", etc.) with normalized lookup
15
+ - Analyzed MCP client template patterns
16
+ - **✅ Phase 1 Complete:** LSP client returns symbols; graph has symbol nodes and edges (IN_DOCUMENT, IN_PACKAGE)
17
+ - **✅ Phase 2 Complete:** LSP notification handler (e.g. `window/logMessage` when `DEBUG_LSP_NOTIFICATIONS=1`); indexed `modelbase-development/models/`; `graph-map.md` generated with full nodes and interconnection table
18
+ - **✅ CLI exit fix:** (1) Explicit graph store close in `cmdAnalyze` (try/finally). (2) After successful analyze, CLI calls `process.exit(0)` so the process exits before Node/Kuzu teardown (avoids Windows access violation). Verified: `node scripts/index-and-map.mjs test/fixtures/sysml` completes with exit 0 and writes `graph-map.md`.
19
+
20
+ ## Plan
21
+
22
+ ### Phase 1: Test & Verify — ✅ Done
23
+
24
+ 1. Rebuild and test LSP client; run index-and-map.
25
+ 2. Verify `graph-map.md` has symbol nodes and edges.
26
+ 3. Debug LSP/MCP via `scripts/debug-lsp-symbols.mjs` if needed.
27
+
28
+ ### Phase 2: Notification Handlers & Larger Models — ✅ Done
29
+
30
+ 4. **LSP notification handler** — Handler added in `lsp-client.ts`; `window/logMessage` and `window/showMessage` logged when `DEBUG_LSP_NOTIFICATIONS=1`.
31
+ 5. **Real SysML files** — Indexed `modelbase-development/models/` (4 files); map shows Action, Block, Package, PartDef, PartUsage, RequirementDef and IN_DOCUMENT/IN_PACKAGE edges.
32
+
33
+ ### Phase 3: Robustness — ✅ Done
34
+
35
+ 6. **Connection retry logic** — LSP: `getDocumentSymbolsFromLsp` retries `createLspClient()` once after 1.5s on failure. MCP: `getSymbolsFromMcp` retries the getSymbols call once after 1s on failure; still returns [] if unavailable.
36
+ 7. **Better error reporting** — When **`DEBUG_SYSMLEGRAPH_SYMBOLS=1`**, log to stderr per file whether symbols came from LSP or MCP (and count for MCP). LSP errors still fall through to MCP; no custom error types added.
37
+
38
+ ### Phase 4: Validation & Documentation — ✅ Done
39
+
40
+ 8. **Validate the requested file** — `scripts/validate-sysml-file.mjs` calls MCP `validate`; reports syntax errors and semantic issues; exit 0 if valid/no issues, 1 otherwise. Init/read failures handled with clear errors.
41
+ 9. **Documentation** — v0.4.3: fixes in `MCP_INTERACTION_GUIDE.md`, "no edges" and §6. **Phase 4:** MCP_INTERACTION_GUIDE §8 Troubleshooting (no edges, LSP not found, Kuzu lock, validate script); §9 Summary includes validate.
42
+
43
+ ## MCP server for Cursor AI
44
+
45
+ So Cursor AI can use the graph, the repo runs as an **MCP server** (stdio). See **docs/MCP_SERVER_FOR_CURSOR.md** for the full plan.
46
+
47
+ - **Entrypoint:** `mcp/index.ts` → `dist/mcp/index.js`; bin `sysmledgraph-mcp` and `npm run mcp`.
48
+ - **Cursor:** Add **sysmledgraph** to `.cursor/mcp.json` (command `node`, args `dist/mcp/index.js`, cwd `.`). Example added in this repo’s `.cursor/mcp.json`.
49
+ - **Tools:** indexDbGraph, list_indexed, clean_index, cypher, query, context, impact, rename, generate_map. Resources: sysmledgraph://context, sysmledgraph://schema.
50
+ - **Prereq:** Index at least one path (CLI or indexDbGraph); same storage as CLI. Kuzu lock: only one process per DB (see Troubleshooting in MCP_INTERACTION_GUIDE).
51
+
52
+ ## Success Criteria
53
+
54
+ - ✅ `graph-map.md` shows symbol nodes (Package, PartDef, Action, etc.) not just Document
55
+ - ✅ Interconnection table has edges (IN_DOCUMENT, IN_PACKAGE)
56
+ - ✅ Indexing writes data correctly (LSP + optional MCP fallback)
57
+ - ✅ Validation script: `node scripts/validate-sysml-file.mjs <path>` (exit 0/1)
58
+ - ✅ MCP server runnable via `npx sysmledgraph-mcp`; Cursor can use tools when configured (see MCP_SERVER_FOR_CURSOR.md)