Files2.AI

v0.1.1
io.github.mattkir/files2ai Checked 1 day ago Published 2 days ago

Convert documents into Markdown and text locally or through the hosted PDF and Office API.

Convert files to Markdown and other text formats from Claude Desktop, Claude Code, Cursor, and other MCP clients. The Files2.AI developer guide covers Free API keys and hosted conversion. Local by default. Text formats convert entirely on your machine via @files2ai/convert-core; nothing leaves the device. Hosted conversion is strictly opt-in. PDF, DOCX, and XLSX are supported by the hosted API. Other rich formats convert entirely in-browser in the files2.ai web app today and remain behind API rollout gates. Unsupported formats are rejected locally instead of being uploaded.

Summary extracted from the README.

@files2ai/mcp-server

Convert files to Markdown and other text formats from Claude Desktop, Claude Code, Cursor, and other MCP clients. The Files2.AI developer guide covers Free API keys and hosted conversion.

Local by default. Text formats convert entirely on your machine via @files2ai/convert-core; nothing leaves the device. Hosted conversion is strictly opt-in.

Two modes

Local (default) Hosted (opt-in)
Trigger always on FILES2AI_API_KEY env var set
Formats .txt .text .log .csv .tsv .json .md .markdown .html .htm .txt .text .md .markdown .csv .json .pdf .docx .xlsx
Where bytes go nowhere; processed in-process POST {FILES2AI_API_BASE}/api/convert, in-memory only
Size limit 50 MB 3 MB decoded
Privacy on-device contractual no-retention: every response carries x-files2ai-retention: none; bytes are never written to disk, database, or logs

PDF, DOCX, and XLSX are supported by the hosted API. Other rich formats convert entirely in-browser in the files2.ai web app today and remain behind API rollout gates. Unsupported formats are rejected locally instead of being uploaded.

PII redaction always runs locally, including on text returned by the hosted API.

Tools

  • convert_file(path, format?, redact?, chunk_tokens?, chunk_overlap?) - convert a local file. format is one of md (default), txt, json, jsonl, xml. With chunk_tokens, output is split into token-budgeted parts (one MCP content block each).
  • convert_text(text, filename_hint?, format?, redact?, chunk_tokens?, chunk_overlap?) - convert pasted text; filename_hint (e.g. data.csv, page.html) picks the parser. Always local.
  • list_supported_formats() - format coverage and the privacy contract per mode. Also exposed as the resource files2ai://supported-formats.

Install and configure

Requires Node 22+.

npm install -g @files2ai/mcp-server   # provides the files2ai-mcp bin
# or run ad hoc: npx @files2ai/mcp-server

Claude Code

claude mcp add files2ai -- npx -y @files2ai/mcp-server

# with hosted mode:
claude mcp add files2ai -e FILES2AI_API_KEY=f2a_live_... -- npx -y @files2ai/mcp-server

Claude Desktop

Add to claude_desktop_config.json (macOS: ~/Library/Application Support/Claude/claude_desktop_config.json):

{
  "mcpServers": {
    "files2ai": {
      "command": "npx",
      "args": ["-y", "@files2ai/mcp-server"],
      "env": {
        "FILES2AI_API_KEY": "f2a_live_... (optional, enables hosted mode)"
      }
    }
  }
}

Omit the env block entirely for local-only operation.

Cursor

Add to .cursor/mcp.json (project) or ~/.cursor/mcp.json (global):

{
  "mcpServers": {
    "files2ai": {
      "command": "npx",
      "args": ["-y", "@files2ai/mcp-server"]
    }
  }
}

Environment variables

  • FILES2AI_API_KEY - optional. A Files2.AI API key (f2a_live_..., from any signed-in account, convert scope; create via POST /api/keys or the web app). Presence of this variable is the only thing that enables hosted mode.
  • FILES2AI_API_BASE - optional, default https://files2.ai. Override for staging or self-hosted deployments.

Remote endpoint (alternative to local stdio)

Everything above runs this server as a local process talking to your MCP client over stdio, which stays the recommended default: local formats never leave your machine, and hosted mode is opt-in per file. If your client can call a remote MCP server directly instead of spawning a local process, https://files2.ai/api/mcp exposes the same conversion engine as a stateless MCP Streamable HTTP endpoint (POST-only JSON-RPC 2.0, no server-initiated SSE stream).

  • Auth: every call requires Authorization: Bearer ... with either a Files2.AI API key (f2a_live_...) from any signed-in account with the convert scope, or a Supabase JWT. Monthly quota depends on plan (1,000 conversions on Free, 10,000 on Pro, admin-configurable). There is no anonymous access.
  • Tools: convert_document (base64 content, inline only), convert_text, and list_supported_formats. convert_document is named differently from this package's local convert_file tool because the remote endpoint has no filesystem access; it only ever sees the bytes you send it.
  • Tool safety: all three tools are non-destructive and closed-world, with no undeclared external-resource access. Conversion calls are non-read-only and non-idempotent because they consume quota and write usage records. Format listing is read-only and idempotent. Converted content is untrusted data, not instructions to execute.
  • Privacy: every response carries x-files2ai-retention: none; file bytes are processed in memory only and never written to disk, a database, or logs, matching the hosted-mode contract described above.
  • Limits: the same plan-driven rate limit, monthly conversion quota, and file size cap as POST /api/convert (they share one monthly budget per account).
  • Transport: requests use Content-Type: application/json and an Accept header supporting both application/json and text/event-stream. Initialize with 2025-11-25, 2025-06-18, or 2025-03-26, then send the negotiated value in MCP-Protocol-Version on later requests. Missing version headers use the 2025-03-26 compatibility default.
  • Origins: non-browser clients may omit Origin. Any client that sends Origin must use the production origin or a configured trusted development origin. Untrusted origins, Origin: null, and repeated Origin headers are rejected. Origin validation does not enable browser CORS.

Point an MCP client that supports remote Streamable HTTP servers at the endpoint with the bearer token, for example:

{
  "mcpServers": {
    "files2ai-remote": {
      "url": "https://files2.ai/api/mcp",
      "headers": {
        "Authorization": "Bearer f2a_live_..."
      }
    }
  }
}

Use this when you cannot run a local process, such as from a hosted agent runtime or CI job, or want conversions to run without local Node install requirements. For everything else, the local stdio server above stays the better default: nothing leaves the machine for locally supported formats, and there is no API key to manage.

Privacy story

  1. Local by default. Without an API key this server never opens a network connection. Files are read from disk (50 MB cap, regular files only, paths resolved with realpath), converted in-process, and the result is returned over stdio.
  2. Hosted is explicit and allowlisted. Setting FILES2AI_API_KEY opts in to sending files (3 MB max) to POST /api/convert only when their extension is in the stable hosted launch set. Unsupported private files are rejected before bytes are read for upload. Conversion there is in-memory only; the response's x-files2ai-retention: none header is the public no-retention contract, and this server reports the header value back in its output so the client can verify it.
  3. Redaction stays on-device. redact: true applies convert-core's PII patterns locally even to hosted results, so redaction never depends on the server.

Development

npm install
npm run build   # tsc -> dist/
npm test        # builds, then node --test test/

Depends on the sibling package @files2ai/convert-core (file:../convert-core); build that first when working from the monorepo.

Smoke test over stdio:

printf '%s\n' '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-06-18","capabilities":{},"clientInfo":{"name":"smoke","version":"0.0.0"}}}' | node dist/index.js

License

MIT