Skip to content

NewSessionRequest silently drops McpServerHttp items (no error) #203

Open

Description

@sammyawad

SDK: agent-client-protocol 1.0.0 (same on main today), Python 3.12, Windows 11.

What happens

acp.schema has both McpServerHttp (no type field) and HttpMcpServer(McpServerHttp) with type: Literal["http"]. NewSessionRequest.mcp_servers only accepts the tagged variants, and skip_invalid_items (added in #117 for lenient deserialization) silently drops a McpServerHttp instance. The agent then starts with no MCP servers, and nothing tells the caller why.

We hit this driving codex-acp through conn.new_session(..., mcp_servers=[McpServerHttp(...)]): Codex ran without its MCP server, and the only clue was a missing tool.

Repro

from acp.schema import McpServerHttp, HttpMcpServer, HttpHeader, NewSessionRequest

h = [HttpHeader(name="Authorization", value="Bearer x")]
print(NewSessionRequest(cwd="/w", mcp_servers=[McpServerHttp(name="m", url="http://127.0.0.1:1/mcp", headers=h)])
      .model_dump_json(by_alias=True))
# {"cwd":"/w","mcpServers":[]}            <- server gone, no error
print(NewSessionRequest(cwd="/w", mcp_servers=[HttpMcpServer(name="m", url="http://127.0.0.1:1/mcp", headers=h)])
      .model_dump_json(by_alias=True))
# {"cwd":"/w","mcpServers":[{"name":"m",...,"type":"http"}]}

Expected

Lenient skipping makes sense for wire data from a newer peer. For a model instance built in local code, a ValidationError (or at least a warning) would surface the mistake.

Possible fix

In _deserialize.skip_invalid_items, re-raise when the failing item is already a BaseModel instance; raw dicts from the wire keep today's lenient behaviour. Happy to send a PR with tests.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions