MCPcopy
hub / github.com/codeaashu/claude-code / loadPluginLspServers

Function loadPluginLspServers

src/utils/plugins/lspPluginIntegration.ts:57–122  ·  view source on GitHub ↗
(
  plugin: LoadedPlugin,
  errors: PluginError[] = [],
)

Source from the content-addressed store, hash-verified

55 * @returns Record of server name to config, or undefined if no servers
56 */
57export async function loadPluginLspServers(
58 plugin: LoadedPlugin,
59 errors: PluginError[] = [],
60): Promise<Record<string, LspServerConfig> | undefined> {
61 const servers: Record<string, LspServerConfig> = {}
62
63 // 1. Check for .lsp.json file in plugin directory
64 const lspJsonPath = join(plugin.path, '.lsp.json')
65 try {
66 const content = await readFile(lspJsonPath, 'utf-8')
67 const parsed = jsonParse(content)
68 const result = z
69 .record(z.string(), LspServerConfigSchema())
70 .safeParse(parsed)
71
72 if (result.success) {
73 Object.assign(servers, result.data)
74 } else {
75 const errorMsg = `LSP config validation failed for .lsp.json in plugin ${plugin.name}: ${result.error.message}`
76 logError(new Error(errorMsg))
77 errors.push({
78 type: 'lsp-config-invalid',
79 plugin: plugin.name,
80 serverName: '.lsp.json',
81 validationError: result.error.message,
82 source: 'plugin',
83 })
84 }
85 } catch (error) {
86 // .lsp.json is optional, ignore if it doesn't exist
87 if (!isENOENT(error)) {
88 const _errorMsg =
89 error instanceof Error
90 ? `Failed to read/parse .lsp.json in plugin ${plugin.name}: ${error.message}`
91 : `Failed to read/parse .lsp.json file in plugin ${plugin.name}`
92
93 logError(toError(error))
94
95 errors.push({
96 type: 'lsp-config-invalid',
97 plugin: plugin.name,
98 serverName: '.lsp.json',
99 validationError:
100 error instanceof Error
101 ? `Failed to parse JSON: ${error.message}`
102 : 'Failed to parse JSON file',
103 source: 'plugin',
104 })
105 }
106 }
107
108 // 2. Check manifest.lspServers field
109 if (plugin.manifest.lspServers) {
110 const manifestServers = await loadLspServersFromManifest(
111 plugin.manifest.lspServers,
112 plugin.path,
113 plugin.name,
114 errors,

Callers 4

getPluginLspServersFunction · 0.85
refreshActivePluginsFunction · 0.85
useManagePluginsFunction · 0.85

Calls 9

readFileFunction · 0.85
jsonParseFunction · 0.85
isENOENTFunction · 0.85
toErrorFunction · 0.85
keysMethod · 0.80
logErrorFunction · 0.50
recordMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected