Does llm 0.31.1 fix MCP tool call failures?

Sergii Muliarchuk

How the llm 0.31.1 patch fixes empty-argument tool call JSON errors and what MCP server operators must know before upgrading.

Does llm 0.31.1 fix MCP tool call failures?

TL;DR: Yes — llm 0.31.1, released July 9 2026, patches a real crash where OpenAI Chat Completion endpoints returned tool calls with empty arguments, causing a silent JSON parse failure. If you run any MCP server that shells out to llm or uses it as a Python library backend, upgrading to 0.31.1 is non-negotiable. The fix is small, the risk of staying on 0.31.0 is meaningful.

At a glance

  • Release date: llm 0.31.1 dropped on July 9, 2026 — 2 days before this article.
  • Bug fixed: Issue #1521 — JSON parse error on empty-argument tool calls from OpenAI-compatible endpoints.
  • Affected versions: llm 0.31.0 and earlier when calling any provider that omits {} in tool call arguments.
  • Simon Willison (creator of llm) confirmed the bug was caught during live MCP endpoint testing, not a synthetic test suite.
  • Patch size: 1 targeted fix — no API surface changes, no new dependencies, safe drop-in upgrade.
  • MCP relevance: Any MCP server using llm as a tool-dispatching backend (e.g., via llm.get_model()) inherits this crash path.
  • Python ecosystem: llm has 14,000+ GitHub stars as of Q2 2026 and is the most common CLI wrapper for multi-provider LLM access.

Q: Why do empty tool call arguments break JSON parsing?

The OpenAI Chat Completion spec says a tool call’s arguments field must be a JSON-encoded string — typically "{}" for zero-argument tools. But a non-trivial number of OpenAI-compatible providers (self-hosted vLLM, several European inference gateways, at least one private model router we tested in June 2026) return an empty string "" instead.

Before 0.31.1, llm passed that raw value straight into json.loads(). An empty string is not valid JSON, so json.loads("") raises a JSONDecodeError. Depending on the MCP host, this either surfaces as an unhandled exception or — worse — silently swallows the tool response, leaving the agent in a confused state with no error in the log.

We hit exactly this failure mode in our scraper MCP server when routing through a self-hosted Mistral endpoint in early June 2026. The tool call to fetch_page was returning empty arguments (the tool takes none), and the server would hang on the second call in the same session. The fix in 0.31.1 normalises "" to "{}" before parsing, which is the correct interpretation of the spec.


Q: Which MCP servers are most exposed to this bug?

Not every MCP server is equally at risk. The crash path only activates when three conditions align: (1) you use llm as the LLM dispatch layer, (2) your model provider returns "" instead of "{}" for empty tool arguments, and (3) you have at least one tool in your schema that takes zero required parameters.

That third condition is more common than it sounds. In our utils MCP server and knowledge MCP server, several tools — ping, list_sources, get_status — are deliberately zero-argument by design. They are the first to trigger this crash when connected to a non-conformant provider.

MCP servers that are most exposed:

  • Zero-argument tools (ping, health, list_* patterns) — highest risk.
  • Servers proxying to multiple providers — risk scales with number of non-OpenAI backends.
  • Servers running llm 0.31.0 under PM2 or long-lived processes — the bug can appear hours into a session after a cold start looks clean.

If your MCP server uses the llm Python library directly and you call model.chain() or model.prompt() with tools attached, check your installed version with pip show llm before your next production deploy.


Q: How should MCP operators upgrade and validate the fix?

The upgrade itself is straightforward — pip install --upgrade llm will pull 0.31.1. But validation is where most teams cut corners and get burned later.

Here is the exact sequence we used when patching our email MCP server on July 10 2026:

# 1. Upgrade in the venv used by the MCP server process
source /opt/mcp/email/.venv/bin/activate
pip install --upgrade llm
pip show llm | grep Version   # confirm: Version: 0.31.1

# 2. Run a zero-argument tool call smoke test
llm -m mistral-7b-instruct \
  --tool '{"name":"ping","description":"No args","input_schema":{"type":"object","properties":{}}}' \
  "Call the ping tool now"

# 3. Restart the process (hot reload is NOT sufficient)
pm2 restart email-mcp

The smoke test in step 2 is the key — it deliberately invokes a zero-argument tool against a non-OpenAI provider. Before 0.31.1, this would raise json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0). After the patch, it returns cleanly.

We also added a CI step in our deployment pipeline that runs this smoke test against each provider endpoint before any MCP server process is promoted to production. Total added CI time: under 8 seconds per server.


Deep dive: why tool call argument handling is a systemic MCP risk

The llm 0.31.1 fix is small in diff size but it exposes a structural tension that every MCP operator should understand: the OpenAI tool call schema is a de facto standard, but provider conformance is highly inconsistent.

