@treedy/lsp-mcp 0.1.4 → 0.1.6
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/index.js +113 -8
- package/dist/index.js.map +4 -4
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -19845,6 +19845,7 @@ function loadConfig() {
|
|
|
19845
19845
|
const typescriptEnabled = getEnvBool("LSP_MCP_TYPESCRIPT_ENABLED", true);
|
|
19846
19846
|
const vueEnabled = getEnvBool("LSP_MCP_VUE_ENABLED", true);
|
|
19847
19847
|
const autoUpdate = getEnvBool("LSP_MCP_AUTO_UPDATE", true);
|
|
19848
|
+
const eagerStart = getEnvBool("LSP_MCP_EAGER_START", false);
|
|
19848
19849
|
return {
|
|
19849
19850
|
python: {
|
|
19850
19851
|
enabled: pythonEnabled,
|
|
@@ -19856,7 +19857,8 @@ function loadConfig() {
|
|
|
19856
19857
|
vue: {
|
|
19857
19858
|
enabled: vueEnabled
|
|
19858
19859
|
},
|
|
19859
|
-
autoUpdate
|
|
19860
|
+
autoUpdate,
|
|
19861
|
+
eagerStart
|
|
19860
19862
|
};
|
|
19861
19863
|
}
|
|
19862
19864
|
function getEnvBool(name, defaultValue) {
|
|
@@ -21661,6 +21663,7 @@ function registerBackendTools(language, tools) {
|
|
|
21661
21663
|
console.error(`[lsp-mcp] Registered ${namespacedName}`);
|
|
21662
21664
|
count++;
|
|
21663
21665
|
}
|
|
21666
|
+
server.sendToolListChanged();
|
|
21664
21667
|
return count;
|
|
21665
21668
|
}
|
|
21666
21669
|
async function startAndRegisterBackend(language) {
|
|
@@ -21711,6 +21714,91 @@ server.registerTool("update_backend", {
|
|
|
21711
21714
|
description: "Update a backend to the latest version. This will restart the backend with the newest version available.",
|
|
21712
21715
|
inputSchema: updateBackendSchema
|
|
21713
21716
|
}, async ({ language }) => updateBackend(language, backendManager, config2, updateAndRestartBackend));
|
|
21717
|
+
var KNOWN_TOOLS = {
|
|
21718
|
+
python: [
|
|
21719
|
+
{ name: "hover", description: "Get documentation for the symbol at the given position", schema: { file: exports_external.string(), line: exports_external.number().int(), column: exports_external.number().int() } },
|
|
21720
|
+
{ name: "definition", description: "Get the definition location for the symbol at the given position", schema: { file: exports_external.string(), line: exports_external.number().int(), column: exports_external.number().int() } },
|
|
21721
|
+
{ name: "references", description: "Find all references to the symbol at the given position", schema: { file: exports_external.string(), line: exports_external.number().int(), column: exports_external.number().int() } },
|
|
21722
|
+
{ name: "completions", description: "Get code completion suggestions at the given position", schema: { file: exports_external.string(), line: exports_external.number().int(), column: exports_external.number().int() } },
|
|
21723
|
+
{ name: "symbols", description: "Get symbols from a Python file", schema: { file: exports_external.string(), query: exports_external.string().optional() } },
|
|
21724
|
+
{ name: "diagnostics", description: "Get type errors and warnings for a Python file or directory", schema: { path: exports_external.string() } },
|
|
21725
|
+
{ name: "rename", description: "Rename the symbol at the given position", schema: { file: exports_external.string(), line: exports_external.number().int(), column: exports_external.number().int(), new_name: exports_external.string() } },
|
|
21726
|
+
{ name: "signature_help", description: "Get function signature information at the given position", schema: { file: exports_external.string(), line: exports_external.number().int(), column: exports_external.number().int() } },
|
|
21727
|
+
{ name: "update_document", description: "Update file content for incremental analysis without writing to disk", schema: { file: exports_external.string(), content: exports_external.string() } },
|
|
21728
|
+
{ name: "search", description: "Search for a regex pattern in files using ripgrep", schema: { pattern: exports_external.string(), path: exports_external.string().optional(), glob: exports_external.string().optional() } },
|
|
21729
|
+
{ name: "status", description: "Get the status of the Python MCP server", schema: {} }
|
|
21730
|
+
],
|
|
21731
|
+
typescript: [
|
|
21732
|
+
{ name: "hover", description: "Get type information and documentation at a specific position", schema: { file: exports_external.string(), line: exports_external.number().int().positive(), column: exports_external.number().int().positive() } },
|
|
21733
|
+
{ name: "definition", description: "Go to definition of a symbol at a specific position", schema: { file: exports_external.string(), line: exports_external.number().int().positive(), column: exports_external.number().int().positive() } },
|
|
21734
|
+
{ name: "references", description: "Find all references to a symbol at a specific position", schema: { file: exports_external.string(), line: exports_external.number().int().positive(), column: exports_external.number().int().positive() } },
|
|
21735
|
+
{ name: "completions", description: "Get code completion suggestions at a specific position", schema: { file: exports_external.string(), line: exports_external.number().int().positive(), column: exports_external.number().int().positive(), limit: exports_external.number().int().positive().default(20).optional() } },
|
|
21736
|
+
{ name: "signature_help", description: "Get function signature help at a specific position", schema: { file: exports_external.string(), line: exports_external.number().int().positive(), column: exports_external.number().int().positive() } },
|
|
21737
|
+
{ name: "symbols", description: "Extract symbols (classes, functions, methods, variables) from a file", schema: { file: exports_external.string(), query: exports_external.string().optional() } },
|
|
21738
|
+
{ name: "diagnostics", description: "Get type errors and warnings for a TypeScript/JavaScript file", schema: { path: exports_external.string() } },
|
|
21739
|
+
{ name: "rename", description: "Preview renaming a symbol at a specific position", schema: { file: exports_external.string(), line: exports_external.number().int().positive(), column: exports_external.number().int().positive(), newName: exports_external.string() } },
|
|
21740
|
+
{ name: "update_document", description: "Update file content for incremental analysis without writing to disk", schema: { file: exports_external.string(), content: exports_external.string() } },
|
|
21741
|
+
{ name: "status", description: "Check TypeScript environment status for a project", schema: { file: exports_external.string() } },
|
|
21742
|
+
{ name: "search", description: "Search for a pattern in files using ripgrep", schema: { pattern: exports_external.string(), path: exports_external.string().optional(), glob: exports_external.string().optional() } },
|
|
21743
|
+
{ name: "move", description: "Move a function, class, or variable to a new file", schema: { file: exports_external.string(), line: exports_external.number().int().positive(), column: exports_external.number().int().positive(), destination: exports_external.string().optional(), preview: exports_external.boolean().default(false).optional() } },
|
|
21744
|
+
{ name: "function_signature", description: "Get the current signature of a function at a specific position", schema: { file: exports_external.string(), line: exports_external.number().int().positive(), column: exports_external.number().int().positive() } },
|
|
21745
|
+
{ name: "available_refactors", description: "Get available refactoring actions at a specific position", schema: { file: exports_external.string(), line: exports_external.number().int().positive(), column: exports_external.number().int().positive() } },
|
|
21746
|
+
{ name: "apply_refactor", description: "Apply a specific refactoring action at a position", schema: { file: exports_external.string(), line: exports_external.number().int().positive(), column: exports_external.number().int().positive(), refactorName: exports_external.string(), actionName: exports_external.string(), preview: exports_external.boolean().default(false).optional() } }
|
|
21747
|
+
],
|
|
21748
|
+
vue: [
|
|
21749
|
+
{ name: "hover", description: "Get type information and documentation at a specific position in a Vue SFC file", schema: { file: exports_external.string(), line: exports_external.number().int().positive(), column: exports_external.number().int().positive() } },
|
|
21750
|
+
{ name: "definition", description: "Go to definition of a symbol at a specific position in a Vue SFC file", schema: { file: exports_external.string(), line: exports_external.number().int().positive(), column: exports_external.number().int().positive() } },
|
|
21751
|
+
{ name: "references", description: "Find all references to a symbol at a specific position in a Vue SFC file", schema: { file: exports_external.string(), line: exports_external.number().int().positive(), column: exports_external.number().int().positive() } },
|
|
21752
|
+
{ name: "completions", description: "Get code completion suggestions at a specific position in a Vue SFC file", schema: { file: exports_external.string(), line: exports_external.number().int().positive(), column: exports_external.number().int().positive(), limit: exports_external.number().int().positive().default(20).optional() } },
|
|
21753
|
+
{ name: "signature_help", description: "Get function signature help at a specific position in a Vue SFC file", schema: { file: exports_external.string(), line: exports_external.number().int().positive(), column: exports_external.number().int().positive() } },
|
|
21754
|
+
{ name: "diagnostics", description: "Get type errors and warnings for Vue SFC files", schema: { path: exports_external.string() } },
|
|
21755
|
+
{ name: "update_document", description: "Update Vue file content for incremental analysis without writing to disk", schema: { file: exports_external.string(), content: exports_external.string() } },
|
|
21756
|
+
{ name: "symbols", description: "Extract symbols (variables, functions, components) from a Vue SFC file", schema: { file: exports_external.string(), query: exports_external.string().optional() } },
|
|
21757
|
+
{ name: "rename", description: "Preview renaming a symbol at a specific position", schema: { file: exports_external.string(), line: exports_external.number().int().positive(), column: exports_external.number().int().positive(), newName: exports_external.string() } },
|
|
21758
|
+
{ name: "search", description: "Search for a pattern in Vue files using ripgrep", schema: { pattern: exports_external.string(), path: exports_external.string().optional(), glob: exports_external.string().optional() } },
|
|
21759
|
+
{ name: "status", description: "Check Vue Language Server status for a project", schema: { file: exports_external.string() } }
|
|
21760
|
+
]
|
|
21761
|
+
};
|
|
21762
|
+
function preRegisterKnownTools() {
|
|
21763
|
+
const languages = [];
|
|
21764
|
+
if (config2.python.enabled)
|
|
21765
|
+
languages.push("python");
|
|
21766
|
+
if (config2.typescript.enabled)
|
|
21767
|
+
languages.push("typescript");
|
|
21768
|
+
if (config2.vue.enabled)
|
|
21769
|
+
languages.push("vue");
|
|
21770
|
+
let totalCount = 0;
|
|
21771
|
+
for (const language of languages) {
|
|
21772
|
+
const tools = KNOWN_TOOLS[language];
|
|
21773
|
+
if (!tools)
|
|
21774
|
+
continue;
|
|
21775
|
+
for (const tool of tools) {
|
|
21776
|
+
const namespacedName = `${language}_${tool.name}`;
|
|
21777
|
+
server.registerTool(namespacedName, {
|
|
21778
|
+
description: tool.description,
|
|
21779
|
+
inputSchema: tool.schema
|
|
21780
|
+
}, async (args) => {
|
|
21781
|
+
if (!startedBackends.has(language)) {
|
|
21782
|
+
console.error(`[lsp-mcp] Auto-starting ${language} backend for ${tool.name}...`);
|
|
21783
|
+
try {
|
|
21784
|
+
await backendManager.getBackend(language);
|
|
21785
|
+
startedBackends.add(language);
|
|
21786
|
+
console.error(`[lsp-mcp] ${language} backend started`);
|
|
21787
|
+
} catch (error2) {
|
|
21788
|
+
return {
|
|
21789
|
+
content: [{ type: "text", text: JSON.stringify({ error: `Failed to start ${language} backend: ${error2}` }) }]
|
|
21790
|
+
};
|
|
21791
|
+
}
|
|
21792
|
+
}
|
|
21793
|
+
return backendManager.callTool(language, tool.name, args);
|
|
21794
|
+
});
|
|
21795
|
+
totalCount++;
|
|
21796
|
+
}
|
|
21797
|
+
console.error(`[lsp-mcp] Pre-registered ${tools.length} ${language} tools`);
|
|
21798
|
+
}
|
|
21799
|
+
console.error(`[lsp-mcp] Total: ${totalCount} tools pre-registered (backends start on first use)`);
|
|
21800
|
+
}
|
|
21801
|
+
preRegisterKnownTools();
|
|
21714
21802
|
async function gracefulShutdown(signal) {
|
|
21715
21803
|
console.error(`
|
|
21716
21804
|
[lsp-mcp] Received ${signal}, shutting down gracefully...`);
|
|
@@ -21731,15 +21819,32 @@ async function main() {
|
|
|
21731
21819
|
console.error(` Version: ${packageJson.version}`);
|
|
21732
21820
|
console.error(" Python:", config2.python.enabled ? `enabled (${config2.python.provider})` : "disabled");
|
|
21733
21821
|
console.error(" TypeScript:", config2.typescript.enabled ? "enabled" : "disabled");
|
|
21734
|
-
console.error("");
|
|
21735
|
-
console.error("Backends are loaded on-demand. Use these tools to get started:");
|
|
21736
|
-
console.error(" - list_backends: See available backends and their status");
|
|
21737
|
-
console.error(" - start_backend: Install and start a backend (e.g., start_backend language=python)");
|
|
21738
|
-
console.error("");
|
|
21739
|
-
console.error("Prompts available: code-navigation, refactoring, code-analysis, lsp-rules, lsp-quick-start");
|
|
21822
|
+
console.error(" Vue:", config2.vue.enabled ? "enabled" : "disabled");
|
|
21740
21823
|
console.error("");
|
|
21741
21824
|
const transport = new StdioServerTransport;
|
|
21742
21825
|
await server.connect(transport);
|
|
21826
|
+
if (config2.eagerStart) {
|
|
21827
|
+
console.error("Eager start enabled - starting all backends now...");
|
|
21828
|
+
const languages = [];
|
|
21829
|
+
if (config2.python.enabled)
|
|
21830
|
+
languages.push("python");
|
|
21831
|
+
if (config2.typescript.enabled)
|
|
21832
|
+
languages.push("typescript");
|
|
21833
|
+
if (config2.vue.enabled)
|
|
21834
|
+
languages.push("vue");
|
|
21835
|
+
await Promise.allSettled(languages.map(async (lang) => {
|
|
21836
|
+
try {
|
|
21837
|
+
await backendManager.getBackend(lang);
|
|
21838
|
+
startedBackends.add(lang);
|
|
21839
|
+
console.error(` ${lang}: backend started`);
|
|
21840
|
+
} catch (error2) {
|
|
21841
|
+
console.error(` ${lang}: failed to start - ${error2}`);
|
|
21842
|
+
}
|
|
21843
|
+
}));
|
|
21844
|
+
} else {
|
|
21845
|
+
console.error("Tools are pre-registered. Backends start automatically on first use.");
|
|
21846
|
+
}
|
|
21847
|
+
console.error("");
|
|
21743
21848
|
console.error("Ready");
|
|
21744
21849
|
}
|
|
21745
21850
|
main().catch((error2) => {
|
|
@@ -21747,4 +21852,4 @@ main().catch((error2) => {
|
|
|
21747
21852
|
process.exit(1);
|
|
21748
21853
|
});
|
|
21749
21854
|
|
|
21750
|
-
//# debugId=
|
|
21855
|
+
//# debugId=45E34912A1845F5D64756E2164756E21
|