Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down
31 changes: 16 additions & 15 deletions server/src/properties.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createMCPClient, createA2AClient } from "@adcp/client";
import { AgentClient } from "@adcp/client";
import type { Agent } from "./types.js";

export interface PropertyInfo {
Expand Down Expand Up @@ -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;
Expand All @@ -66,14 +65,16 @@ 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}`;
}

const profile: AgentPropertiesProfile = {
agent_url: agent.url,
protocol,
protocol: agent.protocol || "mcp",
properties,
last_fetched: new Date().toISOString(),
error,
Expand Down