mirror of
https://gh-proxy.org/https://github.com/klinsmaya/multica.git
synced 2026-11-11 02:46:45 +08:00
* fix(agent): deliver MCP servers to Pi tasks Pi skipped untrusted project config in JSON mode, and Multica never wrote .pi/mcp.json, so composed MCP servers never reached the runtime. Co-authored-by: Cursor <[email protected]> * fix(agent): hand Pi its MCP servers through a temporary extension Writing .pi/mcp.json and passing --approve trusted the whole project directory and failed when that file already existed. An explicit --extension loads the servers without project trust. Co-authored-by: Cursor <[email protected]> * docs: mark Pi as reading agent MCP configuration The provider comparison still said Pi skipped the MCP field. Pi now receives that configuration. Co-authored-by: Cursor <[email protected]> * fix(agent): harden Pi MCP registration Co-authored-by: multica-agent <[email protected]> * fix(agent): allow empty Pi MCP configuration Co-authored-by: multica-agent <[email protected]> --------- Co-authored-by: Cursor <[email protected]> Co-authored-by: Yushen <[email protected]> Co-authored-by: multica-agent <[email protected]>
73 lines
1.9 KiB
Go
73 lines
1.9 KiB
Go
package execenv
|
|
|
|
import (
|
|
"encoding/json"
|
|
"os"
|
|
"path/filepath"
|
|
"testing"
|
|
)
|
|
|
|
func TestPreparePiLeavesProjectMcpConfigAlone(t *testing.T) {
|
|
t.Parallel()
|
|
workspacesRoot := t.TempDir()
|
|
|
|
env, err := Prepare(PrepareParams{
|
|
WorkspacesRoot: workspacesRoot,
|
|
WorkspaceID: "ws-pi-mcp",
|
|
TaskID: "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
|
|
AgentName: "Pi",
|
|
Provider: "pi",
|
|
McpConfig: json.RawMessage(`{"mcpServers":{"probe":{"command":"echo"}}}`),
|
|
Task: TaskContextForEnv{
|
|
IssueID: "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
|
|
},
|
|
}, testLogger())
|
|
if err != nil {
|
|
t.Fatalf("Prepare: %v", err)
|
|
}
|
|
defer env.Cleanup(true)
|
|
|
|
if _, err := os.Stat(filepath.Join(env.WorkDir, ".pi", "mcp.json")); !os.IsNotExist(err) {
|
|
t.Fatalf("Prepare created .pi/mcp.json, stat error = %v", err)
|
|
}
|
|
}
|
|
|
|
func TestPreparePiDoesNotOverwriteExistingProjectMcpConfig(t *testing.T) {
|
|
t.Parallel()
|
|
workspacesRoot := t.TempDir()
|
|
userDir := t.TempDir()
|
|
path := filepath.Join(userDir, ".pi", "mcp.json")
|
|
if err := os.MkdirAll(filepath.Dir(path), 0o755); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
existing := []byte(`{"mcpServers":{"user":{"command":"echo"}}}`)
|
|
if err := os.WriteFile(path, existing, 0o644); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
env, err := Prepare(PrepareParams{
|
|
WorkspacesRoot: workspacesRoot,
|
|
WorkspaceID: "ws-pi-mcp-existing",
|
|
TaskID: "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
|
|
AgentName: "Pi",
|
|
Provider: "pi",
|
|
LocalWorkDir: userDir,
|
|
McpConfig: json.RawMessage(`{"mcpServers":{"managed":{"command":"echo"}}}`),
|
|
Task: TaskContextForEnv{
|
|
IssueID: "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
|
|
},
|
|
}, testLogger())
|
|
if err != nil {
|
|
t.Fatalf("Prepare: %v", err)
|
|
}
|
|
defer env.Cleanup(true)
|
|
|
|
data, err := os.ReadFile(path)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if string(data) != string(existing) {
|
|
t.Fatalf("existing .pi/mcp.json changed to %s", data)
|
|
}
|
|
}
|