MCPcopy Create free account
hub / github.com/adcontextprotocol/adcp / resolveAgentOwnerUserIds

Function resolveAgentOwnerUserIds

server/src/notifications/compliance.ts:37–53  ·  view source on GitHub ↗

* Find user IDs for the organization that owns an agent URL. * Looks up member_profiles where the agents JSONB contains the URL, * then finds org members to notify.

(agentUrl: string)

Source from the content-addressed store, hash-verified

35 * then finds org members to notify.
36 */
37async function resolveAgentOwnerUserIds(agentUrl: string): Promise<string[]> {
38 try {
39 const result = await query(
40 `SELECT om.workos_user_id
41 FROM member_profiles mp
42 JOIN organization_memberships om
43 ON om.workos_organization_id = mp.workos_organization_id
44 WHERE mp.agents @> $1::jsonb
45 LIMIT 5`,
46 [JSON.stringify([{ url: agentUrl }])],
47 );
48 return result.rows.map((r: any) => r.workos_user_id);
49 } catch (error) {
50 logger.debug({ error, agentUrl }, 'Could not resolve agent owner');
51 return [];
52 }
53}
54
55/**
56 * Extract a short agent name from the URL for display.

Callers 2

notifyComplianceChangeFunction · 0.85
notifyExtendedOutagesFunction · 0.85

Calls 1

queryFunction · 0.85

Tested by

no test coverage detected