> ## Documentation Index
> Fetch the complete documentation index at: https://docs.nano-gpt.com/llms.txt
> Use this file to discover all available pages before exploring further.

# MCP

> Use NanoGPT via MCP-compatible clients

# NanoGPT MCP Integration

The NanoGPT MCP (Model Context Protocol) server allows you to use NanoGPT's AI capabilities directly from MCP-compatible clients like Claude Code, Cursor, and other AI coding assistants.

## Features

The NanoGPT MCP server provides these tools:

| Area | Tools |
| - | - |
| Account | `nanogpt_get_balance` |
| Text | `nanogpt_chat`, `nanogpt_vision`, `nanogpt_embeddings`, `nanogpt_ai_detection` |
| Images | `nanogpt_image_generate`, `nanogpt_image_edit`, `nanogpt_ai_qr` |
| Video | `nanogpt_video_generate` |
| 3D | `nanogpt_3d_generate` |
| Audio | `nanogpt_text_to_speech`, `nanogpt_music_generate`, `nanogpt_audio_transcribe` |
| Web and research | `nanogpt_web_search`, `nanogpt_scrape_urls`, `nanogpt_firecrawl`, `nanogpt_x_research`, `nanogpt_hunter` |
| Model catalogs (free) | `nanogpt_list_text_models`, `nanogpt_list_image_models`, `nanogpt_list_video_models`, `nanogpt_list_3d_models`, `nanogpt_list_audio_models` |
| Feedback (free) | `nanogpt_send_feedback`, `nanogpt_get_feedback` |

