Connector guide6-minute read13 MCP tools7 languages

How to Connect Gemini API to Cursor via MCP

Let your AI use Google Gemini with your own API key: ask Gemini models questions, analyse images and PDFs from a link, count tokens, create embeddings, and generate or edit pictures with Nano Banana that appear right in the chat.

HCBy HelpCode teamUpdated 6 min read Open-source on GitHub

No credit card · 7-day trial · Self-host alternative available

Google Gemini API

Google Gemini API

Let your AI use Google Gemini with your own API key: ask Gemini models questions, analyse images and PDFs from a link, count tokens, create embeddings, and generate or edit pictures with Nano Banana that appear right in the chat.

tools

13

Region

INTL

Category

Public Data

Authentication

API Key

Required env vars

GEMINI_API_KEY
Install in one click on Cloud

7-day free trial · No credit card

  • 7-day free trial
    No credit card required
  • GDPR & SOC 2 ready
    EU data residency, audit logs
  • Open-source on GitHub
    Open source · AGPL-3.0
  • Works with ChatGPT, Claude, Gemini
    Any MCP-compatible client

Skip the install. Get this working in under 2 minutes.

Start a free trial on cloud.anythingmcp.com, add the Google Gemini API in one click, then point your AI client (Claude, ChatGPT, Copilot or Cursor) at the generated MCP endpoint. No Docker, no git clone, zero engineering experience required.

Start free trial

Summary

Let your AI use Google Gemini with your own API key: ask Gemini models questions, analyse images and PDFs from a link, count tokens, create embeddings, and generate or edit pictures with Nano Banana that appear right in the chat.

Try asking

Example prompts for Google Gemini API

Click any prompt to copy it. Paste into Claude, ChatGPT, Cursor, Gemini, Copilot or OpenClaw to run it against this connector.

Google Gemini API · live via MCP
Share
Opus 4.7

Claude is AI and can make mistakes. Please double-check responses.

💡 No install? Use cloud.anythingmcp.com directly. Sign in, click Connectors → Google Gemini API, paste your credentials, mint an MCP API key and you're done. No Docker, no git clone, no local server.

Gemini API + Cursor

Let your AI use Google Gemini with your own API key: ask Gemini models questions, analyse images and PDFs from a link, count tokens, create embeddings, and generate or edit pictures with Nano Banana that appear right in the chat.

Prerequisites

See the full setup instructions baked into the connector (visible in the in-app store when you select the connector). The required environment variables for this connector are:

GEMINI_API_KEY

Step 1 — Get credentials

  1. Open Google AI Studio at https://aistudio.google.com/apikey and sign in with your Google account.
  2. Click Create API key, pick or create a Google Cloud project, and copy the key. It usually starts with AIza.
  3. Paste it into GEMINI_API_KEY and install the connector. The key is sent only to Google.
  4. To generate images, or for higher limits, enable billing for the key's project in AI Studio (Get API key, then Set up billing). Image models have no free tier.
  5. Run gemini_list_models to see which models your key can use. It costs nothing.

Billing: the Gemini API runs on your own key. Every call except the model list, the Files API and token counting is billed to the key's project or counts against its free tier. On the free tier, text and embedding models are free within per-minute and per-day limits, and Google may use free-tier prompts to improve its products. The AI uses cheap, fast defaults (gemini-3.1-flash-lite for text, gemini-embedding-001 for embeddings) unless you ask for a stronger model, and gemini_count_tokens estimates a long prompt for free before you send it.

Pictures cost money: gemini_generate_image and gemini_edit_image create or change pictures with Nano Banana and show them right in the chat. The default image model costs about $0.034 per picture, the most capable one about $0.13, so the AI confirms with you before every picture. Pictures over 4 MB are not returned: ask for a smaller size.

Files by link: gemini_analyze_file_url answers questions about an image, PDF, text or CSV file or a short video given by a public HTTPS link of up to 15 MB. Gemini fetches the link itself, so it must open without a login. The Files API tools list and read the project's stored files, which expire after 48 hours. gemini_delete_file is switched off at install.

Common errors: 400 with an invalid key: the key is wrong or was deleted, so create a new one in AI Studio. 403: the key is restricted to other APIs (in the Google Cloud console under Credentials, API restrictions, allow the Generative Language API), the API is off in its project, or a file link is not public. 404: the model code does not exist, so check gemini_list_models. 429: a free-tier or paid-tier limit was reached, or an image model was called without billing; wait, or enable billing. A 400 saying the free tier is not available means it is not offered in your region: enable billing. A request blocked by Google's safety filters comes back as an error and is not retried.

The connector does not upload files, stream audio or video (Live API), generate speech or video (Veo), or handle context caching, batch jobs, tuned models or file search stores.

Step 2 — Install the adapter

curl -fsSL https://raw.githubusercontent.com/HelpCode-ai/anythingmcp/main/docker-compose.quickstart.yml -o docker-compose.yml
printf 'JWT_SECRET=%s\nENCRYPTION_KEY=%s\n' "$(openssl rand -hex 32)" "$(openssl rand -hex 32)" > .env
docker compose up -d

