import { z } from "zod";
import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import type { PulseApiClient } from "../client.js";
import { formatResult } from "../format.js";
export function registerDirectoryTools(server: McpServer, client: PulseApiClient) {
server.tool(
"list_my_agents",
"List all AI agents you've published in the Pulse marketplace",
{},
async () => {
const result = await client.get("/api/v1/marketplace/my-agents");
return { content: [{ type: "text", text: formatResult(result) }] };
}
);
server.tool(
"get_agent_usage",
"Get usage statistics for a specific agent by its slug",
{ slug: z.string().describe("The agent's URL slug") },
async ({ slug }) => {
const result = await client.get(`/api/v1/marketplace/agents/${slug}/usage`);
return { content: [{ type: "text", text: formatResult(result) }] };
}
);
server.tool(
"invoke_agent",
"Invoke an AI agent from the Pulse marketplace with a text input",
{
slug: z.string().describe("The agent's URL slug"),
input: z.string().describe("The text input to send to the agent"),
},
async ({ slug, input }) => {
const result = await client.post(
`/api/v1/marketplace/agents/${slug}/invoke`,
{ input }
);
return { content: [{ type: "text", text: formatResult(result) }] };
}
);
}