MCPcopy Index your code
hub / github.com/coder/coder / filterExternalMCPConfigsForTurn

Function filterExternalMCPConfigsForTurn

coderd/x/chatd/chatd.go:6509–6533  ·  view source on GitHub ↗

filterExternalMCPConfigsForTurn returns the external MCP server configs visible on the current turn. Explore children snapshot this filtered set at spawn time so later model overrides cannot widen the external-tool boundary.

(
	configs []database.MCPServerConfig,
	mode database.NullChatPlanMode,
	parentChatID uuid.NullUUID,
)

Source from the content-addressed store, hash-verified

6507// visible on the current turn. Explore children snapshot this filtered set at
6508// spawn time so later model overrides cannot widen the external-tool boundary.
6509func filterExternalMCPConfigsForTurn(
6510 configs []database.MCPServerConfig,
6511 mode database.NullChatPlanMode,
6512 parentChatID uuid.NullUUID,
6513) ([]database.MCPServerConfig, map[uuid.UUID]struct{}) {
6514 if !mode.Valid || mode.ChatPlanMode != database.ChatPlanModePlan {
6515 return configs, nil
6516 }
6517 if parentChatID.Valid {
6518 // Plan-mode subagents do not receive external MCP tools because
6519 // their trust boundary is narrower than the root chat's.
6520 return nil, map[uuid.UUID]struct{}{}
6521 }
6522
6523 filtered := make([]database.MCPServerConfig, 0, len(configs))
6524 approvedIDs := make(map[uuid.UUID]struct{})
6525 for _, cfg := range configs {
6526 if !cfg.AllowInPlanMode {
6527 continue
6528 }
6529 filtered = append(filtered, cfg)
6530 approvedIDs[cfg.ID] = struct{}{}
6531 }
6532 return filtered, approvedIDs
6533}
6534
6535func builtinPlanToolAllowed(name string, isRootChat bool) bool {
6536 switch name {

Callers 3

runChatMethod · 0.85

Calls

no outgoing calls

Tested by 1