{"record":{"id":"03669eb8f3621408","repo":"langchain-ai/deepagents","slug":"server-server-name-field-name-must-be-non","errorCode":null,"errorMessage":"Server '{server_name}' '{field_name}' must be non-empty; omit the field to disable filtering.","messagePattern":"Server '(.+?)' '(.+?)' must be non-empty; omit the field to disable filtering\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"libs/code/deepagents_code/mcp_tools.py","lineNumber":1006,"sourceCode":"        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.\n        lineno: 1-based line number of the error; out-of-range values\n            return `False`.\n\n    Returns:\n        `True` when the stripped failing line starts with `//` or `/*`.\n    \"\"\"","sourceCodeStart":988,"sourceCodeEnd":1024,"githubUrl":"https://github.com/langchain-ai/deepagents/blob/a1af029e6e73cb17c36bff823d227747b28e91e1/libs/code/deepagents_code/mcp_tools.py#L988-L1024","documentation":"An `allowedTools` or `disabledTools` field present in a server config must contain at least one tool name. An empty list is treated as a config mistake rather than 'filter nothing', so `_validate_tool_filter_fields` raises this ValueError with a hint: omit the field entirely if you don't want filtering.","triggerScenarios":"Server config like {\"mcpServers\": {\"fs\": {\"command\": \"mcp-server-fs\", \"allowedTools\": []}}} — the key exists but the list is empty, raised during _validate_server_config.","commonSituations":"Programmatic config builders that initialize the key to [] and never populate it; UIs that let users deselect all tools and serialize the empty selection; cleaning up a config by deleting the tool names but leaving the key.","solutions":["Populate the list with at least one tool name, e.g. \"allowedTools\": [\"read_file\"].","Delete the empty 'allowedTools'/'disabledTools' key from the server config to disable filtering.","In programmatic builders, only emit the key when the list is non-empty."],"exampleFix":"// before\n{\"mcpServers\": {\"fs\": {\"command\": \"mcp-server-fs\", \"disabledTools\": []}}}\n// after (filtering disabled entirely)\n{\"mcpServers\": {\"fs\": {\"command\": \"mcp-server-fs\"}}}","handlingStrategy":"validation","validationCode":"def check_filter_nonempty(server, field):\n    if field in server and not server[field]:\n        del server[field]  # or raise: empty list means 'omit the field'","typeGuard":"def is_empty_filter(server: dict, field: str) -> bool:\n    return server.get(field) == []","tryCatchPattern":"try:\n    load_mcp_config(path)\nexcept ValueError as e:\n    if \"must be non-empty\" in str(e):\n        strip_empty_filter_keys(path)\n    else:\n        raise","preventionTips":["Omit the key entirely when you don't want filtering; never serialize empty lists.","In UIs/builders, drop the field when the user selects zero tools.","Lint the config: flag any empty-array value."],"tags":["config","mcp","validation","tool-filtering"],"backgroundTag":"empty-list-config","analyzedSha":"a1af029e6e73cb17c36bff823d227747b28e91e1","analyzedAt":"2026-08-29T11:43:24.718Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}