StyleOCR
Blog

Connect StyleOCR MCP from Claude, Codex, and Cursor

Enable the local StyleOCR MCP endpoint and wire it into Claude Code, OpenAI Codex CLI, and Cursor Agent using each product’s supported HTTP MCP patterns.

StyleOCR can expose a local Model Context Protocol (MCP) server so assistants on your machine can trigger OCR and related workflows without uploading documents to a third-party cloud—the traffic stays on localhost between the assistant client and the StyleOCR app. Turn it on under Settings → MCP server, note the URL (and any API key or token the UI shows), and restart after changing the listening port. Details on behavior and limits are in the User guide and Security architecture.

This article is a practical wiring guide for three common clients. Replace placeholders such as http://127.0.0.1:PORT/PATH with the exact value copied from StyleOCR.

Security checklist

  • Loopback only — The server is intended for 127.0.0.1 / localhost. Do not port-forward or tunnel it to the public internet unless you fully understand the risk.
  • Treat URL and keys as secrets — Anyone who can reach the endpoint from your user session may be able to invoke tools. On shared machines, disable MCP when idle and avoid pasting the URL into tickets or screenshots.
  • Prefer environment variables for tokens—never commit real URLs, bearer tokens, or API keys to git.

1. Claude Code (CLI)

Claude Code is documented in Anthropic’s Claude Code MCP guide (mirrored at code.claude.com).

Where configuration lives

ScopeStorageTypical use
Project.mcp.json at the repository rootShare with teammates (review before commit).
User~/.claude.jsonPersonal servers on all projects.
Local (per Anthropic docs terminology)Also ~/.claude.json with local-scoped entriesSame machine, not checked in.

HTTP servers use type http (or streamable-http as an alias), a url, and optional headers for static auth.

Quick CLI add (HTTP)

claude mcp add --transport http styleocr http://127.0.0.1:PORT/PATH

If StyleOCR expects a bearer token or API key header, add headers before the server name (see the official examples with --header).

Equivalent JSON (mcpServers)

You can maintain the same server in .mcp.json or via the mcpServers block Claude Code merges into ~/.claude.json. Example shape:

{
  "mcpServers": {
    "styleocr": {
      "type": "http",
      "url": "http://127.0.0.1:PORT/PATH",
      "headers": {
        "Authorization": "Bearer ${STYLEOCR_MCP_TOKEN}"
      }
    }
  }
}

Set STYLEOCR_MCP_TOKEN in your shell profile or use the headersHelper pattern from the same docs if you need short-lived tokens.


2. OpenAI Codex (CLI and IDE extension)

OpenAI documents Codex MCP in Model Context Protocol on the OpenAI developer site.

Where configuration lives

  • User: ~/.codex/config.toml (default).
  • Project (trusted projects): .codex/config.toml.

The CLI and Codex IDE extension share this file. You can run codex mcp --help for subcommands or edit TOML directly.

Streamable HTTP server (TOML)

Each server is a [mcp_servers.<name>] table. For a URL-backed server, set url and optional auth via bearer_token_env_var, http_headers, or env_http_headers (see the official tables on the page above).

[mcp_servers.styleocr]
url = "http://127.0.0.1:PORT/PATH"
bearer_token_env_var = "STYLEOCR_MCP_TOKEN"

Export STYLEOCR_MCP_TOKEN in your environment to match whatever StyleOCR’s settings UI expects (for example a bearer secret shown next to the MCP URL). If the app uses a custom header instead of Authorization, use the http_headers / env_http_headers fields described in OpenAI’s documentation rather than bearer_token_env_var.


3. Cursor (editor + Cursor CLI agent)

Cursor documents MCP in Model Context Protocol (MCP). The Cursor CLI section MCP states that CLI agent uses the same MCP configuration as the editor.

Configuration files (official)

ScopePath
Project.cursor/mcp.json under the project root
Global~/.cursor/mcp.json

Remote / HTTP-style servers use a top-level url entry inside mcpServers, with optional headers for API keys (Cursor’s docs show headers for remote servers).

{
  "mcpServers": {
    "styleocr": {
      "url": "http://127.0.0.1:PORT/PATH",
      "headers": {
        "Authorization": "Bearer ${env:STYLEOCR_MCP_TOKEN}"
      }
    }
  }
}

Cursor supports config interpolation such as ${env:NAME} in url and headers—see the same MCP guide.

Using MCP from the CLI agent

After configuration, use the documented commands, for example:

agent mcp list
agent mcp list-tools styleocr

When running non-interactive prompts, you can pass --approve-mcps if you accept the security trade-offs described in MCP (CLI).


Sanity checks

  1. StyleOCR is running and the MCP toggle shows listening.
  2. The URL uses 127.0.0.1 or localhost exactly as shown—some clients are picky about IPv4 vs IPv6.
  3. Headers or bearer variables match what the StyleOCR settings screen documents for your build.
  4. After edits, restart the assistant client (or reload MCP) so new servers register.

If a client cannot connect, check its MCP logs or verbose mode first, then confirm no VPN or proxy is rewriting localhost traffic.


References