MCPcopy Create free account
hub / github.com/Mnexa-AI/e2a / registerAgents

Method registerAgents

internal/httpapi/operations.go:99–139  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

97}
98
99func (s *Server) registerAgents() {
100 huma.Register(s.API, huma.Operation{
101 OperationID: "listAgents",
102 Method: http.MethodGet,
103 Path: "/v1/agents",
104 Summary: "List agents",
105 Description: "List the agents owned by the authenticated account.",
106 Tags: []string{"agents"},
107 Security: []map[string][]string{{"bearer": {}}},
108 }, func(ctx context.Context, _ *struct{}) (*listAgentsOutput, error) {
109 user, err := s.requireAccountUser(ctx)
110 if err != nil {
111 return nil, err
112 }
113 agents, err := s.deps.ListAgents(ctx, user.ID)
114 if err != nil {
115 return nil, NewError(http.StatusInternalServerError, "internal_error", "failed to list agents")
116 }
117 items := make([]AgentView, 0, len(agents))
118 for i := range agents {
119 items = append(items, agentViewFromIdentity(&agents[i]))
120 }
121 return &listAgentsOutput{Body: NewPage(items, "")}, nil
122 })
123
124 huma.Register(s.API, huma.Operation{
125 OperationID: "getAgent",
126 Method: http.MethodGet,
127 Path: "/v1/agents/{email}",
128 Summary: "Get an agent",
129 Description: "Fetch a single agent the authenticated account owns, by full email address.",
130 Tags: []string{"agents"},
131 Security: []map[string][]string{{"bearer": {}}},
132 }, func(ctx context.Context, in *AddressParam) (*agentOutput, error) {
133 ag, err := s.resolveOwnedAgent(ctx, in.Address)
134 if err != nil {
135 return nil, err
136 }
137 return &agentOutput{Body: agentViewFromIdentity(ag)}, nil
138 })
139}
140
141// resolveOwnedAgent authenticates the caller, loads the agent by address,
142// and verifies ownership — the shared front half of every per-agent

Callers 1

registerOperationsMethod · 0.95

Calls 7

requireAccountUserMethod · 0.95
resolveOwnedAgentMethod · 0.95
NewErrorFunction · 0.85
makeFunction · 0.85
agentViewFromIdentityFunction · 0.85
NewPageFunction · 0.85
RegisterMethod · 0.80

Tested by

no test coverage detected