@@ -46,72 +46,6 @@ async def __call__(self, *args, **kwargs):
4646from mcp .server .streamable_http_manager import StreamableHTTPSessionManager
4747from starlette .routing import Mount
4848from starlette .applications import Starlette
49- from starlette .testclient import TestClient
50-
51-
52- def json_rpc (app , method : str , params , request_id : str ):
53- with TestClient (app ) as client :
54- init_response = client .post (
55- "/mcp/" ,
56- headers = {
57- "Accept" : "application/json, text/event-stream" ,
58- "Content-Type" : "application/json" ,
59- },
60- json = {
61- "jsonrpc" : "2.0" ,
62- "method" : "initialize" ,
63- "params" : {
64- "clientInfo" : {"name" : "test-client" , "version" : "1.0" },
65- "protocolVersion" : "2025-11-25" ,
66- "capabilities" : {},
67- },
68- "id" : request_id ,
69- },
70- )
71-
72- session_id = init_response .headers ["mcp-session-id" ]
73-
74- # Notification response is mandatory.
75- # https://modelcontextprotocol.io/specification/2025-11-25/basic/lifecycle
76- client .post (
77- "/mcp/" ,
78- headers = {
79- "Accept" : "application/json, text/event-stream" ,
80- "Content-Type" : "application/json" ,
81- "mcp-session-id" : session_id ,
82- },
83- json = {
84- "jsonrpc" : "2.0" ,
85- "method" : "notifications/initialized" ,
86- "params" : {},
87- },
88- )
89-
90- response = client .post (
91- "/mcp/" ,
92- headers = {
93- "Accept" : "application/json, text/event-stream" ,
94- "Content-Type" : "application/json" ,
95- "mcp-session-id" : session_id ,
96- },
97- json = {
98- "jsonrpc" : "2.0" ,
99- "method" : method ,
100- "params" : params ,
101- "id" : request_id ,
102- },
103- )
104-
105- return session_id , response
106-
107-
108- def select_mcp_transactions (events ):
109- return [
110- event
111- for event in events
112- if event ["type" ] == "transaction"
113- and event ["contexts" ]["trace" ]["op" ] == "mcp.server"
114- ]
11549
11650
11751@pytest .fixture (autouse = True )
0 commit comments