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

Method fetchStats

server/src/health.ts:127–157  ·  view source on GitHub ↗
(agent: Agent)

Source from the content-addressed store, hash-verified

125 }
126
127 private async fetchStats(agent: Agent): Promise<AgentStats> {
128 const stats: AgentStats = {};
129
130 try {
131 if (agent.type === "buying") {
132 // Use PropertyIndex if available (populated by crawler)
133 const index = getPropertyIndex();
134 const auth = index.getAgentAuthorizations(agent.url);
135
136 if (auth && auth.properties.length > 0) {
137 stats.property_count = auth.properties.length;
138 stats.publishers = auth.publisher_domains;
139 stats.publisher_count = auth.publisher_domains.length;
140 }
141 } else if (agent.type === "creative") {
142 // For creative agents, get format count from FormatsService
143 try {
144 const formatsProfile = await this.formatsService.getFormatsForAgent(agent);
145 if (formatsProfile.formats && formatsProfile.formats.length > 0) {
146 stats.creative_formats = formatsProfile.formats.length;
147 }
148 } catch {
149 // Creative format listing failed
150 }
151 }
152 } catch {
153 // Stats are optional, failure is ok
154 }
155
156 return stats;
157 }
158
159 clearCache(): void {
160 this.healthCache.clear();

Callers 1

getStatsMethod · 0.95

Calls 1

getFormatsForAgentMethod · 0.80

Tested by

no test coverage detected