@@ -117,11 +117,12 @@ type MCPConfig struct {
117117}
118118
119119type LSPConfig struct {
120− Disabled bool `json:"enabled,omitempty" jsonschema:"description=Whether this LSP server is disabled,default=false"`
121− Command string `json:"command" jsonschema:"required,description=Command to execute for the LSP server,example=gopls"`
122− Args []string `json:"args,omitempty" jsonschema:"description=Arguments to pass to the LSP server command"`
123− Options any `json:"options,omitempty" jsonschema:"description=LSP server-specific configuration options"`
124− FileTypes []string `json:"filetypes,omitempty" jsonschema:"description=File types this LSP server handles,example=go,example=mod,example=rs,example=c,example=js,example=ts"`
120+ Disabled bool `json:"enabled,omitempty" jsonschema:"description=Whether this LSP server is disabled,default=false"`
121+ Command string `json:"command" jsonschema:"required,description=Command to execute for the LSP server,example=gopls"`
122+ Args []string `json:"args,omitempty" jsonschema:"description=Arguments to pass to the LSP server command"`
123+ Env map[string]string `json:"env,omitempty" jsonschema:"description=Environment variables to set to the LSP server command"`
124+ Options any `json:"options,omitempty" jsonschema:"description=LSP server-specific configuration options"`
125+ FileTypes []string `json:"filetypes,omitempty" jsonschema:"description=File types this LSP server handles,example=go,example=mod,example=rs,example=c,example=js,example=ts"`
125126}
126127
127128type TUIOptions struct {
@@ -186,22 +187,12 @@ func (l LSPs) Sorted() []LSP {
186187 return sorted
187188}
188189
189−func (m MCPConfig) ResolvedEnv() []string {
190− resolver := NewShellVariableResolver(env.New())
191− for e, v := range m.Env {
192− var err error
193− m.Env[e], err = resolver.ResolveValue(v)
194− if err != nil {
195− slog.Error("error resolving environment variable", "error", err, "variable", e, "value", v)
196− continue
197− }
198− }
190+func (l LSPConfig) ResolvedEnv() []string {
191+ return resolveEnvs(l.Env)
192+}
199193
200− env := make([]string, 0, len(m.Env))
201− for k, v := range m.Env {
202− env = append(env, fmt.Sprintf("%s=%s", k, v))
203− }
204− return env
194+func (m MCPConfig) ResolvedEnv() []string {
195+ return resolveEnvs(m.Env)
205196}
206197
207198func (m MCPConfig) ResolvedHeaders() map[string]string {
@@ -509,3 +500,21 @@ func (c *ProviderConfig) TestConnection(resolver VariableResolver) error {
509500 _ = b.Body.Close()
510501 return nil
511502}
503+
504+func resolveEnvs(envs map[string]string) []string {
505+ resolver := NewShellVariableResolver(env.New())
506+ for e, v := range envs {
507+ var err error
508+ envs[e], err = resolver.ResolveValue(v)
509+ if err != nil {
510+ slog.Error("error resolving environment variable", "error", err, "variable", e, "value", v)
511+ continue
512+ }
513+ }
514+
515+ res := make([]string, 0, len(envs))
516+ for k, v := range envs {
517+ res = append(res, fmt.Sprintf("%s=%s", k, v))
518+ }
519+ return res
520+}