{"record":{"id":"f8c8877e75fea3a8","repo":"different-ai/openwork","slug":"mcp-catalog-tool-title-limit","errorCode":"MCP_CATALOG_TOOL_TITLE_LIMIT","errorMessage":"MCP_CATALOG_TOOL_TITLE_LIMIT","messagePattern":"MCP_CATALOG_TOOL_TITLE_LIMIT","errorType":"error_code","errorClass":"ExternalMcpDiagnosticError","httpStatus":null,"severity":"error","filePath":"ee/apps/den-api/src/capability-sources/external-mcp-client.ts","lineNumber":633,"sourceCode":"\nfunction measureCatalogTool(input: {\n  diagnostic: ExternalMcpDiagnosticTracker\n  tool: ExternalMcpToolPage[\"tools\"][number]\n  remainingBytes: number\n}): number {\n  validateToolCatalogField({\n    diagnostic: input.diagnostic,\n    value: input.tool.name,\n    field: \"name\",\n    limit: EXTERNAL_MCP_TOOL_NAME_LIMIT_BYTES,\n    code: \"MCP_CATALOG_TOOL_NAME_LIMIT\",\n  })\n  validateToolCatalogField({\n    diagnostic: input.diagnostic,\n    value: input.tool.title,\n    field: \"title\",\n    limit: EXTERNAL_MCP_TOOL_TITLE_LIMIT_BYTES,\n    code: \"MCP_CATALOG_TOOL_TITLE_LIMIT\",\n  })\n  validateToolCatalogField({\n    diagnostic: input.diagnostic,\n    value: input.tool.description,\n    field: \"description\",\n    limit: EXTERNAL_MCP_TOOL_DESCRIPTION_LIMIT_BYTES,\n    code: \"MCP_CATALOG_TOOL_DESCRIPTION_LIMIT\",\n  })\n  validateToolSchema({ diagnostic: input.diagnostic, schema: input.tool.inputSchema })\n  if (input.tool.outputSchema !== undefined) {\n    validateToolSchema({ diagnostic: input.diagnostic, schema: input.tool.outputSchema })\n  }\n\n  const measurement = measureSerializedJson(\n    input.tool,\n    Math.max(0, input.remainingBytes),\n    EXTERNAL_MCP_TOOL_SCHEMA_DEPTH_LIMIT + 4,\n  )","sourceCodeStart":615,"sourceCodeEnd":651,"githubUrl":"https://github.com/different-ai/openwork/blob/2b7df46e8ae1517d64c896c7793d2d52ec845669/ee/apps/den-api/src/capability-sources/external-mcp-client.ts#L615-L651","documentation":"Thrown by measureCatalogTool in external-mcp-client.ts when an external MCP server advertises a tool whose title exceeds EXTERNAL_MCP_TOOL_TITLE_LIMIT_BYTES (4 KiB of UTF-8). The gateway enforces bounded catalog fields so a single malicious or misconfigured server cannot blow up the serialized catalog or UI rendering.","triggerScenarios":"A tools/list response contains a tool whose `title` field serializes to more than 4096 UTF-8 bytes; validation runs during catalog discovery (collectExternalMcpToolPages -> measureCatalogTool).","commonSituations":"Providers auto-generating titles from long prompts or docs; misconfigured servers embedding template text into titles; servers reflecting an entire help page as the title; multilingual titles that inflate UTF-8 byte counts.","solutions":["Shorten the offending tool's `title` on the MCP server to under 4096 UTF-8 bytes","If you operate the server, truncate or rewrite titles server-side before returning tools/list","Use a scoped/narrowed MCP server that only exposes the needed tools","Check which tool failed via the diagnostic tracker output and fix it at the provider"],"exampleFix":"// before (provider server config)\n{ name: \"search\", title: `${entireDocumentationText}` }\n// after\n{ name: \"search\", title: \"Documentation Search\" }","handlingStrategy":"validation","validationCode":"function validateToolTitle(title: string): boolean {\n  return new TextEncoder().encode(title).byteLength <= 4096\n}\nif (!validateToolTitle(tool.title)) throw new Error(\"tool title exceeds 4096 UTF-8 bytes\")","typeGuard":"function hasSafeTitle(tool: { title?: string }): boolean {\n  return typeof tool.title !== \"string\" || new TextEncoder().encode(tool.title).byteLength <= 4096\n}","tryCatchPattern":"try {\n  await connectExternalMcp(...)\n} catch (err) {\n  if (err instanceof Error && err.message.includes(\"MCP_CATALOG_TOOL_TITLE_LIMIT\")) {\n    console.error(\"Provider tool title too large; fix provider server titles (<4KB)\")\n  } else throw err\n}","preventionTips":["Cap tool titles at a short human-readable length on your MCP server","Add a server-side test asserting serialized field byte sizes","Avoid templating long text into tool titles","Audit providers before onboarding them to the gateway"],"tags":["mcp","catalog-validation","byte-limit"],"backgroundTag":"payload-size-limit-exceeded","analyzedSha":"2b7df46e8ae1517d64c896c7793d2d52ec845669","analyzedAt":"2026-09-01T07:59:23.713Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}