Skip to content

Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure

TypeScript

fix(mcp-host): tell the operator what to do when xAI refuses the client version

Jose Gabriel Ramirez Encinas723b631742be
diff --git a/mcp-host/package-lock.json b/mcp-host/package-lock.json
index 3d480e944..ab901ab32 100644
--- a/mcp-host/package-lock.json
+++ b/mcp-host/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "clerum-mcp-host",
- "version": "0.1.345",
+ "version": "0.1.346",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "clerum-mcp-host",
- "version": "0.1.345",
+ "version": "0.1.346",
"license": "SEE LICENSE IN LICENSE",
"dependencies": {
"@anthropic-ai/sdk": "^0.32.0",
diff --git a/mcp-host/package.json b/mcp-host/package.json
index affdcfd6f..57b9f0478 100644
--- a/mcp-host/package.json
+++ b/mcp-host/package.json
@@ -1,6 +1,6 @@
{
"name": "clerum-mcp-host",
- "version": "0.1.345",
+ "version": "0.1.346",
"description": "MCP Host - reads Host CRD and provides LLM access via OpenAI/Claude",
"main": "dist/main.js",
"engines": {
diff --git a/mcp-host/src/llm/__tests__/grokLlmProxyClient.test.ts b/mcp-host/src/llm/__tests__/grokLlmProxyClient.test.ts
index 86b0792b1..bb707409a 100644
--- a/mcp-host/src/llm/__tests__/grokLlmProxyClient.test.ts
+++ b/mcp-host/src/llm/__tests__/grokLlmProxyClient.test.ts
@@ -1,5 +1,9 @@
import { describe, expect, it, vi } from 'vitest'
-import { GrokLlmProxyClient, resolveGrokProxyRuntimeUrl } from '../grokLlmProxyClient'
+import {
+ GrokLlmProxyClient,
+ grokProxyErrorMessage,
+ resolveGrokProxyRuntimeUrl,
+} from '../grokLlmProxyClient'
const RUNTIME_BASE = 'http://grok-llm-proxy.control-plane.svc.cluster.local:8080'
const RUNTIME_URL = `${RUNTIME_BASE}/internal/runtime/v1/grok/completions`
@@ -195,4 +199,19 @@ describe('GrokLlmProxyClient', () => {
dispatched: true,
})
})
+
+ // The operator, not a retry, has to resolve xAI's client-version floor, so
+ // the surfaced text must say what to do instead of a bare status code.
+ it('surfaces an actionable message when the proxy reports client_upgrade_required', async () => {
+ expect(grokProxyErrorMessage('client_upgrade_required', 426)).toMatch(
+ /newer Grok client version[\s\S]*Contact support/i
+ )
+ expect(grokProxyErrorMessage('client_upgrade_required', 426)).not.toMatch(
+ /proxy stream failed/i
+ )
+ expect(grokProxyErrorMessage('provider_unavailable', 503)).toBe(
+ 'proxy stream failed with 503 (provider_unavailable)'
+ )
+ expect(grokProxyErrorMessage('ticket_expired')).toBe('proxy stream failed with ticket_expired')
+ })
})
diff --git a/mcp-host/src/llm/grokLlmProxyClient.ts b/mcp-host/src/llm/grokLlmProxyClient.ts
index c48f67181..4955604c3 100644
--- a/mcp-host/src/llm/grokLlmProxyClient.ts
+++ b/mcp-host/src/llm/grokLlmProxyClient.ts
@@ -1,5 +1,18 @@
export const GROK_PROXY_COMPLETIONS_PATH = '/internal/runtime/v1/grok/completions'
+/**
+ * Operator-facing text for a proxy denial. Codes an operator must act on get a
+ * sentence that says what to do; everything else keeps the diagnostic shape.
+ */
+export function grokProxyErrorMessage(code: string, status?: number): string {
+ if (code === 'client_upgrade_required') {
+ return 'Grok subscription inference is unavailable: xAI requires a newer Grok client version than this Evenfire build presents. Contact support to upgrade — retrying will not help.'
+ }
+ return status === undefined
+ ? `proxy stream failed with ${code}`
+ : `proxy stream failed with ${status} (${code})`
+}
+
export class GrokProxyError extends Error {
/**
* `dispatched` records whether a request had already left this process when
@@ -95,7 +108,7 @@ export class GrokLlmProxyClient {
}
const payload = (await response.json().catch(() => ({}))) as Record<string, unknown>
const code = typeof payload.error === 'string' ? payload.error : 'provider_unavailable'
- throw new GrokProxyError(code, `proxy stream failed with ${response.status} (${code})`)
+ throw new GrokProxyError(code, grokProxyErrorMessage(code, response.status))
}
if (!response.body) {
throw new GrokProxyError('provider_unavailable', 'proxy stream had no body')
@@ -129,7 +142,7 @@ async function readProxySse(body: ReadableStream<Uint8Array>): Promise<GrokProxy
if (!line) continue
const frame = JSON.parse(line.slice(6)) as GrokProxyFrame
if (frame.type === 'error') {
- throw new GrokProxyError(frame.code, `proxy stream failed with ${frame.code}`)
+ throw new GrokProxyError(frame.code, grokProxyErrorMessage(frame.code))
}
if (frame.type === 'text') text += frame.text
if (frame.type === 'tool_call') toolCalls.push(frame)