refactor(mcp): declare _resolved_identity in MCPServerTask's slots and init it
The transport publishes _resolved_identity and server_run resets it, but the attribute was neither in __slots__ nor set in __init__, so a task that never reached the transport raised AttributeError on read and the attribute silently lived in the mixins' __dict__. Declare it and start it at None (not shareable until the transport publishes a digest). The getattr in registration stays for test fakes that are not MCPServerTask instances.
This commit is contained in:
@@ -317,7 +317,7 @@ class MCPServerTask(MCPServerRunMixin, MCPServerTransportMixin, MCPServerHealthM
|
||||
"_recycled_reason", "initialize_result", "_ping_unsupported", "_list_cache_meta",
|
||||
"_reconnect_retries", "_session_proven", "_was_parked", "_inflight_tasks", "_reconnecting",
|
||||
"_suspect_reason", "_teardown_race", "_permanent_grace_used", "_stdio_child_pids",
|
||||
"_ever_connected", "_sse_fallback", "_park_reason", "_last_park_line")
|
||||
"_ever_connected", "_sse_fallback", "_park_reason", "_last_park_line", "_resolved_identity")
|
||||
|
||||
def __init__(self, name: str):
|
||||
self.name = name
|
||||
@@ -358,6 +358,9 @@ class MCPServerTask(MCPServerRunMixin, MCPServerTransportMixin, MCPServerHealthM
|
||||
# (revoked credentials, dead endpoint) that must not run the job tool-less forever.
|
||||
self._park_reason: Optional[str] = None
|
||||
self._last_park_line: Optional[str] = None # last park WARNING text; identical re-parks log at DEBUG
|
||||
# Digest of the resolved inputs the transport last connected with; a cross-profile adopter
|
||||
# must resolve the same digest in its own scope. None until the transport publishes it.
|
||||
self._resolved_identity: Optional[str] = None
|
||||
# In-flight RPC tasks so a deliberate teardown fails them fast; _reconnecting is True
|
||||
# during that teardown so _track_inflight_rpc turns the cancel into a retryable error.
|
||||
# In-flight RPC bookkeeping (#48069 salvage): user-visible requests registered while running so a
|
||||
|
||||
Reference in New Issue
Block a user