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:
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.
Prerequisites
- A NanoGPT account with an API key (get one here)
- 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 vianpx.
Claude Code
macOS / LinuxOn native Windows,npxis usually a.cmdshim, so it should be launched throughcmd /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 existingnanogptMCP entry and add it again using the commands on this page. An immediateInvalid API keyerror can be caused by a broken MCP launcher command, not just a bad key value.
Codex
Cursor, Claude Desktop and other JSON-configured clients
YOUR_API_KEY with your actual NanoGPT API key.
Option 2: Global Installation
Configuration
Required Environment Variables
Optional Environment Variables
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.
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”
Get YouTube Transcripts
“Use NanoGPT to get the transcript of this YouTube video: https://www.youtube.com/watch?v=…”
Scrape Web Pages
“Use NanoGPT to scrape the content from https://example.com”
Tool Reference
nanogpt_chat
Send a chat completion request to an AI model. Parameters:messages(required): Array of message objects withrole(“system”, “user”, “assistant”) andcontentmodel(optional): Model ID (usesNANOGPT_DEFAULT_MODELwhen omitted)temperature(optional): Sampling temperature (0-2)max_tokens(optional): Maximum tokens in response
nanogpt_get_balance
Check your current account balance. Parameters: None Returns:usd_balance: Balance in USDnano_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 generatemodel(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
nanogpt_web_search
Search the web for current information. Parameters:query(required): Search querydepth(optional): “standard” or “deep”outputType(optional): “searchResults”, “sourcedAnswer”, or “structured”includeImages(optional): Include image resultsfromDate/toDate(optional): Date range filter (YYYY-MM-DD)
nanogpt_vision
Analyze images using vision-capable models. Parameters:messages(required): Array of message objects with text and image content blocksmodel(optional): Vision-capable model IDtemperature(optional): Sampling temperature (0-2)max_tokens(optional): Maximum tokens in response
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
nanogpt_youtube_transcribe
Get transcripts from YouTube videos. Parameters:urls(required): Array of YouTube URLs (max 10 per request)
nanogpt_video_generate
Generate videos from a text prompt, an image or a video. Parameters:operation(optional):submit(default),submit_and_poll,pollorstatusmodel(required to submit): Video model ID fromnanogpt_list_video_modelsprompt(optional): Text description of the videoimageUrl/imageDataUrl(optional): Input image as a public URL or data URLduration,resolution,aspect_ratio(optional): Model-dependent settingsrunId(forpollandstatus): Job ID returned by a previous calltimeout_ms(optional): How long to wait for the result (default 50000)
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,pollorstatusmodel(required to submit): 3D model ID fromnanogpt_list_3d_modelsprompt(optional): Text description for text-to-3D modelsimageUrl/imageDataUrl(optional): Input image for image-to-3D modelsrunId(forpollandstatus): Job ID returned by a previous calltimeout_ms(optional): How long to wait for the result (default 50000)
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 totimeout_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 thantimeout_ms.- If the job is still running, the result contains its
runId. Call the tool again withoperation: "poll"and thatrunIdto keep waiting, oroperation: "status"for a single check. operation: "submit"only submits the job.
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.
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 callnanogpt://image/{id}: Generated images stored during the sessionnanogpt://media/{id}: Generated audio and other media stored during the session
Error Handling
The MCP server provides clear error messages for common issues:Billing
- All paid tools deduct from your NanoGPT balance
- Use
nanogpt_get_balanceto check your balance before expensive operations - Model listing tools are free to use
- Video and 3D jobs are charged when submitted; use
pollto keep waiting instead of submitting again
Troubleshooting
”Missing required env var: NANOGPT_API_KEY”
macOS / Linux--env NANOGPT_API_KEY=... again.
”Invalid API key” errors
An immediateInvalid API key error can be caused by a broken MCP launcher command, not just a bad key value.
- Verify your API key at nano-gpt.com/api
- Make sure you’re using the full API key value
- Check for extra spaces or newlines in the key
- Verify that your Claude Code MCP launch command is correct, especially on Windows where
npxshould be run viacmd /c "C:\Program Files\nodejs\npx.cmd".
Requests timing out
For long-running operations like web search, you can increase the timeout: macOS / LinuxVideo or 3D tool calls time out
Many MCP clients stop a tool call after 60 seconds. Keeptimeout_ms below that limit and continue with operation: "poll" and the returned runId until the job finishes.
MCP server not connecting
- Ensure Node.js 22+ is installed:
node --version - Try removing and re-adding the MCP server
- Check your MCP client’s logs for detailed error messages
- If you already added NanoGPT using an older command, remove the existing
nanogptMCP entry and add it again with the updated command
Support
- Documentation: nano-gpt.com/docs
- Discord: Join our community for help and updates
- API Keys: 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