From 415920e17c09dedfa02ed7e9fc9d2af8c51f126e Mon Sep 17 00:00:00 2001 From: oijkn Date: Thu, 19 Mar 2026 15:44:06 +0100 Subject: [PATCH] =?UTF-8?q?=EF=BB=BFfix:=20replace=20tuple[str,=20int]=20w?= =?UTF-8?q?ith=20list[int=20|=20str]=20in=20ports=20schema?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit  tuple[str, int] generates an array schema without an `items` field in JSON Schema, which is invalid and causes a 400 error when the tool is registered with AI APIs (e.g. OpenAI, Anthropic): Invalid schema for function 'docker-create_container': In context=('properties', 'ports', 'anyOf', '0', 'additionalProperties', 'anyOf', '2'), array schema missing items. Replace with list[int | str] which correctly generates: {"type": "array", "items": {"anyOf": [{"type": "integer"}, {"type": "string"}]}} The Docker SDK accepts both int and "host_ip:port" string formats for port bindings, so list[int | str] is semantically equivalent. --- src/mcp_server_docker/input_schemas.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mcp_server_docker/input_schemas.py b/src/mcp_server_docker/input_schemas.py index c912d0e..2a2e94d 100644 --- a/src/mcp_server_docker/input_schemas.py +++ b/src/mcp_server_docker/input_schemas.py @@ -96,7 +96,7 @@ class CreateContainerInput(JSONParsingModel): environment: dict[str, str] | None = Field( None, description="Environment variables dictionary" ) - ports: dict[str, int | list[int] | tuple[str, int] | None] | None = Field( + ports: dict[str, int | list[int | str] | None] | None = Field( None, description="A map whose keys are the container port, and the values are the host port(s) to bind to.", )