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

Method getAgentByUrl

server/src/agent-service.ts:92–118  ·  view source on GitHub ↗

* Get agent by URL * Checks registered agents first, then discovered agents

(url: string, options: { viewerHasApiAccess?: boolean } = {})

Source from the content-addressed store, hash-verified

90 * Checks registered agents first, then discovered agents
91 */
92 async getAgentByUrl(url: string, options: { viewerHasApiAccess?: boolean } = {}): Promise<Agent | undefined> {
93 const viewerHasApiAccess = options.viewerHasApiAccess ?? false;
94 // Mirror listAgents: API-access viewers can look up members_only agents
95 // on private profiles; unauth viewers stay scoped to public profiles.
96 const profiles = viewerHasApiAccess
97 ? await this.memberDb.listProfiles()
98 : await this.memberDb.listProfiles({ is_public: true });
99
100 for (const profile of profiles) {
101 for (const agentConfig of profile.agents || []) {
102 if (agentConfig.url !== url) continue;
103 if (!this.isVisibleToViewer(agentConfig.visibility, viewerHasApiAccess)) continue;
104 if (agentConfig.visibility === 'public' && !profile.is_public && !viewerHasApiAccess) continue;
105 return this.configToAgent(agentConfig, profile);
106 }
107 }
108
109 // Check discovered agents
110 const discoveredAgents = await this.federatedDb.getAllDiscoveredAgents();
111 for (const discovered of discoveredAgents) {
112 if (discovered.agent_url === url) {
113 return this.discoveredToAgent(discovered);
114 }
115 }
116
117 return undefined;
118 }
119
120 /**
121 * Get agent by identifier (URL or legacy slug format like "type/name")

Callers 3

getAgentMethod · 0.95
handleToolCallMethod · 0.80

Calls 5

isVisibleToViewerMethod · 0.95
configToAgentMethod · 0.95
discoveredToAgentMethod · 0.95
listProfilesMethod · 0.80

Tested by

no test coverage detected