Skip to content

MCP SDK logs validation warnings for vendor-prefixed notification types (e.g. codex/event) #2159

@jsj

Description

@jsj

Describe the bug

When connecting to MCP servers that send vendor-prefixed notification types (e.g., Codex CLI's codex/event), the SDK logs 20+ Pydantic validation warnings per notification to stderr:

WARNING:root:Failed to validate notification: 20 validation errors for ServerNotification
CancelledNotification.method
  Input should be 'notifications/cancelled' [type=literal_error, input_value='codex/event', input_type=str]
...

The MCP spec allows vendor-prefixed methods, and Codex MCP server intentionally emits these events for progress reporting. The SDK should handle unknown notification types gracefully.

See also: openai/codex#4223

Debug information

  • Agents SDK version: 0.6.1
  • Python version: 3.12

Repro steps

from agents.mcp import MCPServerStdio

server = MCPServerStdio(
    name="codex",
    params={"command": "codex", "args": ["mcp-server"]},
)

async with server:
    # codex/event notifications spam stderr with validation warnings
    pass

Expected behavior

Unknown/vendor-prefixed notification types should be silently ignored or exposed via an optional callback.

Workaround

import logging

class MCPNotificationFilter(logging.Filter):
    def filter(self, record: logging.LogRecord) -> bool:
        if "Failed to validate notification" in record.getMessage():
            return False
        return True

logging.getLogger().addFilter(MCPNotificationFilter())

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions