DEV Community

Richard Nemeth for AnswerLine

Posted on Originally published at answerline.dev

Ask ChatGPT from inside Cursor with one MCP line

You can ask ChatGPT and Gemini, and search Google News, from inside Cursor or Claude Code by adding one remote MCP server: https://mcp.answerline.dev/mcp, authenticated with your API key as a bearer token. Each engine then appears as a tool the editor's agent can call mid-session, and every call returns the same structured JSON as the REST API (answer text, sources[] and citation pills).

What the MCP server is

The Model Context Protocol (MCP) server is a hosted endpoint that exposes this API's monitor routes as tools an MCP client can list and call. It speaks Streamable HTTP over POST, and supports protocol revisions 2024-11-05 through 2025-11-25 as well as 2026-07-28 (MCP guide).

There are two endpoint forms:

Endpoint Auth Use when
https://mcp.answerline.dev/mcp Authorization: Bearer sk_... header The client can send headers. Cursor and Claude Code both can.
https://mcp.answerline.dev/<API_KEY>/mcp Key in the path The client only accepts a URL. The URL itself is then a secret.

Prefer the header form whenever the client supports it. A URL with a key in it ends up in logs, screenshots and shell history more easily than a header value.

Claude Code setup

  1. Create an API key in the dashboard and export it in the shell you start Claude Code from: export API_KEY=sk_....
  2. Add the server:
claude mcp add --transport http answerline \
  https://mcp.answerline.dev/mcp \
  --header "Authorization: Bearer $API_KEY"
Enter fullscreen mode Exit fullscreen mode
  1. Start a session and ask for something that needs a tool, for example "check my AnswerLine credits". The agent should call credits.

Two details from the Claude Code MCP documentation (code.claude.com/docs/en/mcp, checked 2026-09-17):

  • Scope decides where the key is stored. The default local scope and the user scope write to ~/.claude.json, which is private to you. The projectscope writes .mcp.json in the project root, which is meant to be shared through version control. Because your shell expands $API_KEY before claude mcp add runs, the literal key is what gets stored. Never use --scope project with a literal key.
  • Shared configs can reference variables. .mcp.json supports ${VAR} expansion in url and headers, so a committed project file can hold "Authorization": "Bearer ${ANSWERLINE_API_KEY}" while each developer sets the variable locally. The same page documents MCP_TOOL_TIMEOUT for the tool execution timeout, which matters for long engine calls.

A project-scoped file that is safe to commit:

{
  "mcpServers": {
    "answerline": {
      "type": "http",
      "url": "https://mcp.answerline.dev/mcp",
      "headers": { "Authorization": "Bearer ${ANSWERLINE_API_KEY}" }
    }
  }
}
Enter fullscreen mode Exit fullscreen mode

Cursor setup

Cursor reads MCP servers from .cursor/mcp.json in the project root or ~/.cursor/mcp.json for all projects, supports stdio, SSE and Streamable HTTP transports, and takes remote servers as a url with optional headers (cursor.com/docs/context/mcp, checked 2026-09-17).

  1. Pick the file. Use ~/.cursor/mcp.json if you want the tools everywhere; use .cursor/mcp.json if the project needs them and your teammates should get the entry too.
  2. Add the server, referencing an environment variable for the key. Cursor resolves ${env:NAME} in url and headers (same source):
{
  "mcpServers": {
    "answerline": {
      "url": "https://mcp.answerline.dev/mcp",
      "headers": { "Authorization": "Bearer ${env:ANSWERLINE_API_KEY}" }
    }
  }
}
Enter fullscreen mode Exit fullscreen mode
  1. Set ANSWERLINE_API_KEY in the environment Cursor is started from; a variable exported in a terminal opened later is not visible to an editor that is already running.
  2. Confirm the server is enabled in Cursor's MCP settings and that the tools are listed. If the server shows an error, Cursor's Output panel has an "MCP Logs" channel with connection and authentication errors (same source).
  3. Expect an approval prompt. Cursor asks for approval before running MCP tools by default (same source). Leave that on while you learn what the calls cost; each approved engine call spends credits.

