MCPcopy
hub / github.com/google/ax / RegisterRemote

Method RegisterRemote

internal/controller/registry.go:81–100  ·  view source on GitHub ↗

RegisterRemote registers a remote agent by creating a remote agent client. The protocol field determines what kind of remote agent to register (matched case-insensitively): - "axp" (default): AX's proto.AgentService. - "a2a": A2A protocol.

(ctx context.Context, cfg config.RemoteAgentConfig)

Source from the content-addressed store, hash-verified

79// - "axp" (default): AX's proto.AgentService.
80// - "a2a": A2A protocol.
81func (r *Registry) RegisterRemote(ctx context.Context, cfg config.RemoteAgentConfig) error {
82 r.mu.Lock()
83 defer r.mu.Unlock()
84
85 if err := validateID(cfg.ID); err != nil {
86 return err
87 }
88 if _, ok := r.agents[cfg.ID]; ok {
89 return fmt.Errorf("agent %s already registered", cfg.ID)
90 }
91
92 switch strings.ToLower(cfg.Protocol) {
93 case "", "axp":
94 return r.registerRemote(cfg)
95 case "a2a":
96 return r.registerA2A(ctx, cfg)
97 default:
98 return fmt.Errorf("remote agent %s: invalid protocol %q (want \"axp\" or \"a2a\")", cfg.ID, cfg.Protocol)
99 }
100}
101
102func (r *Registry) registerRemote(cfg config.RemoteAgentConfig) error {
103 remoteAgent, err := agent.NewRemoteAgent(agent.RemoteAgentConfig{

Callers 2

NewControllerFromConfigFunction · 0.80

Calls 3

registerRemoteMethod · 0.95
registerA2AMethod · 0.95
validateIDFunction · 0.85

Tested by 1