// User & account tools
import { z } from "zod";
import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import { getClient } from "../client.js";

export function registerUserTools(server: McpServer): void {
  // ─── Get User Info ───
  server.tool(
    "get_user_info",
    "Get the authenticated user's profile information from z-image.ai.",
    {},
    async () => {
      const client = getClient();
      const data = await client.post("/api/user/get-user-info", {});
      return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }] };
    },
  );

  // ─── Get Credits ───
  server.tool(
    "get_credits",
    "Get the current credit balance for the z-image.ai account.",
    {},
    async () => {
      const client = getClient();
      const data = await client.post("/api/user/get-user-credits", {});
      return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }] };
    },
  );

  // ─── Get Config ───
  server.tool(
    "get_config",
    "Get z-image.ai app configuration (available models, features, limits).",
    {},
    async () => {
      const client = getClient();
      const data = await client.post("/api/config/get-configs", {});
      return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }] };
    },
  );
}