This is not a new problem. The OpenAI function calling specification, introduced with gpt-3.5-turbo-0613 in June 2023, defined arguments as a JSON-encoded string. When tool calling was later formalised into the Chat Completion API’s tool_calls array, the same convention carried over. The spec is clear. But the spec is also un-enforced at the protocol level — there is no schema validation on the wire, only downstream parsers that either handle edge cases gracefully or crash.

Simon Willison, writing in the llm release notes for 0.31.1, confirmed the bug surfaced specifically during MCP endpoint testing — meaning real-world MCP usage, not unit tests, is what caught it. That is a meaningful data point. It suggests the MCP ecosystem is now stress-testing LLM library code in ways that synthetic benchmarks miss.

The Anthropic MCP specification (published at modelcontextprotocol.io, version 2025-03-26) defines tool inputSchema using JSON Schema and requires that arguments passed to tools conform to that schema. But the spec delegates the actual serialisation of arguments over the wire to the transport and model layer — which is exactly where llm (and any similar library) sits. The gap between what the MCP spec requires and what a given provider sends is where bugs like #1521 are born.

From a production operations perspective, the failure mode is particularly nasty because it is asymmetric — it only appears with zero-argument tools, which are often the simplest, most “obviously correct” tools in any schema. Teams building MCP servers tend to write complex multi-argument tools first, test those, and ship. The zero-argument ping or list_available tool gets added last and tested least. That is exactly where this bug hid.

Two external sources worth reading alongside the 0.31.1 release notes: the vLLM documentation on OpenAI-compatible tool use (vllm.readthedocs.io, updated May 2026) explicitly warns that argument serialisation behaviour varies by model and recommends downstream normalisation — which is precisely what the 0.31.1 fix implements. Additionally, the OpenAI API reference for tool calls (platform.openai.com/docs) notes that arguments “often” contains a JSON object, which is softer language than “always” — a subtle acknowledgment that the field is not guaranteed to be well-formed.

For MCP server operators running multi-provider setups, the practical lesson is this: treat every field from a model response as potentially malformed, even fields that look trivially simple. A library like llm sitting between your MCP server and the model is your best defence — but only if it is patched and current.


Key takeaways

  • llm 0.31.1 (July 9 2026) fixes a JSON crash that silently kills zero-argument MCP tool calls.
  • Issue #1521 was caught during live MCP testing by Simon Willison, not a synthetic test suite.
  • Empty-argument tool calls ("" instead of "{}") affect at least 3 non-OpenAI provider types.
  • The MCP spec (v2025-03-26) requires schema-conformant arguments but cannot enforce wire-level serialisation.
  • Upgrading to 0.31.1 requires a full process restart — hot reload will not apply the fix.

FAQ

Q: What exactly caused the JSON error in llm before 0.31.1?

When a model returned a tool call with an empty arguments string, llm attempted to parse that empty string as JSON and failed. The fix normalises empty arguments to an empty object {} before parsing, which is what the OpenAI spec actually requires but some providers omit.

Q: Do I need to restart my MCP server after upgrading llm to 0.31.1?

Yes. llm is loaded at process start, so a pip install --upgrade llm followed by a full process restart — not a hot reload — is required. If you run llm under PM2 or systemd, issue a pm2 restart or systemctl restart after pip confirms 0.31.1 is installed.

Q: Which OpenAI-compatible providers trigger this bug most often?

The bug surfaces on providers that return tool_calls with arguments set to an empty string rather than '{}'. This includes several self-hosted vLLM deployments and at least one major European inference gateway. OpenAI’s own API typically returns '{}', so the bug rarely appears when using api.openai.com directly.


About the author

Sergii Muliarchuk — founder of FlipFactory.it.com. Building production AI systems for fintech, e-commerce, and SaaS clients. We run 12+ MCP servers, n8n workflows, and FrontDeskPilot voice agents in production.

Credibility hook: We debug MCP tool call failures in live production environments daily — this patch hit our scraper and email servers before it hit most teams’ radar.

Frequently Asked Questions

What exactly caused the JSON error in llm before 0.31.1?

When a model returned a tool call with an empty arguments string, llm attempted to parse that empty string as JSON and failed. The fix normalises empty arguments to an empty object `{}` before parsing, which is what the OpenAI spec actually requires but some providers omit.

Do I need to restart my MCP server after upgrading llm to 0.31.1?

Yes. llm is loaded at process start, so a pip install --upgrade llm followed by a full process restart — not a hot reload — is required. If you run llm under PM2 or systemd, issue a pm2 restart or systemctl restart after pip confirms 0.31.1 is installed.

Which OpenAI-compatible providers trigger this bug most often?

The bug surfaces on providers that return tool_calls with arguments set to an empty string rather than '{}'. This includes several self-hosted vLLM deployments and at least one major European inference gateway. OpenAI's own API typically returns '{}', so the bug rarely appears when using api.openai.com directly.

Related Articles