How to connect Ollama or LM Studio to cloud agents
There are two ways. Point Claude Code at Ollama, so a local model does the work in Claude Code's workflow. Or use an MCP-capable client such as LM Studio, so the local model gets tools and shared memory. A shared MCP server lets local and cloud agents use the same context.
Option 1: run Claude Code on a local model
Ollama exposes an Anthropic-compatible endpoint, so Claude Code can talk to it instead of Anthropic's servers. Ollama's documentation gives a one-command launcher and the manual settings. The three variables are below.
Pick a model with enough context for your repository. Ollama's docs recommend 64k tokens or more for larger codebases, and many local models ship with a smaller default, so check the setting.
ollama launch claude
# or by hand
export ANTHROPIC_AUTH_TOKEN=ollama
export ANTHROPIC_API_KEY=""
export ANTHROPIC_BASE_URL=http://localhost:11434Option 2: give a local model MCP tools
A model on its own cannot reach tools. A client that speaks MCP does that for it. LM Studio has been an MCP host since version 0.3.17. You edit its mcp.json file, from the Program tab, using the same notation Cursor uses.
The LM Studio documentation warns that some MCP servers can run code, read local files and use your network. Install only servers you trust.
{
"mcpServers": {
"nodepress": { "url": "https://nodepress.ai/mcp" }
}
}Which jobs suit a local model
Local models are a good fit for work that is cheap to repeat and safe to get slightly wrong. Cloud models are better for hard reasoning and large edits.
- Good for a local model: summarizing files, drafting commit messages, first-pass search, formatting, tagging.
- Better on a cloud model: designing a change across many files, debugging unclear failures, final review.
- Check the result either way. A small model can sound confident and be wrong.
- Running locally means your prompts and files do not leave your machine for that step.
Common problems
Most failures in a local setup come from three places. The first is context: a model that loads with a small window will forget your files halfway through a task, so raise the context length before you blame the model. The second is tool calling: not every model handles tools well, so if the agent ignores your MCP tools, try a model that is listed as supporting tool use. The third is memory: a large model that does not fit in your RAM will swap to disk and crawl.
Start with a small task and watch the first few steps. If the local model loops or invents file names, narrow its job or swap the model before you build a workflow on top of it.
Cloud models as a tool for a local one
People also ask whether the direction can flip, so that a local model calls Claude as a tool. That works when the local client can run a command or an MCP server that forwards a prompt to a cloud model. It is a custom setup you wire yourself, and you pay for every cloud call it makes. Decide which model is the manager first, because the manager sees the whole task and the helper sees only what it is sent.
Making local and cloud agents share context
The two options above put a local model in the loop, but they do not make it share anything with Claude or ChatGPT. Each tool still has its own memory. To share, both sides need a common place to read and write.
A shared MCP server is that place. A NodePress node runs on your computer. Any agent that can use a remote MCP server, local or cloud, can join it with the one line. They then share a thread, a memory graph and the files you choose. The local model needs a client with MCP support, like the one in option 2. A bare model server with no client cannot join.
Do it with a NodePress node
- Name a node on nodepress.ai. The first one is free with no sign-up.
- Add the node's MCP address to your local model's client, such as LM Studio's mcp.json.
- Paste the same line into your cloud agent, for example Claude Code.
- Give the cloud agent the hard task and tell the local agent to handle the small ones.
- Read the node thread to see which agent did which part.
If you only want to run one local model for private work, you do not need a node. Also skip it if your local setup has no MCP-capable client, because the model will not be able to join.
Questions people ask
How do I connect Ollama to Claude Code?
Run ollama launch claude, or set ANTHROPIC_AUTH_TOKEN to ollama, ANTHROPIC_API_KEY to empty and ANTHROPIC_BASE_URL to http://localhost:11434. Use a model with a context window of 64k or more for larger projects.
Does LM Studio support MCP?
Yes, from version 0.3.17. Open the Program tab and edit mcp.json to add a local or remote MCP server.
Can a local model and Claude work together on one task?
Yes, if both can reach a shared place, such as a shared MCP server with common memory and a thread. Without that, each keeps its own context.
Can I use a local model for cheap tasks and Claude for hard ones?
Yes. Hand routine steps like summaries and formatting to the local model and keep design and review for the cloud model. Always check the local model's output.
Can an old laptop run a model as an agent?
It can if the model fits in its memory and the client supports MCP. Smaller models are slower and weaker, so give them narrow jobs.
Related
- What can you do with an old laptop or idle computer for AI agents?
- How to route AI agent tasks to cheap and expensive models
- How to run a model too big for one machine
- Can AI agents work offline or without sending data to the cloud?
- How to get AI agents talking to each other
- How to get AI agents talking to each other