/**
 * OwlCoda Native ListMcpResources Tool
 *
 * Lists resources available from a connected MCP server.
 *
 * Upstream parity notes:
 * - Upstream queries MCP server resources endpoint
 * - Our version: delegates to MCP client provider
 */
const defaultProvider = {
    isConnected: () => false,
    listResources: async () => [],
};
export function createListMcpResourcesTool(provider = defaultProvider) {
    return {
        name: 'ListMcpResources',
        description: 'List resources available from a connected MCP server.',
        async execute(input) {
            const { server_name } = input;
            if (!server_name)
                return { output: 'Error: server_name is required.', isError: true };
            if (!provider.isConnected(server_name)) {
                return {
                    output: `MCP server "${server_name}" is not connected.`,
                    isError: true,
                };
            }
            try {
                const resources = await provider.listResources(server_name);
                if (resources.length === 0) {
                    return {
                        output: `No resources found on server "${server_name}".`,
                        isError: false,
                        metadata: { server_name, resources: [] },
                    };
                }
                const lines = resources.map(r => `  ${r.uri} — ${r.name}${r.description ? ` (${r.description})` : ''}`);
                return {
                    output: `Resources on "${server_name}" (${resources.length}):\n${lines.join('\n')}`,
                    isError: false,
                    metadata: { server_name, resources },
                };
            }
            catch (err) {
                const msg = err instanceof Error ? err.message : String(err);
                return { output: `Error listing resources: ${msg}`, isError: true };
            }
        },
    };
}
//# sourceMappingURL=list-mcp-resources.js.map