import { NextResponse } from 'next/server';

const ANVEVOICE_API_KEY = "anvk_6a217415c671b8e613df1f0b37f72c492a91b625";
const CLEOPATRA_BOT_ID = "022ae3d3-ed11-45a9-b663-f4a6dfa34f77";

export async function GET() {
  try {
    const res = await fetch('https://aaxlcyouksuljvmypyhy.supabase.co/functions/v1/anve-mcp', {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json',
        'x-api-key': ANVEVOICE_API_KEY
      },
      body: JSON.stringify({
        jsonrpc: "2.0",
        method: "tools/call",
        params: {
          name: "get_analytics_overview",
          arguments: { bot_id: CLEOPATRA_BOT_ID }
        },
        id: 4
      })
    });
    
    const data = await res.json();
    return NextResponse.json(data);
  } catch (e) {
    return NextResponse.json({ error: "Failed to fetch" }, { status: 500 });
  }
}
