{"record":{"id":"b8845e8705af79cd","repo":"langchain-ai/deepagents","slug":"server-server-name-field-name-must-be-a-li","errorCode":null,"errorMessage":"Server '{server_name}' '{field_name}' must be a list of strings","messagePattern":"Server '(.+?)' '(.+?)' must be a list of strings","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"libs/code/deepagents_code/mcp_tools.py","lineNumber":1000,"sourceCode":"    has_disabled = \"disabledTools\" in server_config\n    if has_allowed and has_disabled:\n        error_msg = (\n            f\"Server '{server_name}' cannot set both 'allowedTools' and\"\n            \" 'disabledTools' — pick one.\"\n        )\n        raise ValueError(error_msg)\n\n    for field_name in (\"allowedTools\", \"disabledTools\"):\n        if field_name not in server_config:\n            continue\n        value = server_config[field_name]\n        if not isinstance(value, list) or not all(\n            isinstance(item, str) for item in value\n        ):\n            error_msg = (\n                f\"Server '{server_name}' '{field_name}' must be a list of strings\"\n            )\n            raise TypeError(error_msg)\n        if not value:\n            error_msg = (\n                f\"Server '{server_name}' '{field_name}' must be non-empty;\"\n                \" omit the field to disable filtering.\"\n            )\n            raise ValueError(error_msg)\n\n\ndef _looks_like_comment(doc: str, lineno: int) -> bool:\n    \"\"\"Return `True` if the offending line *begins* with `//` or `/*`.\n\n    Only the failing line is checked, and only its leading characters (after\n    stripping indentation). A `url` value such as `\"url\": \"https://...\"`\n    begins with a quote, not `//`, so a URL scheme inside a quoted string\n    never triggers a false comment hint.\n\n    Args:\n        doc: Full source text that failed to parse.","sourceCodeStart":982,"sourceCodeEnd":1018,"githubUrl":"https://github.com/langchain-ai/deepagents/blob/a1af029e6e73cb17c36bff823d227747b28e91e1/libs/code/deepagents_code/mcp_tools.py#L982-L1018","documentation":"When a server config defines `allowedTools` or `disabledTools`, the value must be a list containing only strings. `_validate_tool_filter_fields` raises this TypeError when the field is a non-list (e.g. a string or dict) or when any element is not a string. It's a config schema check that runs before any MCP server is contacted.","triggerScenarios":"Server config with a non-list value like \"allowedTools\": \"read_file\" (string instead of list), or a list with non-string entries like \"disabledTools\": [\"write_file\", 42] or [\"tool\", null].","commonSituations":"Hand-edited JSON where quotes around a single tool name were dropped; YAML-derived configs where a single-item list becomes a scalar; programmatic config generation that inserts tool IDs as integers; copying an object of tool->settings instead of an array of names.","solutions":["Wrap the value in a JSON array of strings: \"allowedTools\": [\"read_file\"].","Remove or stringify non-string elements (numbers, booleans, null) from the list.","If the field is not needed, delete the key entirely rather than passing an empty or malformed value."],"exampleFix":"// before\n{\"mcpServers\": {\"fs\": {\"command\": \"mcp-server-fs\", \"allowedTools\": \"read_file\"}}}\n// after\n{\"mcpServers\": {\"fs\": {\"command\": \"mcp-server-fs\", \"allowedTools\": [\"read_file\"]}}}","handlingStrategy":"validation","validationCode":"def check_filter_value(server, field):\n    value = server.get(field)\n    if value is not None and not (isinstance(value, list) and all(isinstance(i, str) for i in value)):\n        raise TypeError(f\"{field} must be a list of strings\")","typeGuard":"def is_str_list(value: object) -> bool:\n    return isinstance(value, list) and all(isinstance(i, str) for i in value)","tryCatchPattern":"try:\n    load_mcp_config(path)\nexcept TypeError as e:\n    if \"must be a list of strings\" in str(e):\n        repair_filter_field(path, server_name=e, field=...)\n    else:\n        raise","preventionTips":["Always write tool filters as JSON arrays of quoted strings, even for a single tool.","Generate configs with typed builders instead of hand-editing JSON.","Keep tool-name lists next to the tool definitions to avoid copy drift."],"tags":["config","mcp","type-error","validation"],"backgroundTag":"schema-validation-failed","analyzedSha":"a1af029e6e73cb17c36bff823d227747b28e91e1","analyzedAt":"2026-08-29T11:43:24.718Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}