diff --git a/package-lock.json b/package-lock.json index 2a241f1..2ca2d00 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8,7 +8,7 @@ "name": "adcp-registry", "version": "0.1.0", "dependencies": { - "@adcp/client": "^2.3.2", + "@adcp/client": "^2.5.5", "@modelcontextprotocol/sdk": "^1.0.4", "express": "^4.18.2" }, @@ -45,9 +45,9 @@ } }, "node_modules/@adcp/client": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/@adcp/client/-/client-2.4.1.tgz", - "integrity": "sha512-xZHXLW0tMBlWlnCEcsisWKuvJGwbRhYRGRoYCHbklmBscSEG2FOz7vpTItxKhtgKi9hdmmbjIdh+00r/Pomv0A==", + "version": "2.5.5", + "resolved": "https://registry.npmjs.org/@adcp/client/-/client-2.5.5.tgz", + "integrity": "sha512-ADHD0c9j2EMmvjbrEsUMIlVXH8aF27/xrTCmmckqktULW4vIQpqHimrQjDaqBIYC+Cmn30AnCCuuNp+L01ZQ6g==", "license": "MIT", "dependencies": { "better-sqlite3": "^12.4.1", diff --git a/package.json b/package.json index b7de1a3..14b2547 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "test:coverage": "c8 vitest run" }, "dependencies": { - "@adcp/client": "^2.3.2", + "@adcp/client": "^2.5.5", "@modelcontextprotocol/sdk": "^1.0.4", "express": "^4.18.2" }, diff --git a/server/src/properties.ts b/server/src/properties.ts index 6a5973e..3a5d68c 100644 --- a/server/src/properties.ts +++ b/server/src/properties.ts @@ -1,4 +1,4 @@ -import { createMCPClient, createA2AClient } from "@adcp/client"; +import { AgentClient } from "@adcp/client"; import type { Agent } from "./types.js"; export interface PropertyInfo { @@ -28,25 +28,24 @@ export class PropertiesService { return cached; } - const protocol = agent.protocol || "mcp"; let properties: PropertyInfo[] = []; let error: string | undefined; try { - if (protocol === "a2a") { - const client = createA2AClient(agent.url); - const response = await client.callTool("list_authorized_properties", {}); + // Create agent client with the new API + const agentConfig = { + id: agent.name, + name: agent.name, + agent_uri: agent.url, + protocol: (agent.protocol || "mcp") as "mcp" | "a2a", + }; + const client = new AgentClient(agentConfig); + const result = await client.executeTask("list_authorized_properties", {}); - // Extract properties from A2A response - const artifact = response?.result?.artifacts?.[0]; - if (artifact?.parts?.[0]?.data?.properties) { - properties = artifact.parts[0].data.properties; - } - } else { - const client = createMCPClient(agent.url); - const response = await client.callTool("list_authorized_properties", {}); + if ((result.status === "completed" || result.success) && result.data) { + const response = result.data; - // MCP response can have different formats: + // Handle different response formats: // 1. Array of properties directly if (Array.isArray(response)) { properties = response; @@ -66,6 +65,8 @@ export class PropertiesService { description: response.portfolio_description, })); } + } else if (result.status === "error" || !result.success) { + error = `Agent returned error: ${result.error || "Unknown error"}`; } } catch (toolError: any) { error = `Agent does not support list_authorized_properties: ${toolError.message}`; @@ -73,7 +74,7 @@ export class PropertiesService { const profile: AgentPropertiesProfile = { agent_url: agent.url, - protocol, + protocol: agent.protocol || "mcp", properties, last_fetched: new Date().toISOString(), error,