Connect an agent

MCP server setup

Connect imagemcpserver to any Model Context Protocol client — Claude, Cursor, or your own — and all eleven image tools appear in the agent’s tool list. Remote endpoint or local process, both shown here.

Remote endpoint (recommended)

The hosted server lives at https://mcp.imagemcpserver.com/mcp. Most clients reach it through mcp-remote, which bridges a stdio client to a remote MCP endpoint — so this config works anywhere a mcpServers block is accepted.

MCP client config
{
  "mcpServers": {
    "imagemcp": {
      "command": "npx",
      "args": [
        "-y",
        "mcp-remote",
        "https://mcp.imagemcpserver.com/mcp",
        "--header",
        "x-api-key:sk-img-gen-your_key_here"
      ]
    }
  }
}
  1. 1

    Paste the block into your client config

    Merge it with any mcpServers entries you already have — the key name imagemcp is what the agent will see.

  2. 2

    Swap in your API key

    Replace sk-img-gen-your_key_here with a key from the dashboard. See authentication for the alternatives to the x-api-key header.

  3. 3

    Restart the client

    Tool lists are read at startup, so a running client will not see the server until it restarts.

Running it locally

Prefer the server on your own machine — to point it at a self-hosted backend, or to keep the key off a bridge process? Run it over stdio and hand the key in through the environment.

MCP client config (local process)
{
  "mcpServers": {
    "imagemcp": {
      "command": "node",
      "args": ["/absolute/path/to/imagemcp-mcp-server/index.js"],
      "env": {
        "IMAGEMCP_API_KEY": "sk-img-gen-your_key_here",
        "IMAGEMCP_API_URL": "https://api.imagemcpserver.com"
      }
    }
  }
}

IMAGEMCP_API_URL is optional

It defaults to https://api.imagemcpserver.com. Set it only when you are pointing the MCP server at a different backend.

Self-hosted HTTP transport

The same package also serves streamable HTTP, which is what browser-based clients and Custom GPT actions need. Start it on a port and it exposes three paths:

terminal
cd imagemcp-mcp-server
npm install
PORT=3001 npm start
  • POST /mcp — the MCP endpoint itself (streamable HTTP).
  • GET /openapi.json — an OpenAPI spec, for ChatGPT Actions and other spec-driven clients.
  • GET /health — liveness check.

Over HTTP the key can arrive four ways: an x-api-key header, an Authorization header, an ?apikey= query parameter, or the IMAGEMCP_API_KEY environment variable on the process.

terminal
curl "http://localhost:3001/health"

# Point a browser-based MCP client at:
# http://localhost:3001/mcp?apikey=sk-img-gen-your_key_here

Verifying the connection

The cheapest way to confirm everything is wired up is to ask the agent for your credit balance — get_user_info costs nothing and fails loudly if the key is wrong.

verify
Use the imagemcp tools to check my credit balance,
then generate a 16:9 image of a paper-craft fox in tall grass.

Tools exposed

Troubleshooting

  • Tools do not appear — the client did not restart, or the JSON has a trailing comma. Most clients silently ignore a config file they cannot parse.
  • 401 Unauthorized on every call — the key never reached the server. Check the header is x-api-key:<key> with no space after the colon.
  • Tools appear but every call fails — the account is out of credits. Ask the agent to run get_user_info; it is free and returns the balance.
  • npx cannot find mcp-remote — run it once by hand to warm the cache, then restart the client.

FAQ

Which MCP clients does this work with?

Any client that speaks the Model Context Protocol. The remote endpoint is a standard streamable-HTTP MCP server and the local process speaks stdio, which between them cover the transports MCP clients use today.

Do I need to run anything locally?

No. Pointing your client at the hosted endpoint through mcp-remote is enough. Running the server yourself is only useful when you want it on your own machine or against a self-hosted backend.

How does the server know which account to bill?

From your API key, passed as an x-api-key header, an Authorization header, an ?apikey= query parameter, or the IMAGEMCP_API_KEY environment variable when you run the process locally.

How many tools does the server expose?

Eleven: get_user_info, list_models, generate_image, generate_transparent_image, edit_image, remove_background, upscale_image, text_to_svg, compress_image, convert_format, multicall.