MCPcopy Create free account
hub / github.com/compozy/agh / networkChannelCreate

Method networkChannelCreate

internal/daemon/native_create_tools.go:50–91  ·  view source on GitHub ↗
(
	ctx context.Context,
	scope toolspkg.Scope,
	req toolspkg.CallRequest,
)

Source from the content-addressed store, hash-verified

48}
49
50func (n *daemonNativeTools) networkChannelCreate(
51 ctx context.Context,
52 scope toolspkg.Scope,
53 req toolspkg.CallRequest,
54) (toolspkg.ToolResult, error) {
55 var input networkChannelCreateInput
56 if err := decodeNativeInput(req, &input); err != nil {
57 return toolspkg.ToolResult{}, err
58 }
59 channel, err := nativeNetworkChannel(req.ToolID, input.Channel)
60 if err != nil {
61 return toolspkg.ToolResult{}, err
62 }
63 purpose := strings.TrimSpace(input.Purpose)
64 if purpose == "" {
65 return toolspkg.ToolResult{}, nativeRequiredInputError(req.ToolID, "purpose")
66 }
67 fanoutPolicy := store.NormalizeNetworkFanoutPolicy(input.FanoutPolicy)
68 coordinatorPeerID := strings.TrimSpace(input.CoordinatorPeerID)
69 if err := store.ValidateNetworkChannelFanoutConfiguration(fanoutPolicy, coordinatorPeerID); err != nil {
70 return toolspkg.ToolResult{}, nativeNetworkInputError(req.ToolID, err)
71 }
72 workspaceID, err := n.nativeNetworkWorkspaceID(ctx, req.ToolID, input.WorkspaceID, scope)
73 if err != nil {
74 return toolspkg.ToolResult{}, err
75 }
76 entry := store.NetworkChannelEntry{
77 Channel: channel,
78 WorkspaceID: workspaceID,
79 Purpose: purpose,
80 FanoutPolicy: fanoutPolicy,
81 CoordinatorPeerID: coordinatorPeerID,
82 CreatedBy: strings.TrimSpace(scope.AgentName),
83 }
84 if err := n.deps.NetworkStore.WriteNetworkChannel(ctx, entry); err != nil {
85 return toolspkg.ToolResult{}, nativeNetworkInputError(req.ToolID, err)
86 }
87 return structuredNetworkResult(
88 nativeNetworkChannelPayload(entry),
89 "channel "+channel,
90 )
91}
92
93func nativeNetworkChannelPayload(entry store.NetworkChannelEntry) map[string]any {
94 return map[string]any{

Callers

nothing calls this directly

Calls 10

decodeNativeInputFunction · 0.85
nativeNetworkChannelFunction · 0.85
nativeRequiredInputErrorFunction · 0.85
nativeNetworkInputErrorFunction · 0.85
structuredNetworkResultFunction · 0.85
WriteNetworkChannelMethod · 0.65

Tested by

no test coverage detected