Genace

AI generation API Cursor: configure a custom MCP image tool

Cursor can launch a local MCP wrapper that turns two tools into Genace HTTP requests. Use the wrapper to keep a paid creation action distinct from a status check. The setup below uses Cursor’s project MCP configuration and environment interpolation; it does not require or imply a dedicated Genace extension from a marketplace.

1. Put the wrapper in a known project location

Follow the MCP server implementation and save the reviewed Python server as tools/genace_mcp.py. Create a virtual environment and install the dependencies used by that implementation. Set GENACE_API_KEY in the environment available to Cursor before opening the editor.

The interpreter path must point to that environment. The following example uses a POSIX virtual environment; Windows users should change the command to their environment’s Scripts/python.exe path. Do not rely on whichever python happens to appear first in a GUI application’s PATH.

2. Configure the project server

Create or merge this entry into .cursor/mcp.json. Preserve other server entries in an existing file. Cursor documents ${workspaceFolder} and ${env:NAME} interpolation, which keeps the real key outside the committed JSON.

{
  "mcpServers": {
    "genace-local": {
      "command": "${workspaceFolder}/.venv/bin/python",
      "args": ["${workspaceFolder}/tools/genace_mcp.py"],
      "env": {
        "GENACE_API_KEY": "${env:GENACE_API_KEY}"
      }
    }
  }
}

This configuration grants the local server access to the environment value; it does not create an API key. If the key is missing, fix the launching environment and restart the relevant editor process. An environment variable added to an unrelated terminal may not reach an already-running GUI application.

3. Verify the boundary before generating

Use Cursor’s MCP controls to confirm the server starts and exposes the expected submission and inspection tools. Tool discovery should not call the generation endpoint. Read the tool descriptions and verify the model cannot supply a credential, arbitrary API base URL, or unrestricted model ID as an argument.

Then make one intentional generation request with a specific prompt. The wrapper’s submission operation should return job_id and state immediately after acceptance. Store that identifier outside transient chat context when the result matters to your project. A subsequent status request should inspect the same job, not create a replacement because it has not finished yet.

4. Integrate results into the project deliberately

A returned output URL is a remote asset reference. If you want a local project image, use a separate download step after validating that the job succeeded and that the output type is image. Follow your project’s policy for filenames, image review, and long-term storage. Do not assume remote URLs have a documented permanent lifetime.

Keep failed and canceled outcomes visible. They are terminal states, while queued and running remain pending. The status endpoint may return HTTP 200 with a failed state and null outputs, so a tool must preserve those fields rather than fabricate a usable file path.

Common mistakes and verification

Do not paste the raw API key into .cursor/mcp.json, chat instructions, or the server source. Do not configure the REST generation URL as though it were an MCP server URL. Avoid enabling automatic creation retries for uncertain POST results, because the REST route exposes no request idempotency contract.

Verify the JSON parses, the selected interpreter can import the SDK, and the key is absent from exported configuration. Exercise pending and failed fixtures without generating assets. Finally, confirm stopping Cursor leaves the stored job reference available for observation from another client.

See Cursor’s MCP documentation for configuration behavior and server-side key handling for the credential boundary behind this setup.

Continue with agents and automation

Models covered on this page

Where these facts come from

  • Editorial keyword hypothesis; search volume not measured
  • https://cursor.com/docs/mcp
  • codebase: src/app/api/v1/images/generations/route.ts
  • codebase: src/ai/jobs/http.ts