@likec4/language-server 1.28.1 → 1.29.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.
@@ -0,0 +1,28 @@
1
+ import { logger } from "../../logger.js";
2
+ import { SSELikeC4MCPServer } from "./SSELikeC4MCPServer.js";
3
+ export const WithMCPServer = {
4
+ mcp: {
5
+ Server(services) {
6
+ logger.debug("Creating SSELikeC4MCPServer");
7
+ const server = new SSELikeC4MCPServer(services);
8
+ const langId = services.LanguageMetaData.languageId;
9
+ services.shared.workspace.ConfigurationProvider.onConfigurationSectionUpdate((update) => {
10
+ if (update.section !== langId) {
11
+ logger.warn("Unexpected configuration update: {update}", { update });
12
+ return;
13
+ }
14
+ logger.debug("Configuration update: {update}", { update });
15
+ const { enabled, port } = update.configuration.mcp ?? {
16
+ enabled: false,
17
+ port: 33335
18
+ };
19
+ if (!enabled) {
20
+ server.stop();
21
+ return;
22
+ }
23
+ server.start(port);
24
+ });
25
+ return server;
26
+ }
27
+ }
28
+ };
@@ -0,0 +1,34 @@
1
+ import { type LikeC4Model, type ProjectId } from '@likec4/core';
2
+ import type { LikeC4LanguageServices } from '../LikeC4LanguageServices';
3
+ export declare function elementResource(languageServices: LikeC4LanguageServices, el: LikeC4Model.Element, projectId?: ProjectId): {
4
+ id: any;
5
+ parent: {
6
+ id: any;
7
+ title: any;
8
+ kind: any;
9
+ } | null;
10
+ projectId: any;
11
+ title: any;
12
+ kind: any;
13
+ shape: any;
14
+ technology: any;
15
+ description: any;
16
+ tags: any;
17
+ children: any;
18
+ relations: {
19
+ incoming: any;
20
+ outgoing: any;
21
+ };
22
+ views: any;
23
+ sourceFile: import("../protocol").Locate.Res;
24
+ };
25
+ export declare function modelViewResource(languageServices: LikeC4LanguageServices, view: LikeC4Model.View, projectId?: ProjectId): {
26
+ id: any;
27
+ title: any;
28
+ projectId: any;
29
+ viewType: any;
30
+ description: any;
31
+ tags: any;
32
+ nodes: any;
33
+ sourceFile: import("../protocol").Locate.Res;
34
+ };
@@ -0,0 +1,104 @@
1
+ import { imap, toArray } from "@likec4/core";
2
+ export function elementResource(languageServices, el, projectId) {
3
+ return {
4
+ id: el.id,
5
+ parent: !el.parent ? null : {
6
+ id: el.parent.id,
7
+ title: el.parent.title,
8
+ kind: el.parent.kind
9
+ },
10
+ projectId,
11
+ title: el.title,
12
+ kind: el.kind,
13
+ shape: el.shape,
14
+ technology: el.technology,
15
+ description: el.description,
16
+ tags: el.tags,
17
+ children: toArray(imap(el.children(), (c) => ({
18
+ id: c.id,
19
+ title: c.title,
20
+ kind: el.kind
21
+ }))),
22
+ relations: {
23
+ incoming: toArray(imap(el.incoming(), (r) => ({
24
+ id: r.id,
25
+ title: r.title,
26
+ description: r.description,
27
+ technology: r.technology,
28
+ source: {
29
+ id: r.source.id,
30
+ title: r.source.title,
31
+ kind: r.source.kind
32
+ },
33
+ ...r.target.id === el.id ? {
34
+ type: "direct"
35
+ } : {
36
+ type: "implicit, to nested",
37
+ target: {
38
+ id: r.target.id,
39
+ title: r.target.title,
40
+ kind: r.target.kind
41
+ }
42
+ }
43
+ }))),
44
+ outgoing: toArray(imap(el.outgoing(), (r) => ({
45
+ id: r.id,
46
+ title: r.title,
47
+ description: r.description,
48
+ technology: r.technology,
49
+ target: {
50
+ id: r.target.id,
51
+ title: r.target.title,
52
+ kind: r.target.kind
53
+ },
54
+ ...r.source.id === el.id ? {
55
+ type: "direct"
56
+ } : {
57
+ type: "implicit, from nested",
58
+ source: {
59
+ id: r.source.id,
60
+ title: r.source.title,
61
+ kind: r.source.kind
62
+ }
63
+ }
64
+ })))
65
+ },
66
+ views: toArray(imap(el.views(), (v) => ({
67
+ id: v.id,
68
+ title: v.title
69
+ }))),
70
+ sourceFile: languageServices.locate({
71
+ element: el.id,
72
+ projectId
73
+ })
74
+ };
75
+ }
76
+ export function modelViewResource(languageServices, view, projectId) {
77
+ return {
78
+ id: view.id,
79
+ title: view.title,
80
+ projectId,
81
+ viewType: view.__,
82
+ description: view.$view.description ?? "",
83
+ tags: view.tags,
84
+ nodes: toArray(imap(view.nodes(), (node) => ({
85
+ id: node.id,
86
+ title: node.title,
87
+ represents: node.element ? {
88
+ element: node.element.id
89
+ } : {}
90
+ }))),
91
+ sourceFile: languageServices.locate({
92
+ view: view.id,
93
+ projectId
94
+ })
95
+ // edges: toArray(imap(view.edges(), edge => ({
96
+ // id: edge.id,
97
+ // title: edge.title,
98
+ // }))),
99
+ // elements: toArray(imap(view.elements(), el => ({
100
+ // id: el.id,
101
+ // title: el.title,
102
+ // }))),
103
+ };
104
+ }
package/dist/module.d.ts CHANGED
@@ -4,6 +4,8 @@ import { type DefaultSharedModuleContext, type LangiumServices, type LangiumShar
4
4
  import { LikeC4DocumentationProvider } from './documentation';
5
5
  import { type LikeC4LanguageServices } from './LikeC4LanguageServices';
6
6
  import { LikeC4CodeLensProvider, LikeC4CompletionProvider, LikeC4DocumentHighlightProvider, LikeC4DocumentLinkProvider, LikeC4DocumentSymbolProvider, LikeC4HoverProvider, LikeC4SemanticTokenProvider } from './lsp';
7
+ import { type LikeC4MCPServer, LikeC4MCPServerFactory } from './mcp/LikeC4MCPServerFactory';
8
+ import { type LikeC4MCPTools } from './mcp/LikeC4MCPTools';
7
9
  import { type LikeC4ModelBuilder, DeploymentsIndex, FqnIndex, LikeC4ModelLocator, LikeC4ModelParser } from './model';
8
10
  import { LikeC4ModelChanges } from './model-change/ModelChanges';
9
11
  import { LikeC4NameProvider, LikeC4ScopeComputation, LikeC4ScopeProvider } from './references';
@@ -33,6 +35,11 @@ export interface LikeC4AddedServices {
33
35
  };
34
36
  ValidatedWorkspaceCache: WorkspaceCache<string, any>;
35
37
  Rpc: Rpc;
38
+ mcp: {
39
+ Tools: LikeC4MCPTools;
40
+ Server: LikeC4MCPServer;
41
+ ServerFactory: LikeC4MCPServerFactory;
42
+ };
36
43
  likec4: {
37
44
  LanguageServices: LikeC4LanguageServices;
38
45
  Views: LikeC4Views;
package/dist/module.js CHANGED
@@ -26,6 +26,8 @@ import {
26
26
  LikeC4HoverProvider,
27
27
  LikeC4SemanticTokenProvider
28
28
  } from "./lsp/index.js";
29
+ import { LikeC4MCPServerFactory, NoopLikeC4MCPServer } from "./mcp/LikeC4MCPServerFactory.js";
30
+ import { DefaultLikeC4MCPTools } from "./mcp/LikeC4MCPTools.js";
29
31
  import {
30
32
  DefaultLikeC4ModelBuilder,
31
33
  DeploymentsIndex,
@@ -74,6 +76,11 @@ export const LikeC4Module = {
74
76
  },
75
77
  ValidatedWorkspaceCache: (services) => new WorkspaceCache(services.shared, DocumentState.Validated),
76
78
  Rpc: bind(Rpc),
79
+ mcp: {
80
+ Tools: bind(DefaultLikeC4MCPTools),
81
+ Server: bind(NoopLikeC4MCPServer),
82
+ ServerFactory: bind(LikeC4MCPServerFactory)
83
+ },
77
84
  likec4: {
78
85
  LanguageServices: bind(DefaultLikeC4LanguageServices),
79
86
  Layouter: (_services) => {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@likec4/language-server",
3
3
  "description": "LikeC4 Language Server",
4
- "version": "1.28.1",
4
+ "version": "1.29.0",
5
5
  "license": "MIT",
6
6
  "bugs": "https://github.com/likec4/likec4/issues",
7
7
  "homepage": "https://likec4.dev",
@@ -94,10 +94,14 @@
94
94
  "vscode-uri": "3.1.0"
95
95
  },
96
96
  "devDependencies": {
97
+ "@modelcontextprotocol/sdk": "^1.9.0",
98
+ "express": "^5.1.0",
97
99
  "@msgpack/msgpack": "^3.1.1",
98
100
  "@smithy/util-base64": "^4.0.0",
101
+ "@types/express": "^5.0.1",
99
102
  "@types/node": "^20.17.30",
100
103
  "@types/picomatch": "^4.0.0",
104
+ "picomatch": "^4.0.2",
101
105
  "@types/which": "^3.0.4",
102
106
  "esm-env": "^1.2.2",
103
107
  "fast-equals": "^5.2.2",
@@ -109,7 +113,6 @@
109
113
  "natural-compare-lite": "^1.4.0",
110
114
  "p-debounce": "^4.0.0",
111
115
  "p-queue": "^8.1.0",
112
- "picomatch": "^4.0.2",
113
116
  "p-timeout": "^6.1.4",
114
117
  "pretty-ms": "^9.2.0",
115
118
  "remeda": "^2.21.2",
@@ -121,16 +124,17 @@
121
124
  "ufo": "^1.6.1",
122
125
  "unbuild": "^3.5.0",
123
126
  "valibot": "^1.0.0",
127
+ "zod": "^3.24.2",
124
128
  "vitest": "^3.1.1",
125
129
  "vscode-languageserver": "9.0.1",
126
130
  "vscode-languageserver-protocol": "3.17.5",
127
131
  "vscode-languageserver-types": "3.17.5",
128
132
  "which": "^5.0.0",
129
- "@likec4/core": "1.28.1",
130
- "@likec4/layouts": "1.28.1",
131
- "@likec4/tsconfig": "1.28.1",
132
- "@likec4/log": "1.28.1",
133
- "@likec4/icons": "1.28.1"
133
+ "@likec4/icons": "1.29.0",
134
+ "@likec4/core": "1.29.0",
135
+ "@likec4/log": "1.29.0",
136
+ "@likec4/tsconfig": "1.29.0",
137
+ "@likec4/layouts": "1.29.0"
134
138
  },
135
139
  "scripts": {
136
140
  "typecheck": "tsc --noEmit",