{"record":{"id":"74db22a45d9f7ead","repo":"rohitg00/ai-engineering-from-scratch","slug":"completion-complete-requires-a-completion-object","errorCode":null,"errorMessage":"completion/complete requires a completion object","messagePattern":"completion/complete requires a completion object","errorType":"validation","errorClass":"ProtocolViolation","httpStatus":null,"severity":"error","filePath":"phases/13-tools-and-protocols/31-mcp-conformance-versioning-and-operations/code/main.py","lineNumber":287,"sourceCode":"            name = tool.get(\"name\")\n            description = tool.get(\"description\")\n            input_schema = tool.get(\"inputSchema\")\n            if not isinstance(name, str) or not name:\n                raise ProtocolViolation(\"each tool descriptor requires a non-empty name\")\n            if name in names:\n                raise ProtocolViolation(\"tools/list contains a duplicate tool name\")\n            names.add(name)\n            if not isinstance(description, str) or not description:\n                raise ProtocolViolation(\"each tool descriptor requires a non-empty description\")\n            if not isinstance(input_schema, dict) or input_schema.get(\"type\") != \"object\":\n                raise ProtocolViolation(\"each tool descriptor requires an object-root inputSchema\")\n\n    if method == \"completion/complete\":\n        if result_type != \"complete\":\n            raise ProtocolViolation(\"completion/complete must return a complete result\")\n        completion = result.get(\"completion\")\n        if not isinstance(completion, dict):\n            raise ProtocolViolation(\"completion/complete requires a completion object\")\n        values = completion.get(\"values\")\n        if not isinstance(values, list) or any(not isinstance(value, str) for value in values):\n            raise ProtocolViolation(\"completion.values must be an array of strings\")\n        if len(values) > 100:\n            raise ProtocolViolation(\"completion.values must contain at most 100 entries\")\n        total = completion.get(\"total\")\n        if total is not None and (\n            isinstance(total, bool) or not isinstance(total, int) or total < len(values)\n        ):\n            raise ProtocolViolation(\"completion.total must be an integer at least values length\")\n        has_more = completion.get(\"hasMore\")\n        if has_more is not None and not isinstance(has_more, bool):\n            raise ProtocolViolation(\"completion.hasMore must be a boolean\")\n\n    if result_type != \"task\":\n        return\n    if method != \"tools/call\":\n        raise ProtocolViolation(\"task result is valid only for tools/call\")","sourceCodeStart":269,"sourceCodeEnd":305,"githubUrl":"https://github.com/rohitg00/ai-engineering-from-scratch/blob/39ea8a1c6d0b61f071226eff7ede4d4105fed820/phases/13-tools-and-protocols/31-mcp-conformance-versioning-and-operations/code/main.py#L269-L305","documentation":"Error \"completion/complete requires a completion object\" thrown in rohitg00/ai-engineering-from-scratch.","triggerScenarios":"Thrown at phases/13-tools-and-protocols/31-mcp-conformance-versioning-and-operations/code/main.py:287 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"39ea8a1c6d0b61f071226eff7ede4d4105fed820","analyzedAt":"2026-08-26T03:13:46.626Z","schemaVersion":2},"datasetVersion":"2026-08-26T07:17:17.940Z"}