@likec4/language-server 1.36.1 → 1.38.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/LikeC4LanguageServices.d.ts +43 -7
- package/dist/LikeC4LanguageServices.js +51 -11
- package/dist/Rpc.js +22 -6
- package/dist/browser.d.ts +1 -1
- package/dist/browser.js +1 -1
- package/dist/bundled.mjs +4258 -3083
- package/dist/config/schema.d.ts +1 -1
- package/dist/config/schema.js +1 -1
- package/dist/empty.d.ts +2 -0
- package/dist/empty.js +1 -0
- package/dist/filesystem/ChokidarWatcher.d.ts +14 -0
- package/dist/filesystem/ChokidarWatcher.js +64 -0
- package/dist/filesystem/FileSystemWatcher.d.ts +19 -0
- package/dist/filesystem/FileSystemWatcher.js +11 -0
- package/dist/filesystem/LikeC4FileSystem.d.ts +5 -0
- package/dist/filesystem/LikeC4FileSystem.js +56 -0
- package/dist/filesystem/index.d.ts +20 -0
- package/dist/filesystem/index.js +16 -0
- package/dist/index.d.ts +18 -4
- package/dist/index.js +23 -10
- package/dist/likec4lib.d.ts +1 -1
- package/dist/lsp/DocumentLinkProvider.js +3 -3
- package/dist/lsp/DocumentSymbolProvider.js +1 -1
- package/dist/mcp/{sseserver/MCPServerFactory.d.ts → MCPServerFactory.d.ts} +1 -1
- package/dist/mcp/MCPServerFactory.js +69 -0
- package/dist/mcp/NoopLikeC4MCPServer.d.ts +4 -10
- package/dist/mcp/NoopLikeC4MCPServer.js +5 -10
- package/dist/mcp/interfaces.d.ts +7 -5
- package/dist/mcp/interfaces.js +4 -0
- package/dist/mcp/server/StdioLikeC4MCPServer.d.ts +16 -0
- package/dist/mcp/server/StdioLikeC4MCPServer.js +43 -0
- package/dist/mcp/{sseserver/MCPServer.d.ts → server/StreamableLikeC4MCPServer.d.ts} +3 -2
- package/dist/mcp/server/StreamableLikeC4MCPServer.js +156 -0
- package/dist/mcp/server/WithMCPServer.d.ts +2 -0
- package/dist/mcp/server/WithMCPServer.js +57 -0
- package/dist/mcp/tools/_common.d.ts +24 -5
- package/dist/mcp/tools/_common.js +31 -3
- package/dist/mcp/tools/find-relationships.d.ts +13 -0
- package/dist/mcp/tools/find-relationships.js +151 -0
- package/dist/mcp/tools/list-projects.js +42 -14
- package/dist/mcp/tools/open-view.d.ts +4 -3
- package/dist/mcp/tools/open-view.js +37 -14
- package/dist/mcp/tools/{read-project-elements.d.ts → read-deployment.d.ts} +6 -3
- package/dist/mcp/tools/read-deployment.js +130 -0
- package/dist/mcp/tools/read-element.d.ts +4 -3
- package/dist/mcp/tools/read-element.js +114 -51
- package/dist/mcp/tools/read-project-summary.d.ts +3 -2
- package/dist/mcp/tools/read-project-summary.js +141 -34
- package/dist/mcp/tools/read-view.d.ts +4 -3
- package/dist/mcp/tools/read-view.js +146 -105
- package/dist/mcp/tools/search-element.js +81 -30
- package/dist/mcp/utils.js +7 -4
- package/dist/model/builder/buildModel.d.ts +1 -1
- package/dist/model/builder/buildModel.js +4 -6
- package/dist/model/model-parser.d.ts +9 -9
- package/dist/model/model-parser.js +3 -0
- package/dist/model/parser/Base.d.ts +1 -1
- package/dist/model/parser/Base.js +1 -1
- package/dist/model/parser/DeploymentModelParser.d.ts +1 -1
- package/dist/model/parser/DeploymentViewParser.d.ts +1 -1
- package/dist/model/parser/DeploymentViewParser.js +2 -2
- package/dist/model/parser/FqnRefParser.d.ts +1 -1
- package/dist/model/parser/FqnRefParser.js +8 -1
- package/dist/model/parser/GlobalsParser.d.ts +1 -1
- package/dist/model/parser/ImportsParser.d.ts +1 -1
- package/dist/model/parser/ModelParser.d.ts +1 -1
- package/dist/model/parser/PredicatesParser.d.ts +1 -1
- package/dist/model/parser/SpecificationParser.d.ts +1 -1
- package/dist/model/parser/ViewsParser.d.ts +1 -1
- package/dist/model/parser/ViewsParser.js +3 -3
- package/dist/module.d.ts +13 -9
- package/dist/module.js +28 -30
- package/dist/protocol.d.ts +18 -4
- package/dist/protocol.js +5 -1
- package/dist/test/testServices.d.ts +5 -2
- package/dist/test/testServices.js +7 -3
- package/dist/validation/DocumentValidator.d.ts +11 -0
- package/dist/validation/DocumentValidator.js +16 -0
- package/dist/validation/index.d.ts +1 -1
- package/dist/validation/index.js +1 -0
- package/dist/workspace/LangiumDocuments.d.ts +1 -0
- package/dist/workspace/LangiumDocuments.js +10 -1
- package/dist/workspace/ProjectsManager.d.ts +35 -17
- package/dist/workspace/ProjectsManager.js +168 -54
- package/dist/workspace/WorkspaceManager.d.ts +9 -2
- package/dist/workspace/WorkspaceManager.js +31 -40
- package/package.json +14 -10
- package/dist/LikeC4FileSystem.d.ts +0 -14
- package/dist/LikeC4FileSystem.js +0 -39
- package/dist/mcp/sseserver/MCPServer.js +0 -80
- package/dist/mcp/sseserver/MCPServerFactory.js +0 -50
- package/dist/mcp/sseserver/WithMCPServer.d.ts +0 -9
- package/dist/mcp/sseserver/WithMCPServer.js +0 -53
- package/dist/mcp/tools/read-project-elements.js +0 -93
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
-
import packageJson from "../../../package.json" with { type: "json" };
|
|
3
|
-
import { listProjects } from "../tools/list-projects.js";
|
|
4
|
-
import { openView } from "../tools/open-view.js";
|
|
5
|
-
import { readElement } from "../tools/read-element.js";
|
|
6
|
-
import { readProjectElements } from "../tools/read-project-elements.js";
|
|
7
|
-
import { readProjectSummary } from "../tools/read-project-summary.js";
|
|
8
|
-
import { readView } from "../tools/read-view.js";
|
|
9
|
-
import { searchElement } from "../tools/search-element.js";
|
|
10
|
-
export class LikeC4MCPServerFactory {
|
|
11
|
-
constructor(services) {
|
|
12
|
-
this.services = services;
|
|
13
|
-
}
|
|
14
|
-
create(options) {
|
|
15
|
-
const isInEditor = this.services.shared.lsp.Connection !== void 0;
|
|
16
|
-
const mcp = new McpServer({
|
|
17
|
-
name: "LikeC4",
|
|
18
|
-
version: packageJson.version
|
|
19
|
-
}, {
|
|
20
|
-
instructions: `Provides access to LikeC4 model.
|
|
21
|
-
Available tools:
|
|
22
|
-
- list-projects: List all available LikeC4 projects in the workspace
|
|
23
|
-
- read-project-summary: to understand project specifications (what element kinds, tags, metadata keys are available) and available project views
|
|
24
|
-
- read-project-elements: list all elements in the project
|
|
25
|
-
- search-element: Search for LikeC4 element by partial match of id, title, kind, shape or tags
|
|
26
|
-
- read-element: all information about the element (includes source location)
|
|
27
|
-
- read-view: all information about the view (includes source location)
|
|
28
|
-
${isInEditor ? "- open-view: opens the panel in the editor with the LikeC4 view" : ""}
|
|
29
|
-
|
|
30
|
-
Documentation for LikeC4 is available at https://likec4.dev/llms-full.txt
|
|
31
|
-
`,
|
|
32
|
-
...options,
|
|
33
|
-
capabilities: {
|
|
34
|
-
tools: {},
|
|
35
|
-
resources: {},
|
|
36
|
-
...options?.capabilities
|
|
37
|
-
}
|
|
38
|
-
});
|
|
39
|
-
mcp.registerTool(...listProjects(this.services.likec4.LanguageServices));
|
|
40
|
-
mcp.registerTool(...readProjectSummary(this.services.likec4.LanguageServices));
|
|
41
|
-
mcp.registerTool(...readProjectElements(this.services.likec4.LanguageServices));
|
|
42
|
-
mcp.registerTool(...readElement(this.services.likec4.LanguageServices));
|
|
43
|
-
mcp.registerTool(...readView(this.services.likec4.LanguageServices));
|
|
44
|
-
mcp.registerTool(...searchElement(this.services.likec4.LanguageServices));
|
|
45
|
-
if (isInEditor) {
|
|
46
|
-
mcp.registerTool(...openView(this.services.likec4.LanguageServices));
|
|
47
|
-
}
|
|
48
|
-
return mcp;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { LikeC4Services } from '../../module';
|
|
2
|
-
import type { LikeC4MCPServer } from '../interfaces';
|
|
3
|
-
import { LikeC4MCPServerFactory } from './MCPServerFactory';
|
|
4
|
-
export declare const WithMCPServer: {
|
|
5
|
-
mcp: {
|
|
6
|
-
Server(services: LikeC4Services): LikeC4MCPServer;
|
|
7
|
-
ServerFactory(services: LikeC4Services): LikeC4MCPServerFactory;
|
|
8
|
-
};
|
|
9
|
-
};
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { loggable } from "@likec4/log";
|
|
2
|
-
import { isError } from "remeda";
|
|
3
|
-
import { logger } from "../../logger.js";
|
|
4
|
-
import { SSELikeC4MCPServer } from "./MCPServer.js";
|
|
5
|
-
import { LikeC4MCPServerFactory } from "./MCPServerFactory.js";
|
|
6
|
-
export const WithMCPServer = {
|
|
7
|
-
mcp: {
|
|
8
|
-
Server(services) {
|
|
9
|
-
logger.debug("Creating SSELikeC4MCPServer");
|
|
10
|
-
const server = new SSELikeC4MCPServer(services);
|
|
11
|
-
const langId = services.LanguageMetaData.languageId;
|
|
12
|
-
const connection = services.shared.lsp.Connection;
|
|
13
|
-
services.shared.workspace.ConfigurationProvider.onConfigurationSectionUpdate((update) => {
|
|
14
|
-
if (update.section !== langId) {
|
|
15
|
-
logger.warn("Unexpected configuration update: {update}", { update });
|
|
16
|
-
return;
|
|
17
|
-
}
|
|
18
|
-
logger.debug("Configuration update: {update}", { update });
|
|
19
|
-
const {
|
|
20
|
-
enabled = false,
|
|
21
|
-
port = 33335
|
|
22
|
-
} = update.configuration.mcp;
|
|
23
|
-
if (!enabled) {
|
|
24
|
-
server.stop();
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
Promise.resolve().then(() => server.start(port)).then(() => {
|
|
28
|
-
connection?.telemetry?.logEvent({
|
|
29
|
-
eventName: "mcp-server-started",
|
|
30
|
-
mcpPort: port
|
|
31
|
-
});
|
|
32
|
-
}).catch((err) => {
|
|
33
|
-
const message = isError(err) ? err.message : void 0;
|
|
34
|
-
connection?.telemetry?.logEvent({
|
|
35
|
-
eventName: "mcp-server-start-failed",
|
|
36
|
-
mcpPort: port,
|
|
37
|
-
...message && { message }
|
|
38
|
-
});
|
|
39
|
-
logger.error("Failed to start LikeC4 MCP Server", { err });
|
|
40
|
-
if (connection) {
|
|
41
|
-
connection.window.showErrorMessage(`LikeC4: Failed to start MCP Server
|
|
42
|
-
|
|
43
|
-
${loggable(err)}`);
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
|
-
});
|
|
47
|
-
return server;
|
|
48
|
-
},
|
|
49
|
-
ServerFactory(services) {
|
|
50
|
-
return new LikeC4MCPServerFactory(services);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
};
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import { invariant } from "@likec4/core";
|
|
2
|
-
import z from "zod";
|
|
3
|
-
import { safeCall } from "../../utils/index.js";
|
|
4
|
-
import { ProjectsManager } from "../../workspace/index.js";
|
|
5
|
-
import { likec4Tool } from "../utils.js";
|
|
6
|
-
import { locationSchema } from "./_common.js";
|
|
7
|
-
const elementSchema = z.array(
|
|
8
|
-
z.discriminatedUnion("type", [
|
|
9
|
-
z.object({
|
|
10
|
-
type: z.literal("logical"),
|
|
11
|
-
id: z.string().describe("Element ID (FQN)"),
|
|
12
|
-
kind: z.string(),
|
|
13
|
-
title: z.string(),
|
|
14
|
-
description: z.string().nullish(),
|
|
15
|
-
technology: z.string().nullish(),
|
|
16
|
-
shape: z.string(),
|
|
17
|
-
tags: z.array(z.string()),
|
|
18
|
-
defaultView: z.string().nullish().describe("Name of the default view of this element"),
|
|
19
|
-
sourceLocation: locationSchema.nullish()
|
|
20
|
-
}),
|
|
21
|
-
z.object({
|
|
22
|
-
type: z.literal("deployment-node"),
|
|
23
|
-
id: z.string().describe("Deployment ID (FQN)"),
|
|
24
|
-
kind: z.string(),
|
|
25
|
-
title: z.string(),
|
|
26
|
-
description: z.string().nullish(),
|
|
27
|
-
technology: z.string().nullish(),
|
|
28
|
-
shape: z.string(),
|
|
29
|
-
tags: z.array(z.string()),
|
|
30
|
-
defaultView: z.string().nullish().describe("Name of the default view of this element"),
|
|
31
|
-
sourceLocation: locationSchema.nullish()
|
|
32
|
-
})
|
|
33
|
-
])
|
|
34
|
-
);
|
|
35
|
-
export const readProjectElements = likec4Tool({
|
|
36
|
-
name: "read-project-elements",
|
|
37
|
-
annotations: {
|
|
38
|
-
readOnlyHint: true
|
|
39
|
-
},
|
|
40
|
-
description: `
|
|
41
|
-
Returns array of all elements in the project:
|
|
42
|
-
- type (logical or deployment-node)
|
|
43
|
-
- id (FQN)
|
|
44
|
-
- kind
|
|
45
|
-
- title, description and technology
|
|
46
|
-
- shape
|
|
47
|
-
- assigned tags
|
|
48
|
-
- name of the default view of this element if any (applies to logical elements only)
|
|
49
|
-
- source location (where the element is defined, if running in the editor)
|
|
50
|
-
`,
|
|
51
|
-
inputSchema: {
|
|
52
|
-
project: z.string().optional().describe('Project name (optional, will use "default" if not specified)')
|
|
53
|
-
},
|
|
54
|
-
outputSchema: {
|
|
55
|
-
elements: elementSchema
|
|
56
|
-
}
|
|
57
|
-
}, async (languageServices, args) => {
|
|
58
|
-
const projectId = args.project ?? ProjectsManager.DefaultProjectId;
|
|
59
|
-
const project = languageServices.projects().find((p) => p.id === projectId);
|
|
60
|
-
invariant(project, `Project "${projectId}" not found`);
|
|
61
|
-
const model = await languageServices.computedModel(project.id);
|
|
62
|
-
const elements = [];
|
|
63
|
-
for (const el of model.elements()) {
|
|
64
|
-
elements.push({
|
|
65
|
-
type: "logical",
|
|
66
|
-
id: el.id,
|
|
67
|
-
title: el.title,
|
|
68
|
-
description: el.description.text,
|
|
69
|
-
technology: el.technology,
|
|
70
|
-
kind: el.kind,
|
|
71
|
-
tags: [...el.tags],
|
|
72
|
-
shape: el.shape,
|
|
73
|
-
defaultView: el.defaultView?.id,
|
|
74
|
-
sourceLocation: safeCall(() => languageServices.locate({ element: el.id, projectId }))
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
for (const el of model.deployment.nodes()) {
|
|
78
|
-
elements.push({
|
|
79
|
-
type: "deployment-node",
|
|
80
|
-
id: el.id,
|
|
81
|
-
title: el.title,
|
|
82
|
-
description: el.description.text,
|
|
83
|
-
technology: el.technology,
|
|
84
|
-
kind: el.kind,
|
|
85
|
-
tags: [...el.tags],
|
|
86
|
-
shape: el.shape,
|
|
87
|
-
sourceLocation: safeCall(() => languageServices.locate({ deployment: el.id, projectId }))
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
return {
|
|
91
|
-
elements
|
|
92
|
-
};
|
|
93
|
-
});
|