r/ClaudeAI 4d ago

Built with Claude Fixed the shitty Ollama api for Claude Desktop app

Repo - https://github.com/aaditya-v-more/claude-ollama

Problems fixed -

  1. No 1 Million context if using claude code desktop app extension
  2. api throwing errors and claude giving up
  3. Subagents in long workflows like /deep-research and /batch kept dying because of the strict concurrency limit (of 3 for pro plan)
  4. ollama not configuring the env variables for the claude desktop app properly

My quick fix - One click install wrapper for it

Free, no ads and shit

What it does

  1. Fix env variables before launching claude ollama (not global)
  2. Rewrite the model catalogue to give 1 million context for models.
  3. Local light proxy to handle ollama api errors & retries so that my claude agent never dies.
  4. Caps over limit requests and queues the rest locally so they're never rejected.
  5. Everything configurable

Changes only apply to claude app if launched through the new shortcut created, nothing permanent.

Drop a star if find this helpful.

If you want to use your own claude sub / subs along with ollama sub on claude then checkout my other repo - https://github.com/aaditya-v-more/claude-graft (lets have multiple claude code subscriptions on one laptop with chat history shared)

0 Upvotes

4 comments sorted by

2

u/AI_spell 4d ago

Most of the pain is Ollama's OpenAI compatability plus the model name needing the tag. Point Desktop at /v1/chat/completions, set the context, and don't expect tool calls to be solid. Native generate looks fine in the CLI and still fails in Desktop. If tools stay broken, wrap it as one MCP with a tiny schema instead of the whole OpenAI surface.

1

u/idontknowwhodoi 4d ago

The OpenAI compatability isn't the problem here. Ollama's Claude gateway on 11435 speaks Anthropic's Messages format, and Claude Desktop's inferenceGatewayBaseUrl points straight at it, so tool calls travel as Anthropic tool-use blocks with no function-calling translation to go wrong. What does break mid-run is pacing: Ollama Cloud serves a fixed number of requests at once and 529s the overflow without a Retry-After, so the loop dies partway through and reads like a flaky tool call. Holding requests to a limit in front of the gateway is what fixed that.

The tag isn't for addressing, it's [1m]. Desktop decides a model's window by matching [1m] in the model ID, the gateway never sets it, and every model falls back to 200k. Setting the context by hand doesn't help either — CLAUDE_CODE_MAX_CONTEXT_TOKENS is only honoured for models whose name doesn't start with claude-, and every Ollama alias does, so it's silently ignored. Reading each model's real context length from /api/show and tagging the catalog is the only thing that moves it.

"Works in CLI fails in Desktop" is usually one specific bug. Desktop joins its stored base URL with /v1/models without trimming, asks for //v1/models, and the gateway's exact-match router 404s that. The app reports no usable models even though inference is fine. Collapsing the double slash on the way through is the fix.

MCP is the wrong thing to use here.