@treedy/lsp-mcp 0.1.5 → 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 CHANGED
@@ -21714,6 +21714,91 @@ server.registerTool("update_backend", {
21714
21714
  description: "Update a backend to the latest version. This will restart the backend with the newest version available.",
21715
21715
  inputSchema: updateBackendSchema
21716
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();
21717
21802
  async function gracefulShutdown(signal) {
21718
21803
  console.error(`
21719
21804
  [lsp-mcp] Received ${signal}, shutting down gracefully...`);
@@ -21735,12 +21820,11 @@ async function main() {
21735
21820
  console.error(" Python:", config2.python.enabled ? `enabled (${config2.python.provider})` : "disabled");
21736
21821
  console.error(" TypeScript:", config2.typescript.enabled ? "enabled" : "disabled");
21737
21822
  console.error(" Vue:", config2.vue.enabled ? "enabled" : "disabled");
21738
- console.error(" Eager Start:", config2.eagerStart ? "enabled" : "disabled");
21739
21823
  console.error("");
21740
21824
  const transport = new StdioServerTransport;
21741
21825
  await server.connect(transport);
21742
21826
  if (config2.eagerStart) {
21743
- console.error("Starting all enabled backends...");
21827
+ console.error("Eager start enabled - starting all backends now...");
21744
21828
  const languages = [];
21745
21829
  if (config2.python.enabled)
21746
21830
  languages.push("python");
@@ -21748,26 +21832,17 @@ async function main() {
21748
21832
  languages.push("typescript");
21749
21833
  if (config2.vue.enabled)
21750
21834
  languages.push("vue");
21751
- const results = await Promise.allSettled(languages.map(async (lang) => {
21835
+ await Promise.allSettled(languages.map(async (lang) => {
21752
21836
  try {
21753
- const count = await startAndRegisterBackend(lang);
21754
- return { lang, count };
21837
+ await backendManager.getBackend(lang);
21838
+ startedBackends.add(lang);
21839
+ console.error(` ${lang}: backend started`);
21755
21840
  } catch (error2) {
21756
- console.error(`[lsp-mcp] Failed to start ${lang}:`, error2);
21757
- return { lang, error: error2 };
21841
+ console.error(` ${lang}: failed to start - ${error2}`);
21758
21842
  }
21759
21843
  }));
21760
- for (const result of results) {
21761
- if (result.status === "fulfilled" && "count" in result.value) {
21762
- console.error(` ${result.value.lang}: ${result.value.count} tools registered`);
21763
- } else if (result.status === "fulfilled" && "error" in result.value) {
21764
- console.error(` ${result.value.lang}: failed to start`);
21765
- }
21766
- }
21767
21844
  } else {
21768
- console.error("Backends are loaded on-demand. Use these tools to get started:");
21769
- console.error(" - list_backends: See available backends and their status");
21770
- console.error(" - start_backend: Install and start a backend (e.g., start_backend language=python)");
21845
+ console.error("Tools are pre-registered. Backends start automatically on first use.");
21771
21846
  }
21772
21847
  console.error("");
21773
21848
  console.error("Ready");
@@ -21777,4 +21852,4 @@ main().catch((error2) => {
21777
21852
  process.exit(1);
21778
21853
  });
21779
21854
 
21780
- //# debugId=93725E95ED75445864756E2164756E21
21855
+ //# debugId=45E34912A1845F5D64756E2164756E21