55import pytest
66from mcp_types import URL_ELICITATION_REQUIRED , ElicitRequestURLParams , ErrorData , JSONRPCError
77
8- from mcp .shared .exceptions import MCPError , UrlElicitationRequiredError
8+ from mcp .shared .exceptions import MCPError , NoBackChannelError , UrlElicitationRequiredError
99
1010
1111def test_url_elicitation_required_error_create_with_single_elicitation () -> None :
@@ -184,7 +184,21 @@ def test_mcp_error_pickle_roundtrip() -> None:
184184 restored = pickle .loads (pickle .dumps (original ))
185185
186186 assert type (restored ) is MCPError
187+ assert restored .args == original .args
187188 assert restored .error == original .error
189+ assert str (restored ) == str (original )
190+
191+
192+ def test_no_back_channel_error_pickle_roundtrip_preserves_method () -> None :
193+ """NoBackChannelError preserves its method and structured payload when pickled."""
194+ original = NoBackChannelError ("sampling/createMessage" )
195+
196+ restored = pickle .loads (pickle .dumps (original ))
197+
198+ assert isinstance (restored , NoBackChannelError )
199+ assert restored .args == original .args
200+ assert restored .error == original .error
201+ assert restored .method == original .method
188202
189203
190204def test_url_elicitation_required_error_pickle_roundtrip () -> None :
@@ -208,5 +222,6 @@ def test_url_elicitation_required_error_pickle_roundtrip() -> None:
208222 restored = pickle .loads (pickle .dumps (original ))
209223
210224 assert type (restored ) is UrlElicitationRequiredError
225+ assert restored .args == original .args
211226 assert restored .error == original .error
212227 assert restored .elicitations == original .elicitations
0 commit comments