1+ import inspect
12from typing import Any
23
34import anyio
2425 ServerCapabilities ,
2526 ServerResult ,
2627)
27- import inspect
28- from mcp .client .session import ClientSession
2928
3029
3130@pytest .mark .anyio
@@ -500,25 +499,23 @@ async def mock_server():
500499 assert isinstance (received_capabilities .roots , types .RootsCapability )
501500 assert received_capabilities .roots .listChanged is True # Should be True for custom callback
502501
502+
503503def test_call_tool_method_signature ():
504504 """Test that call_tool method accepts meta parameter in its signature."""
505505
506506 signature = inspect .signature (ClientSession .call_tool )
507507
508- assert ' meta' in signature .parameters , "call_tool method should have 'meta' parameter"
508+ assert " meta" in signature .parameters , "call_tool method should have 'meta' parameter"
509509
510- meta_param = signature .parameters [' meta' ]
510+ meta_param = signature .parameters [" meta" ]
511511 assert meta_param .default is None , "meta parameter should default to None"
512512
513513
514514def test_call_tool_request_params_construction ():
515515 """Test that CallToolRequestParams can be constructed with metadata."""
516516 from mcp .types import CallToolRequestParams , RequestParams
517517
518- params_no_meta = CallToolRequestParams (
519- name = "test_tool" ,
520- arguments = {"param" : "value" }
521- )
518+ params_no_meta = CallToolRequestParams (name = "test_tool" , arguments = {"param" : "value" })
522519 assert params_no_meta .name == "test_tool"
523520 assert params_no_meta .arguments == {"param" : "value" }
524521 assert params_no_meta .meta is None
@@ -527,14 +524,14 @@ def test_call_tool_request_params_construction():
527524 "progressToken" : None ,
528525 "user_id" : "test_user" ,
529526 "session_id" : "test_session" ,
530- "custom_field" : "custom_value"
527+ "custom_field" : "custom_value" ,
531528 }
532529 test_meta = RequestParams .Meta .model_validate (meta_data )
533530
534531 params_with_meta = CallToolRequestParams (
535532 name = "test_tool" ,
536533 arguments = {"param" : "value" },
537- ** {"_meta" : test_meta } # Using alias
534+ ** {"_meta" : test_meta }, # Using alias
538535 )
539536
540537 assert params_with_meta .name == "test_tool"
@@ -551,21 +548,12 @@ def test_metadata_serialization():
551548 """Test that metadata is properly serialized with _meta alias."""
552549 from mcp .types import CallToolRequest , CallToolRequestParams , RequestParams
553550
554- meta_data = {
555- "progressToken" : None ,
556- "user_id" : "alice" ,
557- "api_key" : "secret_123" ,
558- "permissions" : ["read" , "write" ]
559- }
551+ meta_data = {"progressToken" : None , "user_id" : "alice" , "api_key" : "secret_123" , "permissions" : ["read" , "write" ]}
560552 test_meta = RequestParams .Meta .model_validate (meta_data )
561553
562554 request = CallToolRequest (
563555 method = "tools/call" ,
564- params = CallToolRequestParams (
565- name = "secure_tool" ,
566- arguments = {"query" : "sensitive_data" },
567- ** {"_meta" : test_meta }
568- )
556+ params = CallToolRequestParams (name = "secure_tool" , arguments = {"query" : "sensitive_data" }, ** {"_meta" : test_meta }),
569557 )
570558
571559 serialized = request .model_dump (by_alias = True )
0 commit comments