Other editors and agents configured with an mcpServers JSON file that supports remote servers take the sameurlandheaders` shape; check your client's own documentation for variable interpolation before relying on it.

Testing the key and endpoint

If the editor shows no tools, test the endpoint directly. First the REST API, which isolates key problems:

bash
curl -s https://api.answerline.dev/v1/credits \
-H "Authorization: Bearer $API_KEY"

A valid key returns remaining, perCycle and cycleResetsAt. A 401 with MISSING_API_KEY, INVALID_API_KEY_FORMAT or INVALID_OR_EXPIRED_API_KEY means the key, not the MCP setup, is the problem (authentication).

Then ask the MCP server for its tool list with a plain JSON-RPC request:

bash
curl -s https://mcp.answerline.dev/mcp \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d '{"jsonrpc":"2.0","id":1,"method":"tools/list"}'

The response lists the tools with their input schemas. GET and DELETE on the endpoint answer 405, so a browser visit to the URL tells you nothing; use POST.

The tools and what each call costs

Tool names follow the route: /v1/monitor/google/news becomes google_news. Each engine tool's input schema is that endpoint's request body, so the agent passes prompt and country to chatgpt, or query and country to google_news, plus any options the endpoint accepts.

Every engine tool call is a synchronous API call. It costs the engine's base price plus the 2-credit synchronous surcharge:

Tool Route Base Cost per tool call Common add-ons
chatgpt /v1/monitor/chatgpt 5 5 + 2 = 7 +2 once for include.rawResponse or shopping
gemini /v1/monitor/gemini 4 4 + 2 = 6 none
copilot /v1/monitor/copilot 5 5 + 2 = 7 none
aimode /v1/monitor/aimode 4 4 + 2 = 6 +1 per expanded product cluster, up to 6
google /v1/monitor/google 3 3 + 2 = 5 +2 per extra page; +2 once for the AI Overview
google_news /v1/monitor/google/news 2 2 + 2 = 4 +2 per extra page
credits GET /v1/credits none 0 none

The perplexity and grok tools are paused for now and coming back soon, and are not listed until then.

Worked examples:

  • ChatGPT with include.shopping: true: 5 + 2 (feature group) + 2 (sync) = 9 credits.
  • Google News, pages: 2: 2 + 2 (one extra page) + 2 (sync) = 6 credits.
  • The Free plan's 500 one-time credits work on every engine tool: 71 plain chatgpt or copilot calls at 7, 83 gemini or aimode calls at 6, 100 google calls at 5, or 125 google_news calls at 4.

Failed calls are charged nothing, and the charged amount of each call is in the result's _meta as x-credits-charged, next to x-credits-remaining. See credits for the full rules.

Slots and timeouts

Two limits shape how an editor agent should use these tools.

Concurrency slots

A synchronous call holds one of your plan's concurrency slots for its whole run. The Free plan has 1 slot, Lite 10, Hobby 20, Starter 50, Growth 75 and Business 100 (rate limits). An agent that fires three tool calls in parallel on the Free plan will see the extra calls come back with CONCURRENT_LIMIT_EXCEEDED. Tell the agent to run engine calls one at a time unless you know your plan has room.

Duration

A synchronous call can take up to five minutes. The server streams keep-alive comments to clients that accept text/event-stream, but the client's own tool timeout still applies. In Claude Code, MCP_TOOL_TIMEOUT controls it; in other clients, look for a tool or request timeout setting and set it above five minutes where you can.

Keep the key out of the repository

The key spends credits on your account, so treat every place it can land as sensitive:

  1. Never commit a config file with a literal key. Reference an environment variable (${env:NAME} in Cursor, ${VAR} in Claude Code's .mcp.json) and commit only that.
  2. Treat the key-in-path URL as a password. https://mcp.answerline.dev/<API_KEY>/mcp should never appear in a README, an issue, a chat message or a screen recording.
  3. Use a separate key for editor work. If a laptop config leaks, you can revoke that key alone; a revoked key stops working within a minute.
  4. Git-ignore any project config that holds a literal key, such as a .cursor/mcp.json you have not yet switched to a variable.
  5. Keep approvals on. Cursor's default approval prompt is also a spending check.

Errors the agent should handle

API errors do not break the MCP session. The server returns a normal tool result with isError: true and the API's error body as text, and puts the request id in _meta under x-request-id. The model can read the code and act:

Code Meaning What the agent should do
CONCURRENT_LIMIT_EXCEEDED All slots were busy Wait for its other call to finish, then retry once
INSUFFICIENT_CREDITS Balance too low for the call Stop and tell you; do not retry
RATE_LIMIT_EXCEEDED Over the per-second request limit Retry after a short pause
400 "Request validation failed" with details[] A field was wrong, for example a prompt over 10,000 characters Read details[].field and fix the arguments
EXTERNAL_SERVICE_ERROR (502) The engine request failed Report it; the call was not charged

A standing instruction for the agent: "Call engine tools sequentially. If a result has isError, read the code; stop on INSUFFICIENT_CREDITS and report the x-request-id for anything else you cannot fix."

Example session

"Before we ship this pricing page, ask ChatGPT and Gemini 'best invoicing tool for freelancers' in the US, list every domain each one cites, and tell me which of our competitors appear."

The agent makes two calls, chatgpt (7 credits) and gemini (6 credits), 13 in total. It reads sources[].url from both results, reduces them to domains, and compares the two sets. It can also match brand names in each answer's text to see which brands were named even where no source is cited. Don't ask it for ChatGPT's underlying searches: include.searchQueries is free, but searchQueries[] comes back empty on the ChatGPT answers served today (search queries).

Because the JSON lands in the editor's context, the agent can then write a monitoring script against the field names it has just seen.

When to leave the editor

Editor tools are for questions you ask now. Recurring work, such as the same 200 prompts every Monday, belongs in async tasks and batches: they skip the 2-credit surcharge (200 ChatGPT prompts cost 200 × 5 = 1,000 credits as tasks versus 200 × 7 = 1,400 as tool calls), queue instead of failing when slots are busy, and can deliver results by webhook (sync, async and webhooks). For agent architecture beyond the editor, see giving an AI agent live answer data and the LangChain tools; for tracking competitors over time, see competitor AI answer monitoring.

Full tool reference: /docs/mcp.

Top comments (0)