@apify/actors-mcp-server
Version:
Model Context Protocol Server for Apify
30 lines • 1.04 kB
JavaScript
import Ajv from 'ajv';
import { fixedAjvCompile } from '../tools/utils.js';
import { getMCPServerID, getProxyMCPServerToolName } from './utils.js';
export async function getMCPServerTools(actorID, client,
// Name of the MCP server
serverUrl) {
const res = await client.listTools();
const { tools } = res;
const ajv = new Ajv({ coerceTypes: 'array', strict: false });
const compiledTools = [];
for (const tool of tools) {
const mcpTool = {
actorId: actorID,
serverId: getMCPServerID(serverUrl),
serverUrl,
originToolName: tool.name,
name: getProxyMCPServerToolName(serverUrl, tool.name),
description: tool.description || '',
inputSchema: tool.inputSchema,
ajvValidate: fixedAjvCompile(ajv, tool.inputSchema),
};
const wrap = {
type: 'actor-mcp',
tool: mcpTool,
};
compiledTools.push(wrap);
}
return compiledTools;
}
//# sourceMappingURL=proxy.js.map