Large Language ModelsGenerate imagesGenerate videos

LM Studio MCP Image Generation: Local Setup Step by Step

A hands-on tutorial for running LM Studio MCP image generation on your own computer. Install LM Studio, pick a model that can call tools, edit mcp.json, add an image tool, approve the first call, and fix the errors that stop most setups. Working code included.

LM Studio MCP Image Generation: Local Setup Step by Step
Cristian Da Conceicao
Founder of Picasso IA

You type one sentence into a chat window on your own computer, and a few seconds later a finished photograph appears in the conversation. No browser tab, no copy and paste between apps, no cloud chatbot reading your drafts. That is what LM Studio MCP image generation feels like once the pieces are connected, and the connection takes about fifteen minutes. This tutorial follows the setup in order: installing LM Studio, choosing a model that can call tools, editing mcp.json, adding an image tool, approving the first call, and fixing the problems that trip up most first attempts.

Every file and command below is meant to be copied. Where a detail depends on your machine, a callout tells you what to check before you move on.

Why Run This Locally?

What MCP Does Here

MCP, the Model Context Protocol, is a standard way for an app to hand tools to a language model. LM Studio is the host. It loads a model on your machine, connects to one or more MCP servers, and shows the model what each server can do. When the model decides a tool is useful, LM Studio runs it and feeds the result back into the chat.

For images the tool is simple. The model writes a prompt, calls something like generate_image, and receives an image URL. The language model never draws a single pixel. It acts as a director: it takes your loose idea, turns it into a detailed brief, and hands that brief to an image engine.

Local Chat, Remote Image Engine

The split matters because it decides your hardware budget.

PieceWhere it runsWhat it costs you
Chat model in LM StudioYour computerMemory and GPU time
MCP server processYour computerA few megabytes
Image model behind the toolYour GPU or a hosted APIDepends on the option you pick

Running an image model beside a chat model on one consumer graphics card is possible but cramped, because both want video memory. Pointing the tool at a hosted API leaves the GPU free for the language model. Your conversation, your files and your tool approvals stay on your machine, and only the final image prompt travels out. This tutorial takes the hosted route and uses the PicassoIA API as the worked example, but the pattern fits any image service.

💡 Want everything offline? Swap the tool's backend for a local image server. The LM Studio side of the setup stays exactly the same.

What You Need Before You Start

Hardware That Works

Technician seating a matte black graphics card into a motherboard inside an open PC case

The chat model's size sets the floor. These numbers are rough guidance for 4-bit builds, not benchmarks, so leave headroom for the context window.

Model classMemory needed (approx.)Comfortable machine
7B to 8Babout 5 GBLaptop with 16 GB of RAM
20Babout 16 GBDesktop with 32 GB of RAM or a 16 GB GPU
30B and up24 GB and upWorkstation GPU or a Mac with 48 GB of unified memory

Apple Silicon Macs share one memory pool between CPU and GPU, which makes them surprisingly good at mid-size models. On Windows and Linux, an NVIDIA card with 12 GB of VRAM or more gives the smoothest ride, and a CPU-only run works if you accept slower replies.

Software Checklist

  • LM Studio 0.3.17 or later. That release added MCP support. Older builds have no Program tab.
  • Node.js (current LTS). Needed for the local command server shown below.
  • An image service token. For PicassoIA, create a secret on the API page. It starts with pia_sk_.
  • A plain text editor. The in-app editor works, but a second window helps when you compare JSON.

Install LM Studio and a Model

Download and Install

Woman at a kitchen table with a laptop and a mug of tea in early morning light

Download the installer for Windows, macOS or Linux from lmstudio.ai and run it like any other desktop app. Open the app, then check the version number in the settings. If it reads below 0.3.17, update before going further, because nothing in the next section exists in older builds.

The first launch offers a model catalog. Skip the biggest names for now. A small model that answers in two seconds tells you more about your setup than a huge one that needs a minute per reply.

Pick a Tool-Ready Model

Flat lay of a walnut desk with a laptop, an external drive and a notebook with a hand drawn diagram

Tool calling is a trained behavior. A model that never saw tool-use examples will ignore your image server or invent a broken call. Check each model card for "tool use" or "function calling" before you download.

Two sensible starting points, both available to try in the browser first so you can judge their writing before you spend bandwidth:

ModelSize classWhy pick it
GPT OSS 20B20BOpen weights, tool use supported, writes detailed prompts
Granite 4.1 8B8BSmall enough for a laptop, quick replies

Pay attention to the context length setting when you load the model. Tool descriptions, your system prompt and the whole conversation share that window. A small window fills quickly, and a model that has lost the tool description simply stops calling the tool. Start with at least 8,000 tokens and raise it if the model forgets earlier steps.

