import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
import { z } from "zod";
import QRCode from "qrcode";
// ---------------------------------------------------------------------------
const server = new McpServer({
    name: "maxy-documents",
    version: "0.1.0",
});
server.tool("qr-generate", "Generate a QR code from text or a URL. Returns the QR code as a data URI (PNG) or saves to a file path.", {
    data: z.string().describe("The text or URL to encode in the QR code"),
    outputPath: z
        .string()
        .optional()
        .describe("File path to save the PNG. If omitted, returns a data URI."),
    width: z.number().optional().describe("Width in pixels (default 300)"),
}, async ({ data, outputPath, width }) => {
    try {
        const options = { width: width ?? 300, margin: 2 };
        if (outputPath) {
            await QRCode.toFile(outputPath, data, options);
            return {
                content: [
                    {
                        type: "text",
                        text: `QR code saved to ${outputPath}`,
                    },
                ],
            };
        }
        const dataUri = await QRCode.toDataURL(data, options);
        return {
            content: [
                {
                    type: "text",
                    text: `QR code generated for: ${data}`,
                },
                {
                    type: "image",
                    data: dataUri.replace(/^data:image\/png;base64,/, ""),
                    mimeType: "image/png",
                },
            ],
        };
    }
    catch (err) {
        return {
            content: [
                {
                    type: "text",
                    text: `QR generation failed: ${err instanceof Error ? err.message : String(err)}`,
                },
            ],
            isError: true,
        };
    }
});
server.tool("document-ingest", "DEPRECATED — use memory-ingest-extract + memory-ingest (in the memory MCP server) instead. " +
    "This tool has been replaced by a hierarchical ingestion pipeline with LLM-generated summaries.", {
    attachmentId: z.string().uuid().describe("UUID of the attachment"),
    accountId: z.string().describe("Account this attachment belongs to"),
    storagePath: z.string().describe("Absolute path to the stored file on disk"),
    filename: z.string().describe("Original filename as uploaded"),
    mimeType: z.string().describe("MIME type of the file"),
    sizeBytes: z.number().int().describe("File size in bytes"),
}, async () => ({
    content: [{
            type: "text",
            text: "document-ingest is deprecated. Use memory-ingest-extract to extract text, then memory-ingest to store the document hierarchy with LLM-generated summaries. Both tools are in the memory MCP server.",
        }],
    isError: true,
}));
server.tool("document-create-pdf", "Generate a PDF document from markdown or HTML content", {
    content: z.string(),
    format: z.enum(["markdown", "html"]).optional(),
    title: z.string().optional(),
}, async () => ({
    content: [
        {
            type: "text",
            text: "PDF generation is not available in Phase 0. This capability will be added in Phase 1.",
        },
    ],
}));
server.tool("document-list", "List documents for an account", {
    accountId: z.string().optional(),
    type: z.string().optional(),
}, async () => ({
    content: [
        {
            type: "text",
            text: "Document management is not available in Phase 0. This capability will be added in Phase 1.",
        },
    ],
}));
const transport = new StdioServerTransport();
await server.connect(transport);
//# sourceMappingURL=index.js.map