Skip to content

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

TypeScript

fix(mcp-host): grant the authorize envelope control-api's allowance (#739)

Alfredo Lopez33db6e0e03b9
diff --git a/mcp-host/package-lock.json b/mcp-host/package-lock.json
index b43335b96..beedfb322 100644
--- a/mcp-host/package-lock.json
+++ b/mcp-host/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "clerum-mcp-host",
- "version": "0.1.415",
+ "version": "0.1.416",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "clerum-mcp-host",
- "version": "0.1.415",
+ "version": "0.1.416",
"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 18c821c42..5a886a607 100644
--- a/mcp-host/package.json
+++ b/mcp-host/package.json
@@ -1,6 +1,6 @@
{
"name": "clerum-mcp-host",
- "version": "0.1.415",
+ "version": "0.1.416",
"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/providerAttemptAuthorizer.ts b/mcp-host/src/llm/providerAttemptAuthorizer.ts
index e1feb9cbc..4fca9c452 100644
--- a/mcp-host/src/llm/providerAttemptAuthorizer.ts
+++ b/mcp-host/src/llm/providerAttemptAuthorizer.ts
@@ -1,10 +1,20 @@
import {
+ LIMITS,
parseAuthorizeAttemptResponse,
requestBodyLimitBytes,
} from '@clerum/llm-provider-attempt-contract'
export const AUTHORIZE_PATH = '/api/v1/mcp-host/llm/provider-attempts/authorize'
+/**
+ * Room for the authorize envelope around the contract-capped `request`: ids,
+ * revisions, hashes and recipe names, a few hundred bytes in practice. It
+ * equals control-api's `AUTHORIZE_ENVELOPE_ALLOWANCE_BYTES`
+ * (`llmProviderAttemptAuthorizer.ts`), so a request control-api would accept
+ * is never refused here for its envelope (#739).
+ */
+export const AUTHORIZE_ENVELOPE_ALLOWANCE_BYTES = 16 * 1024
+
export class CodexAuthorizeError extends Error {
constructor(
readonly code: string,
@@ -80,11 +90,17 @@ export class ProviderAttemptAuthorizer {
expiresAt: string
}> {
const serialized = JSON.stringify(body)
- const bodyLimit = requestBodyLimitBytes(body.request)
+ const requestLimit = requestBodyLimitBytes(body.request)
+ // The larger of the two budgets wins, as in control-api's authorizer: the
+ // non-image cap plus the envelope allowance, or the V2 visual envelope.
+ const bodyLimit = Math.max(
+ requestLimit,
+ LIMITS.maxRequestBodyBytes + AUTHORIZE_ENVELOPE_ALLOWANCE_BYTES
+ )
if (Buffer.byteLength(serialized, 'utf8') > bodyLimit) {
throw new CodexAuthorizeError(
'payload_too_large',
- `Codex request exceeds ${bodyLimit / (1024 * 1024)} MiB; use fewer or smaller images, or reduce context`
+ `Codex request exceeds ${requestLimit / (1024 * 1024)} MiB; use fewer or smaller images, or reduce context`
)
}
const jwt = this.options.readPlatformJwt()