💡 Download a 4-bit quantized build first. Prompt writing barely suffers, and the file is roughly a quarter of the full-precision size.

Wire Up the MCP Server

Open mcp.json in the App

Close-up of hands typing on a mechanical board with a code editor blurred in the background

  1. Open any chat in LM Studio.
  2. Switch to the Program tab in the right sidebar.
  3. Click Install, then Edit mcp.json.
  4. Edit the file in the built-in editor and save.

LM Studio follows Cursor's mcp.json notation, so a config written for Cursor reads the same way here. Saving should start the server and list its tools. A red error at this point almost always means broken JSON.

Add a Remote Server

Remote servers need a URL and, usually, a header with your credentials:

{
  "mcpServers": {
    "image-service": {
      "url": "https://mcp.example.com/mcp",
      "headers": {
        "Authorization": "Bearer <YOUR_TOKEN>"
      }
    }
  }
}

Replace the URL with the address your image provider publishes. PicassoIA lists its MCP connections inside your account, so check there for connection details. If a provider's sign-in flow expects a browser login instead of a static header, use the local command route below, which works with a plain token.

Add a Local Command Server

A local server is a small program that LM Studio starts for you:

{
  "mcpServers": {
    "image-tool": {
      "command": "node",
      "args": ["C:/tools/image-mcp/index.js"],
      "env": {
        "IMAGE_API_TOKEN": "pia_sk_paste_your_secret_here"
      }
    }
  }
}

Use forward slashes in Windows paths, or double every backslash. A single backslash breaks the JSON and the server never starts.

Give the Model an Image Tool

The server only has to expose one tool. Keep the contract tiny, because small models handle two parameters far better than ten.

FieldTypeNotes
promptstringThe brief the model writes
aspect_ratiostringDefault 16:9, also allow 1:1 and 9:16
ReturnsURLThe finished image link

The PicassoIA API follows the Replicate pattern: create a prediction, poll it, read the output. A cURL call looks like this:

curl -s -X POST https://api.picassoia.com/v1/models/picassoia/picassoia-image/predictions \
  -H "Authorization: Bearer $IMAGE_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"input": {"prompt": "a lighthouse at sunset, film photograph", "aspect_ratio": "16:9"}}'

Inside your server, the same flow is one short function. Wrap it in a tool handler built with the official MCP SDK for your language:

const API = "https://api.picassoia.com/v1";
const headers = {
  Authorization: `Bearer ${process.env.IMAGE_API_TOKEN}`,
  "Content-Type": "application/json",
};

async function makeImage(prompt, aspect_ratio = "16:9") {
  const start = await fetch(
    `${API}/models/picassoia/picassoia-image/predictions`,
    { method: "POST", headers, body: JSON.stringify({ input: { prompt, aspect_ratio } }) }
  );
  let job = await start.json();

  while (["starting", "processing"].includes(job.status)) {
    await new Promise((r) => setTimeout(r, 2000));
    job = await (await fetch(`${API}/predictions/${job.id}`, { headers })).json();
  }

  if (job.status !== "succeeded") throw new Error(`Image job ${job.status}`);
  return Array.isArray(job.output) ? job.output[0] : job.output;
}

Four facts to keep in mind:

  • Jobs are asynchronous, with the statuses starting, processing, succeeded, failed and canceled.
  • An account runs 5 predictions at once, shared across every token and connection.
  • Prompts are capped at 4,000 characters.
  • The model behind this call is PicassoIA Image. For edits, PicassoIA Image Editor Pro uses the same API pattern.

💡 Check your plan. API access depends on your PicassoIA plan, so read the current terms on the pricing page before you build a daily routine around it.

First Run in the Chat Window

Open a new chat, load your tool-ready model, and confirm the server shows as enabled in the Program tab. Then ask for something concrete:

Generate a 16:9 photograph of a quiet harbor at sunrise, fishing boats at rest, soft haze, shot on 35mm film.

Here is what one round trip looks like once everything is connected:

  1. You send the sentence above.
  2. The model drafts a detailed brief of roughly 50 words and decides to call generate_image.
  3. LM Studio pauses and asks for your approval.
  4. The server creates the prediction, polls it, and gets back a URL.
  5. The model replies with the link and a one-line description of what it requested.

On a mid-range laptop the whole loop usually lands in well under a minute, and most of that time is the language model thinking, not the image engine.

Approve the Tool Call

Finger hovering above the Enter button next to a brass padlock on a wooden desk

When the model calls your tool, LM Studio shows a confirmation dialog first. You can review the arguments, edit them, and then approve. Choose allow once while you test, or always allow for a tool you trust. Permanent permissions can be managed later in the app settings.

