{"record":{"id":"1145d9bfd8d5ed04","repo":"vercel/ai","slug":"deepagents-mcp-server-json-stringify-name-must","errorCode":null,"errorMessage":"DeepAgents MCP server ${JSON.stringify(name)} must be configured with an object value.","messagePattern":"DeepAgents MCP server (.+?) must be configured with an object value\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/harness-deepagents/src/bridge/index.ts","lineNumber":446,"sourceCode":"      saver: checkpointer,\n    });\n    return {};\n  },\n  onDestroy: async () => {\n    await closeMcpClient();\n    await removeMemorySaverSnapshot(conversationCheckpointPath);\n  },\n});\n\nasync function loadMcpTools({\n  mcpServers,\n}: {\n  mcpServers: Record<string, unknown> | undefined;\n}) {\n  if (mcpServers == null || Object.keys(mcpServers).length === 0) return [];\n  for (const [name, value] of Object.entries(mcpServers)) {\n    if (value == null || typeof value !== 'object' || Array.isArray(value)) {\n      throw new Error(\n        `DeepAgents MCP server ${JSON.stringify(name)} must be configured with an object value.`,\n      );\n    }\n  }\n  mcpClient = new MultiServerMCPClient({\n    mcpServers: mcpServers as ClientConfig['mcpServers'],\n    prefixToolNameWithServerName: true,\n    additionalToolNamePrefix: 'mcp',\n  });\n  return mcpClient.getTools();\n}\n\nasync function closeMcpClient(): Promise<void> {\n  const client = mcpClient;\n  mcpClient = undefined;\n  mcpToolNames = new Set();\n  await client?.close();\n}","sourceCodeStart":428,"sourceCodeEnd":464,"githubUrl":"https://github.com/vercel/ai/blob/69428b1f8b037e4d118fb4853428d5c4e620493c/packages/harness-deepagents/src/bridge/index.ts#L428-L464","documentation":"MCP server entries under the `mcpServers` option must each be a plain object (a MultiServerMCPClient connection config). The bridge validates every entry before constructing the client and rejects null, non-object, or array values, naming the offending server key. This prevents malformed configs from reaching `@langchain/mcp-adapters`.","triggerScenarios":"Passing `createDeepAgents({ mcpServers: { myServer: null } })`, an array value (`{ myServer: [ ... ] }`), or any non-object value (string, number, boolean) in the `mcpServers` record of the start message.","commonSituations":"YAML/JSON config where an MCP server was left empty (`server:` with no value); using array-style server lists instead of keyed objects; template/env substitution resolving to null; copying a config shape from a different MCP client that accepts arrays.","solutions":["Give each MCP server an object value, e.g. `{ mcpServers: { filesystem: { command: 'npx', args: ['-y', '@modelcontextprotocol/server-filesystem', '/tmp'] } } }`.","Remove null/empty server entries from the config instead of leaving placeholders.","Convert array-form server lists into the keyed-record form `MultiServerMCPClient` expects.","Check env/templating that fills the config isn't resolving a server entry to null or a string."],"exampleFix":"// before\ncreateDeepAgents({ mcpServers: { filesystem: null } })\n// after\ncreateDeepAgents({ mcpServers: { filesystem: { command: 'npx', args: ['-y', '@modelcontextprotocol/server-filesystem', '/tmp'] } } })","handlingStrategy":"validation","validationCode":"const entries = Object.entries(mcpServers ?? {});\nfor (const [name, value] of entries) {\n  if (value == null || typeof value !== 'object' || Array.isArray(value)) {\n    throw new Error(`MCP server \"${name}\" must be an object`);\n  }\n}","typeGuard":"function isValidMcpServerEntry(v: unknown): v is Record<string, unknown> {\n  return v != null && typeof v === 'object' && !Array.isArray(v);\n}","tryCatchPattern":"try {\n  await startSession();\n} catch (error) {\n  if (error instanceof Error && error.message.includes('must be configured with an object value')) {\n    // fix the named mcpServers entry in config\n  }\n  throw error;\n}","preventionTips":["Validate mcpServers config at load time","Never leave null/empty placeholders for servers","Use the keyed-record shape MultiServerMCPClient expects","Check env/templating that fills server values"],"tags":["mcp","config-validation","schema"],"backgroundTag":"invalid-config-value","analyzedSha":"69428b1f8b037e4d118fb4853428d5c4e620493c","analyzedAt":"2026-08-30T12:32:21.016Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}