MCPcopy
hub / github.com/claude-code-best/claude-code / ensureServerStarted

Function ensureServerStarted

src/services/lsp/LSPServerManager.ts:217–238  ·  view source on GitHub ↗

* Ensure the appropriate LSP server is started for the given file. * Returns undefined if no server handles this file type. * * @throws {Error} If server fails to start

(
    filePath: string,
  )

Source from the content-addressed store, hash-verified

215 * @throws {Error} If server fails to start
216 */
217 async function ensureServerStarted(
218 filePath: string,
219 ): Promise<LSPServerInstance | undefined> {
220 const server = getServerForFile(filePath)
221 if (!server) return undefined
222
223 if (server.state === 'stopped' || server.state === 'error') {
224 try {
225 await server.start()
226 } catch (error) {
227 const err = error as Error
228 logError(
229 new Error(
230 `Failed to start LSP server for file ${filePath}: ${err.message}`,
231 ),
232 )
233 throw error
234 }
235 }
236
237 return server
238 }
239
240 /**
241 * Send a request to the appropriate LSP server for the given file.

Callers 2

sendRequestFunction · 0.85
openFileFunction · 0.85

Calls 3

getServerForFileFunction · 0.85
startMethod · 0.65
logErrorFunction · 0.50

Tested by

no test coverage detected