/**
 * OwlCoda Native ReadMcpResource Tool
 *
 * Reads a specific resource from a connected MCP server by URI.
 *
 * Upstream parity notes:
 * - Upstream reads resource content via MCP protocol
 * - Our version: delegates to MCP client provider
 */
const defaultProvider = {
    isConnected: () => false,
    readResource: async () => ({ content: '' }),
};
export function createReadMcpResourceTool(provider = defaultProvider) {
    return {
        name: 'ReadMcpResource',
        description: 'Read a resource from a connected MCP server by URI.',
        async execute(input) {
            const { server_name, uri } = input;
            if (!server_name)
                return { output: 'Error: server_name is required.', isError: true };
            if (!uri)
                return { output: 'Error: uri is required.', isError: true };
            if (!provider.isConnected(server_name)) {
                return {
                    output: `MCP server "${server_name}" is not connected.`,
                    isError: true,
                };
            }
            try {
                const result = await provider.readResource(server_name, uri);
                return {
                    output: result.content,
                    isError: false,
                    metadata: { server_name, uri, mimeType: result.mimeType },
                };
            }
            catch (err) {
                const msg = err instanceof Error ? err.message : String(err);
                return { output: `Error reading resource: ${msg}`, isError: true };
            }
        },
    };
}
//# sourceMappingURL=read-mcp-resource.js.map