Each tool describes its parameters to your agent through MCP, so the agent can call it without reading the API documentation. The source code is on [GitHub](https://github.com/Nano-GPT-com/nanogpt-mcp).

## Prerequisites

* A NanoGPT account with an API key ([get one here](https://nano-gpt.com/api))
* Node.js 22.x or later
* An MCP-compatible client (Claude Code, Codex, Cursor, Claude Desktop, etc.)

## Installation

### Option 1: Using npx (Recommended)

The easiest way to use the NanoGPT MCP server is via `npx`.

#### Claude Code

**macOS / Linux**

```bash theme={null}
claude mcp add nanogpt --scope user \
  --env NANOGPT_API_KEY=YOUR_API_KEY \
  -- npx -y @nanogpt/mcp
```

**Windows**

```powershell theme={null}
claude mcp add nanogpt --scope user --env NANOGPT_API_KEY=YOUR_API_KEY -- cmd /c "C:\Program Files\nodejs\npx.cmd" -y @nanogpt/mcp
```

> On native Windows, `npx` is usually a `.cmd` shim, so it should be launched through `cmd /c`. If you use WSL, run the macOS/Linux command inside WSL instead of the native Windows one.
>
> Claude Code's MCP CLI syntax has changed over time. If you copied an older NanoGPT command, remove the existing `nanogpt` MCP entry and add it again using the commands on this page.
>
> An immediate `Invalid API key` error can be caused by a broken MCP launcher command, not just a bad key value.

#### Codex

```bash theme={null}
codex mcp add nanogpt --env NANOGPT_API_KEY=YOUR_API_KEY -- npx -y @nanogpt/mcp
```

#### Cursor, Claude Desktop and other JSON-configured clients

```json theme={null}
{
  "mcpServers": {
    "nanogpt": {
      "command": "npx",
      "args": ["-y", "@nanogpt/mcp"],
      "env": { "NANOGPT_API_KEY": "YOUR_API_KEY" }
    }
  }
}
```

Replace `YOUR_API_KEY` with your actual NanoGPT API key.

### Option 2: Global Installation

```bash theme={null}
npm install -g @nanogpt/mcp
```

Then add to your MCP client:

```bash theme={null}
claude mcp add nanogpt --scope user \
  --env NANOGPT_API_KEY=YOUR_API_KEY \
  -- nanogpt-mcp
```

## Configuration

### Required Environment Variables

| Variable | Description |
| - | - |
| `NANOGPT_API_KEY` | Your NanoGPT API key (required) |

### Optional Environment Variables

| Variable | Default | Description |
| - | - | - |
| `NANOGPT_TIMEOUT_MS` | `120000` (2 min) | Default HTTP request timeout in milliseconds |
| `NANOGPT_DEFAULT_MODEL` | None | Default model for chat requests; set to `anthropic/claude-sonnet-5.5` for our recommended configuration |
| `NANOGPT_LOG_LEVEL` | `info` | Log level: `debug`, `info`, `warn`, `error` |
| `NANOGPT_BASE_URL` | `https://api.nano-gpt.com` | Base URL for the NanoGPT API. Set it to `https://nano-gpt.com` if your client has only IPv6. |
| `NANOGPT_AUTH_MODE` | `bearer` | Auth mode: `bearer`, `x-api-key`, or `both` |
| `NANOGPT_MAX_RETRIES` | `0` | Number of retry attempts |

Set `NANOGPT_DEFAULT_MODEL=anthropic/claude-sonnet-5.5` in your MCP client configuration to use Claude Sonnet 5.5 for chat requests that omit `model`.

## Usage Examples

Once configured, you can use NanoGPT tools directly from your MCP client. Here are some examples:

### Check Your Balance

Ask your AI assistant:

> "Check my NanoGPT balance"

The assistant will call `nanogpt_get_balance` and show your USD and Nano balances.

### Tell NanoGPT About a Problem

> "Report to NanoGPT that streaming tool calls stop before the arguments finish"

The assistant will call `nanogpt_send_feedback` and return a report ID. Later, ask it to check the report; it calls `nanogpt_get_feedback` for the status and the team's latest reply.

### Chat with AI Models

> "Use NanoGPT to ask Claude Sonnet about the best practices for REST API design"

### Generate Images

> "Use NanoGPT to generate an image of a futuristic city at sunset"

### Analyze Images

> "Use NanoGPT vision to analyze this product photo"

### Search the Web

> "Use NanoGPT web search to find the latest news about AI"

### Generate Videos

> "Use NanoGPT to generate a 5 second video of a paper boat drifting on a calm pond"

### Generate 3D Models

> "Use NanoGPT to make a 3D model of a wooden rocking chair and give me the GLB link"

### Scrape Web Pages

> "Use NanoGPT to scrape the content from [https://example.com](https://example.com)"

## Tool Reference

### nanogpt\_chat

Send a chat completion request to an AI model.

**Parameters:**

* `messages` (required): Array of message objects with `role` ("system", "user", "assistant") and `content`
* `model` (optional): Model ID (uses `NANOGPT_DEFAULT_MODEL` when omitted)
* `temperature` (optional): Sampling temperature (0-2)
* `max_tokens` (optional): Maximum tokens in response

**Example:**

```json theme={null}
{
  "messages": [
    {"role": "user", "content": "Explain quantum computing in simple terms"}
  ],
  "model": "openai/gpt-6.1-sol"
}
```

### nanogpt\_get\_balance

Check your current account balance.

**Parameters:** None

**Returns:**

* `usd_balance`: Balance in USD
* `nano_balance`: Balance in Nano (XNO)
* `nanoDepositAddress`: Your Nano deposit address

### nanogpt\_image\_generate

Generate images from text prompts.

**Parameters:**

* `prompt` (required): Text description of the image to generate
* `model` (optional): Image model to use (e.g., "openai/gpt-image-2.5/flare/text-to-image")
* `n` (optional): Number of images to generate (1-10)
* `size` (optional): Image size (e.g., "1024x1024")
* `quality` (optional): Image quality setting

**Example:**

```json theme={null}
{
  "prompt": "A serene mountain landscape at dawn",
  "model": "openai/gpt-image-2.5/flare/text-to-image",
  "size": "1024x1024"
}
```

### nanogpt\_web\_search

Search the web for current information.

**Parameters:**

* `query` (required): Search query
* `depth` (optional): "standard" or "deep"
* `outputType` (optional): "searchResults", "sourcedAnswer", or "structured"
* `includeImages` (optional): Include image results
* `fromDate` / `toDate` (optional): Date range filter (YYYY-MM-DD)

**Example:**

```json theme={null}
{
  "query": "latest developments in fusion energy",
  "depth": "deep",
  "outputType": "sourcedAnswer"
}
```

### nanogpt\_vision

Analyze images using vision-capable models.

**Parameters:**

* `messages` (required): Array of message objects with text and image content blocks
* `model` (optional): Vision-capable model ID
* `temperature` (optional): Sampling temperature (0-2)
* `max_tokens` (optional): Maximum tokens in response

**Example:**

```json theme={null}
{
  "messages": [
    {
      "role": "user",
      "content": [
        { "type": "text", "text": "What issues do you see in this image?" },
        {
          "type": "image",
          "source": {
            "type": "url",
            "url": "https://example.com/photo.jpg"
          }
        }
      ]
    }
  ],
  "model": "openai/gpt-6.1-sol"
}
```

### nanogpt\_scrape\_urls

Scrape content from web pages.

**Parameters:**

* `urls` (required): Array of URLs to scrape (max 5 per request)
* `mode` (optional): "scrape-page" or "conversation"
* `stealthMode` (optional): Use stealth mode for scraping

**Example:**

```json theme={null}
{
  "urls": ["https://example.com/article1", "https://example.com/article2"]
}
```

### nanogpt\_video\_generate

Generate videos from a text prompt, an image or a video.

**Parameters:**

* `operation` (optional): `submit` (default), `submit_and_poll`, `poll` or `status`
* `model` (required to submit): Video model ID from `nanogpt_list_video_models`
* `prompt` (optional): Text description of the video
* `imageUrl` / `imageDataUrl` (optional): Input image as a public URL or data URL
* `duration`, `resolution`, `aspect_ratio` (optional): Model-dependent settings
* `runId` (for `poll` and `status`): Job ID returned by a previous call
* `timeout_ms` (optional): How long to wait for the result (default 50000)

**Example:**

```json theme={null}
{
  "operation": "submit_and_poll",
  "model": "bytedance-seedance-v1-pro-fast",
  "prompt": "A paper boat drifting on a calm pond",
  "duration": 5,
  "resolution": "480p"
}
```

### nanogpt\_3d\_generate

Generate a 3D model (GLB and other formats) from a text prompt or an image.

**Parameters:**

* `operation` (optional): `submit_and_poll` (default), `submit`, `poll` or `status`
* `model` (required to submit): 3D model ID from `nanogpt_list_3d_models`
* `prompt` (optional): Text description for text-to-3D models
* `imageUrl` / `imageDataUrl` (optional): Input image for image-to-3D models
* `runId` (for `poll` and `status`): Job ID returned by a previous call
* `timeout_ms` (optional): How long to wait for the result (default 50000)

**Example:**

```json theme={null}
{
  "model": "hyper3d/rodin-v2.5",
  "prompt": "A wooden rocking chair"
}
```

### Video and 3D jobs

Video and 3D jobs run asynchronously and usually take between 30 seconds and several minutes:

* `operation: "submit_and_poll"` submits the job and waits up to `timeout_ms` (default 50 seconds) for the result. A finished job returns the video or GLB URL. The wait includes the submit request, but a submission that is still in progress is never cut short (aborting it could lose a job that was already accepted), so an unusually slow submission can take longer than `timeout_ms`.
* If the job is still running, the result contains its `runId`. Call the tool again with `operation: "poll"` and that `runId` to keep waiting, or `operation: "status"` for a single check.
* `operation: "submit"` only submits the job.

Many MCP clients stop a tool call after 60 seconds, so keep `timeout_ms` below your client's tool timeout and continue long jobs with `poll`. A job is charged when it is submitted, so poll instead of submitting it again.

### nanogpt\_send\_feedback

Send a bug report, feature request, documentation issue or model-quality report to the NanoGPT team. Agents use it when you ask, or when a NanoGPT problem is reproducible and blocks their task; they skip transient errors, timeouts, rate limits and low balance. Reports are private and free, but the account (or the team that pays for it) needs a balance or an active subscription, and each account can send 20 a day. See the [Feedback API](https://docs.nano-gpt.com/api-reference/endpoint/feedback.md).

**Parameters:**

* `type` (required): `bug`, `feature_request`, `documentation` or `model_quality`
* `title` (required): 4-200 characters
* `description` (required): 10-8,000 characters
* `request_id`, `endpoint`, `model`, `expected`, `actual`, `steps` (optional)

**Returns:** the report `id`, `status` and `created_at`.

### nanogpt\_get\_feedback

Read a report's status (`pending`, `accepted`, `in-progress`, `done` or `rejected`) and the team's latest reply. Only the API key that sent the report can read it.

**Parameters:**

* `id` (required): the report ID from `nanogpt_send_feedback`

### Other tools

Image editing, speech, music, transcription, embeddings, AI detection, artistic QR codes, and the research and data tools follow the same pattern: the agent sees each tool's parameters through MCP.

### nanogpt\_list\_text\_models

List available text/chat models.

**Parameters:**

* `detailed` (optional): Include pricing information (default: false)

### nanogpt\_list\_image\_models

List available image generation models.

**Parameters:**

* `detailed` (optional): Include pricing information (default: true)

### nanogpt\_list\_audio\_models

List available audio models.

**Parameters:**

* `detailed` (optional): Include pricing information (default: true)
* `type` (optional): Filter by type: "tts", "stt", or "all"

### nanogpt\_list\_video\_models

List available video generation models.

**Parameters:**

* `detailed` (optional): Include pricing information (default: true)

### nanogpt\_list\_3d\_models

List available 3D generation models with pricing and whether each accepts text, images or both.

**Parameters:**

* `detailed` (optional): Include pricing information (default: true)

## Resources

Resources allow agents to access data saved during a session:

* **`nanogpt://raw/{id}`**: Raw JSON response from a previous API call
* **`nanogpt://image/{id}`**: Generated images stored during the session
* **`nanogpt://media/{id}`**: Generated audio and other media stored during the session

## Error Handling

The MCP server provides clear error messages for common issues:

| Error | Meaning | Solution |
| - | - | - |
| Invalid API key | Authentication failed | Check your `NANOGPT_API_KEY` and MCP launch command |
| Insufficient balance | Account balance too low | Top up your account at [nano-gpt.com](https://nano-gpt.com) |
| Rate limited | Too many requests | Wait and try again |
| Timeout | Request took too long | Try a simpler request or increase `NANOGPT_TIMEOUT_MS` |

## Billing

* All paid tools deduct from your NanoGPT balance
* Use `nanogpt_get_balance` to check your balance before expensive operations
* Model listing tools are free to use
* Video and 3D jobs are charged when submitted; use `poll` to keep waiting instead of submitting again

## Troubleshooting

### "Missing required env var: NANOGPT\_API\_KEY"

**macOS / Linux**

```bash theme={null}
claude mcp add nanogpt --scope user \
  --env NANOGPT_API_KEY=your_actual_key_here \
  -- npx -y @nanogpt/mcp
```

**Windows**

```powershell theme={null}
claude mcp add nanogpt --scope user --env NANOGPT_API_KEY=your_actual_key_here -- cmd /c "C:\Program Files\nodejs\npx.cmd" -y @nanogpt/mcp
```

Make sure you set your API key when adding the MCP server. If you re-add the server later, include `--env NANOGPT_API_KEY=...` again.

### "Invalid API key" errors

An immediate `Invalid API key` error can be caused by a broken MCP launcher command, not just a bad key value.

1. Verify your API key at [nano-gpt.com/api](https://nano-gpt.com/api)
2. Make sure you're using the full API key value
3. Check for extra spaces or newlines in the key
4. Verify that your Claude Code MCP launch command is correct, especially on Windows where `npx` should be run via `cmd /c "C:\Program Files\nodejs\npx.cmd"`.

### Requests timing out

For long-running operations like web search, you can increase the timeout:

**macOS / Linux**

```bash theme={null}
claude mcp add nanogpt --scope user \
  --env NANOGPT_API_KEY=your_key \
  --env NANOGPT_TIMEOUT_MS=900000 \
  -- npx -y @nanogpt/mcp
```

**Windows**

```powershell theme={null}
claude mcp add nanogpt --scope user --env NANOGPT_API_KEY=your_key --env NANOGPT_TIMEOUT_MS=900000 -- cmd /c "C:\Program Files\nodejs\npx.cmd" -y @nanogpt/mcp
```

### Video or 3D tool calls time out

Many MCP clients stop a tool call after 60 seconds. Keep `timeout_ms` below that limit and continue with `operation: "poll"` and the returned `runId` until the job finishes.

### MCP server not connecting

1. Ensure Node.js 22+ is installed: `node --version`
2. Try removing and re-adding the MCP server
3. Check your MCP client's logs for detailed error messages
4. If you already added NanoGPT using an older command, remove the existing `nanogpt` MCP entry and add it again with the updated command

## Support

* **Documentation:** [nano-gpt.com/docs](https://nano-gpt.com/docs)
* **Discord:** Join our community for help and updates
* **API Keys:** [nano-gpt.com/api](https://nano-gpt.com/api)

## Privacy & Security

* Your API key is stored locally and only sent to NanoGPT servers
* The MCP server runs locally on your machine
* No data is logged or stored by the MCP server
* Chat messages and other content are processed according to NanoGPT's [privacy policy](https://nano-gpt.com/privacy)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.