Self-hosted workflows for coding-agent delivery. Orchestrate CodeBuddy, Codex and Claude Code with scripts and human approval gates. Includes Local workflows for coding assistants.
JavaScript agent-orchestrationagentic-workflowai-agentsai-codingclaude-codecode-reviewcodebuddycodexcoding-agentscursordeveloper-toolshuman-on-the-loopllmmcpmulti-agentsdlcself-hostedsopworkflow-automationworkflow-engine
【架构优化】从 resolveAssets 中拆出 roleMCPServerVisible 并复用 loadMCPFiles (#526)
fx-kurumib8f2c0565de9
diff --git a/internal/engine/assets.go b/internal/engine/assets.goindex 787f94b8..2e2e2168 100644--- a/internal/engine/assets.go+++ b/internal/engine/assets.go@@ -117,27 +117,11 @@ func (e *Engine) resolveAssets(agent domain.AgentDefinition, projectID, workflow}for _, id := range agent.MCPServers {if v, ok := e.repo.MCPServer(id); ok {- if v.Scope == "" {- continue- }- if v.Scope == "project" && v.ProjectID != projectID {- continue- }- if v.Scope == "personal" && v.OwnerUserID != userID {- continue- }- if v.Scope == "personal" && v.MarketID != "" {+ if !roleMCPServerVisible(v, projectID, userID) {continue}bundle.MCPServers = append(bundle.MCPServers, v)- if len(v.FileRefs) > 0 {- if contents := e.repo.MCPFileContents(v.ID); len(contents) > 0 {- if bundle.MCPFiles == nil {- bundle.MCPFiles = map[string]map[string][]byte{}- }- bundle.MCPFiles[v.ID] = contents- }- }+ e.loadMCPFiles(&bundle, v)continue}if v, ok := e.projectMarketMCP(id, projectID); ok {@@ -159,6 +143,23 @@ func (e *Engine) resolveAssets(agent domain.AgentDefinition, projectID, workflowreturn bundle}+// roleMCPServerVisible reports whether a catalog MCP server listed on a role+// may be injected for this run: servers without a scope are skipped, project+// servers must belong to the run's project, and personal servers must be the+// caller's own and not installed from the market.+func roleMCPServerVisible(server domain.MCPServerDefinition, projectID string, userID int64) bool {+ switch server.Scope {+ case "":+ return false+ case "project":+ return server.ProjectID == projectID+ case "personal":+ return server.OwnerUserID == userID && server.MarketID == ""+ default:+ return true+ }+}+// appendWorkflowGlobalRules injects project rules that were marked global and// bound to this SOP. Every agent node of the workflow receives them, even when// the node's role does not list the rule. Script and approval nodes do notdiff --git a/internal/engine/assets_mcp_visible_test.go b/internal/engine/assets_mcp_visible_test.gonew file mode 100644index 00000000..56ac4ebe--- /dev/null+++ b/internal/engine/assets_mcp_visible_test.go@@ -0,0 +1,30 @@+package engine++import (+ "testing"++ "agentflow/internal/domain"+)++func TestRoleMCPServerVisible(t *testing.T) {+ cases := []struct {+ name string+ server domain.MCPServerDefinition+ want bool+ }{+ {"no scope", domain.MCPServerDefinition{}, false},+ {"project same", domain.MCPServerDefinition{Scope: "project", ProjectID: "p1"}, true},+ {"project other", domain.MCPServerDefinition{Scope: "project", ProjectID: "p2"}, false},+ {"personal own", domain.MCPServerDefinition{Scope: "personal", OwnerUserID: 7}, true},+ {"personal other user", domain.MCPServerDefinition{Scope: "personal", OwnerUserID: 8}, false},+ {"personal market", domain.MCPServerDefinition{Scope: "personal", OwnerUserID: 7, MarketID: "m1"}, false},+ {"other scope", domain.MCPServerDefinition{Scope: "shared", ProjectID: "p2", OwnerUserID: 8, MarketID: "m1"}, true},+ }+ for _, tc := range cases {+ t.Run(tc.name, func(t *testing.T) {+ if got := roleMCPServerVisible(tc.server, "p1", 7); got != tc.want {+ t.Fatalf("roleMCPServerVisible() = %v, want %v", got, tc.want)+ }+ })+ }+}