Effect 4 MCP server (stdio/HTTP) bridging one LSP process: on-demand document sync with LRU and disk change detection, push/pull diagnostics reconciliation, capability-gated tools, diagnostics resources, tests against a fixture server.
24 lines
865 B
TypeScript
24 lines
865 B
TypeScript
import { fileURLToPath } from "node:url";
|
|
import { Effect, FileSystem, Layer, Path } from "effect";
|
|
import { LanguageServer } from "../../src/lsp/LanguageServer.ts";
|
|
|
|
const server = fileURLToPath(new URL("./server.ts", import.meta.url));
|
|
|
|
/** A temporary workspace with the given files, served by the fixture language server. */
|
|
export const workspace = (files: Record<string, string>) =>
|
|
Layer.unwrap(
|
|
Effect.gen(function* () {
|
|
const fs = yield* FileSystem.FileSystem;
|
|
const path = yield* Path.Path;
|
|
const root = yield* fs.makeTempDirectoryScoped({ prefix: "lsp-mcp-" });
|
|
for (const [name, content] of Object.entries(files)) {
|
|
yield* fs.writeFileString(path.join(root, name), content);
|
|
}
|
|
return LanguageServer.layer({
|
|
command: process.execPath,
|
|
args: [server],
|
|
root,
|
|
});
|
|
}),
|
|
);
|