Read the arguments every time at the start. That is where you see what the model actually wrote: the prompt, the ratio, and anything odd it added. A model that sends a 3,000-character essay to a tool built for one paragraph needs a firmer system prompt.

After you approve, the tool runs, returns an image URL, and the model reports back in the chat. Open the link to see the result.

Write Prompts That Work

Man holding a film camera toward a misty mountain lake at dawn

Models write better image prompts when the system prompt tells them how. Paste this into the system prompt field:

You are a photo director. When asked for an image, call generate_image with one prompt of 40 to 70 words: subject and action, setting, light direction, lens and distance, and surface texture. Never request neon, cartoon or 3D styles.

Why it works: image models respond to the same cues a photographer thinks in.

  • Subject and action come first, in plain words.
  • Light gets a direction: "window light from the left" or "overcast noon".
  • Lens and distance set the framing: "85mm close-up" or "24mm wide shot".
  • Texture adds realism: "wool weave", "wet stone", "fine film grain".

Short prompts are fine for drafts. For a final image, add detail and rerun with a fixed seed if your tool exposes one, so only a single variable changes at a time.

Fix Problems and Stay Safe

Server Won't Start

Developer leaning back in a chair studying a monitor with a thoughtful frown

Work through this list in order:

  1. Validate the JSON. One trailing comma is enough to stop everything.
  2. Run the command by hand. Paste the command and args into a terminal. If it fails there, it fails in LM Studio too.
  3. Check the path. Forward slashes on Windows, and no stray spaces.
  4. Check the environment variable. An empty token produces an authorization error from the API rather than a crash, so read the tool's error text.

Model Ignores the Tool

Three causes account for most cases:

  • The model was not trained for tools. Switch to one whose card lists tool use.
  • Too many tools. LM Studio's own documentation warns that servers built for cloud assistants can use a large number of tokens and overload a local model. Keep one or two servers active, not ten.
  • The context window is too short. Raise the context length so the tool descriptions and the chat history both fit.

💡 Job stuck in processing? Remember the limit of 5 predictions at once. The API also exposes POST /v1/predictions/{id}/cancel for clearing jobs that hang.

Protect Your API Token

LM Studio's documentation says it plainly: never install MCP servers from untrusted sources. A server can run arbitrary code, read local files and use your network connection. Treat each entry in mcp.json like an app you are installing.

For your token:

  • Keep the secret in the env block, never in a chat message or a prompt.
  • Remember that mcp.json stores it as plain text, so never commit that file to a public repository.
  • PicassoIA allows two tokens per account, so rotate one at a time: create the new one, update mcp.json, then delete the old one.
  • Keep approvals on allow once for any server you did not write yourself.

How to Use P Image on PicassoIA

Before you wire a prompt into the tool, test it in a browser. P Image on PicassoIA returns a finished image in under a second with unlimited generations, which makes it a fast sandbox for prompts your language model will write later.

Woman lifting a printed landscape photograph toward a window beside a cork board of prints

  1. Open the model page. Go to the P Image page.
  2. Paste the prompt. The prompt is the only required field. Use the one your local model wrote.
  3. Set the aspect ratio. The default is 1:1. Choose 16:9 for wide images, or custom with a width and height that are multiples of 16.
  4. Adjust the optional settings. Turn on prompt upsampling for short prompts. Enter a seed when you want to reproduce a result.
  5. Generate. Click the generate button and wait about a second.
  6. Download. Save the image and compare it with what your tool returned in LM Studio.
ParameterTypeWhat it does
promptstringRequired. The text description
aspect_ratiochoice1:1 by default, plus 16:9, 9:16, 4:3, 3:4, 3:2, 2:3, custom
width, heightintegerUsed with custom only, multiples of 16
prompt_upsamplingbooleanLets an LLM add visual detail to short prompts
seedintegerSame seed and prompt reproduce the same image

If the draft looks right but you want a different look, run the same prompt through Z-Image Turbo, Flux 2 Klein 4B or Seedream 4.5 and keep the one that fits your project.

Make Your Own Images Today

Cozy home office at dusk with a laptop and a warm desk lamp

You now have a chat window that writes briefs and an engine that turns them into photographs. Try one round tonight. Ask your local model for three prompts about a scene you care about, paste each into P Image on Picasso IA, and see which wording gives you the sharpest result. Then send the winning style to your LM Studio tool and watch the same image appear without leaving the chat.

Picasso IA also offers image editing, upscaling and short video clips, so a good still can become a thumbnail, a poster or a moving scene later. Browse the full catalog at picassoia.com/en/all-models, pick a model, and generate your first image today.

Share this article