feat: integrate MCP tools with UI actions and improve environment variable inheritance

This commit is contained in:
lilong.129
2025-05-28 22:58:59 +08:00
parent 2fe5b14d63
commit 4ea08b0198
4 changed files with 81 additions and 12 deletions
+5 -1
View File
@@ -110,10 +110,14 @@ func (h *MCPHost) connectToServer(ctx context.Context, serverName string, config
mcpClient, err = client.NewSSEMCPClient(cfg.Url,
client.WithHeaders(parseHeaders(cfg.Headers)))
case STDIOServerConfig:
env := make([]string, 0, len(cfg.Env))
// Start with current process environment variables
env := os.Environ()
// Add or override with config-specific environment variables
for k, v := range cfg.Env {
env = append(env, fmt.Sprintf("%s=%s", k, v))
}
mcpClient, err = client.NewStdioMCPClient(cfg.Command, env, cfg.Args...)
if stdioClient, ok := mcpClient.(*client.Client); ok {
stderr, _ := client.GetStderr(stdioClient)