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

Method getAgent

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

* Get agent by identifier (URL or legacy slug format like "type/name") * Provides backward compatibility with old registry-based lookups

(identifier: string)

Source from the content-addressed store, hash-verified

122 * Provides backward compatibility with old registry-based lookups
123 */
124 async getAgent(identifier: string): Promise<Agent | undefined> {
125 // If it looks like a URL, search by URL
126 if (identifier.startsWith("http://") || identifier.startsWith("https://")) {
127 return this.getAgentByUrl(identifier);
128 }
129
130 // Otherwise treat as legacy slug format "type/name" or just name
131 // Search all agents and match by slug-like identifier
132 const agents = await this.listAgents();
133
134 for (const agent of agents) {
135 // Match by type/slugified-name pattern
136 const slugName = agent.name.toLowerCase().replace(/\s+/g, "-");
137 const agentSlug = `${agent.type}/${slugName}`;
138
139 if (agentSlug === identifier || slugName === identifier) {
140 return agent;
141 }
142 }
143
144 return undefined;
145 }
146
147 /**
148 * Get all agents as a map keyed by URL

Callers 1

setupRoutesMethod · 0.80

Calls 2

getAgentByUrlMethod · 0.95
listAgentsMethod · 0.95

Tested by

no test coverage detected