Step 3 — Add the connector in Cursor

Your server URL: in AnythingMCP, open MCP Servers → the server this connector is on, and copy its URL (https://cloud.anythingmcp.com/mcp/…). Use it wherever this guide shows YOUR_SERVER_ID.

Cursor reads MCP servers from ~/.cursor/mcp.json. Add this entry:

{
  "mcpServers": {
    "anythingmcp": {
      "url": "https://cloud.anythingmcp.com/mcp/YOUR_SERVER_ID",
      "headers": { "X-API-Key": "YOUR_MCP_API_KEY" }
    }
  }
}
  1. Create an MCP API key in AnythingMCP under MCP Servers → your server → API keys, and paste it in place of YOUR_MCP_API_KEY.
  2. Save the file and restart Cursor.
  3. Open Cursor → Settings → MCP and check that anythingmcp is listed and connected.
  4. Start chatting: the agent can now call the Gemini API tools.

Available tools

ToolWhat it does
gemini_list_modelsList the Gemini models this API key can use, with their input and output token limits, whether they think, and the methods they support…
gemini_get_modelRead one Gemini model: display name, description, version, input and output token limits, default temperature, top-p and top-k, whether it…
gemini_generate_textAsk a Gemini model one question and get its text answer (generateContent)
gemini_generate_contentFull generateContent call for conversations and mixed input. contents is the list of turns: [{"role": "user", "parts": [{"text": "..."}]}…
gemini_analyze_file_urlAsk a Gemini model about a file on the web: an image, a PDF, a text or CSV file or a short video, given by its public HTTPS link (up to 15…
gemini_count_tokensCount how many input tokens a text is for a Gemini model, to estimate cost or check it fits the context window before a long call
gemini_embed_textTurn one text into an embedding vector (embedContent) for semantic search, clustering or similarity
gemini_batch_embed_textsEmbed up to 20 texts in one call (batchEmbedContents); the vectors come back in the order given
gemini_generate_imageCreate a picture from a text description with a Gemini image model (Nano Banana) and return it as an image the user can see
gemini_edit_imageChange an existing picture with a Gemini image model: describe the edit ("replace the sky with a sunset", "remove the person on the left"…
gemini_list_filesList the files stored in the project's Gemini Files API (uploaded for prompts, or generated), newest first, with name, display name, MIME…
gemini_get_fileRead one file of the Gemini Files API: display name, MIME type, size, state (PROCESSING, ACTIVE or FAILED), uri to use in…
gemini_delete_fileDelete a file from the Gemini Files API before it expires

Example prompts

  • "Read the supplier price list PDF at the link I paste below and list every product with its price."
  • "Ask Gemini to rewrite this product description in a shorter, friendlier tone for our online shop."
  • "How many tokens is this proposal for Gemini, and what would summarising it cost on the default model?"
  • "Create a product photo of our blue ceramic mug on a wooden table with Nano Banana, but tell me the cost and wait for my OK first."

FAQ

Does Cursor support custom MCP servers on the free tier? Yes, MCP is available on Hobby, Pro and Business plans.

Next steps

Was this guide helpful?

Your Google Gemini API agent is one click away.

Install the connector, paste the key, prompt Cursor. Free for 7 days, no credit card.

Related guides

Connectors

How to Connect Gemini API to ChatGPT via MCP

Let your AI use Google Gemini with your own API key: ask Gemini models questions, analyse images and PDFs from a link, count tokens, create embeddings, and generate or edit pictures with Nano Banana that appear right in the chat.

Connectors

How to Connect Gemini API to Claude via MCP

Let your AI use Google Gemini with your own API key: ask Gemini models questions, analyse images and PDFs from a link, count tokens, create embeddings, and generate or edit pictures with Nano Banana that appear right in the chat.

Connectors

How to Use the Gemini API in Gemini CLI via MCP

Let your AI use Google Gemini with your own API key: ask Gemini models questions, analyse images and PDFs from a link, count tokens, create embeddings, and generate or edit pictures with Nano Banana that appear right in the chat.

Connectors

How to Connect Gemini API to Meta Muse via MCP

Let your AI use Google Gemini with your own API key: ask Gemini models questions, analyse images and PDFs from a link, count tokens, create embeddings, and generate or edit pictures with Nano Banana that appear right in the chat.

Connectors

Gemini API to MCP: Use Google Gemini from any AI Agent

Let your AI use Google Gemini with your own API key: ask Gemini models questions, analyse images and PDFs from a link, count tokens, create embeddings, and generate or edit pictures with Nano Banana that appear right in the chat.

Connectors

How to Connect Avito to Cursor via MCP

Let your AI work with your Avito business account: list your ads and change their prices, read views, contacts and calls statistics, check autoload uploads and their errors, the feed format and your wallet, and read Avito Messenger chats. Sending messages and changing autoload settings are optional and off by default.