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

Method crawlAllAgents

server/src/crawler.ts:54–130  ·  view source on GitHub ↗
(agents: Agent[])

Source from the content-addressed store, hash-verified

52 }
53
54 async crawlAllAgents(agents: Agent[]): Promise<CrawlResult> {
55 if (this.crawling) {
56 log.debug('Crawl already in progress, skipping');
57 return this.lastResult || this.emptyResult();
58 }
59
60 this.crawling = true;
61
62 // Filter out agents whose owners have paused monitoring
63 const pausedUrls = await this.getPausedAgentUrls();
64 const activeAgents = agents.filter(a => !pausedUrls.has(a.url));
65 if (activeAgents.length < agents.length) {
66 log.info({ paused: agents.length - activeAgents.length, active: activeAgents.length }, 'Skipping paused agents');
67 }
68 log.info({ agentCount: activeAgents.length }, 'Starting crawl');
69
70 // Convert our Agent type to AgentInfo for the crawler
71 const agentInfos: AgentInfo[] = activeAgents.map((agent) => ({
72 agent_url: agent.url,
73 protocol: agent.protocol || "mcp", // Use agent's protocol, default to MCP
74 publisher_domain: this.extractDomain(agent.url),
75 }));
76
77 try {
78 const result = await this.crawler.crawlAgents(agentInfos);
79
80 this.lastCrawl = new Date();
81 this.lastResult = result;
82 this.crawling = false;
83
84 log.info({
85 totalProperties: result.totalProperties,
86 successfulAgents: result.successfulAgents,
87 totalAgents: agents.length,
88 publisherDomains: result.totalPublisherDomains,
89 }, 'Crawl complete');
90
91 if (result.failedAgents > 0) {
92 log.warn({ failedAgents: result.failedAgents }, 'Some agents failed (no adagents.json)');
93 }
94
95 if (result.errors.length > 0) {
96 const errorsByDomain: Record<string, string[]> = {};
97 for (const err of result.errors) {
98 (errorsByDomain[err.agent_url] ??= []).push(err.error);
99 }
100 log.warn({ errorsByDomain }, 'Crawl errors');
101 }
102
103 if (result.warnings && result.warnings.length > 0) {
104 log.warn({ warnings: result.warnings }, 'Crawl warnings');
105 }
106
107 // Snapshot pre-crawl state for diffing
108 const preCrawlAgents = await this.snapshotAgentState();
109
110 // Populate federated index from PropertyIndex and adagents.json files
111 const crawledDomains = await this.populateFederatedIndex(agents);

Callers 2

startPeriodicCrawlMethod · 0.95
setupRoutesMethod · 0.80

Calls 11

emptyResultMethod · 0.95
getPausedAgentUrlsMethod · 0.95
extractDomainMethod · 0.95
snapshotAgentStateMethod · 0.95
produceEventsFromDiffMethod · 0.95
scanBrandsForDomainsMethod · 0.95
hasMethod · 0.80
warnMethod · 0.80

Tested by

no test coverage detected