@@ -14,7 +14,7 @@ class HTTPNotificationIntegrationTest < ActiveSupport::TestCase
14
14
name : "test_server" ,
15
15
tools : [ ] ,
16
16
prompts : [ ] ,
17
- resources : [ ]
17
+ resources : [ ] ,
18
18
)
19
19
@transport = HTTP . new ( @server )
20
20
@server . transport = @transport
@@ -26,7 +26,7 @@ class HTTPNotificationIntegrationTest < ActiveSupport::TestCase
26
26
"POST" ,
27
27
"/" ,
28
28
{ "CONTENT_TYPE" => "application/json" } ,
29
- { jsonrpc : "2.0" , method : "initialize" , id : "init" } . to_json
29
+ { jsonrpc : "2.0" , method : "initialize" , id : "init" } . to_json ,
30
30
)
31
31
init_response = @transport . handle_request ( init_request )
32
32
session_id = init_response [ 1 ] [ "Mcp-Session-Id" ]
@@ -36,7 +36,7 @@ class HTTPNotificationIntegrationTest < ActiveSupport::TestCase
36
36
get_request = create_rack_request (
37
37
"GET" ,
38
38
"/" ,
39
- { "HTTP_MCP_SESSION_ID" => session_id }
39
+ { "HTTP_MCP_SESSION_ID" => session_id } ,
40
40
)
41
41
response = @transport . handle_request ( get_request )
42
42
response [ 2 ] . call ( io ) if response [ 2 ] . is_a? ( Proc )
@@ -68,7 +68,7 @@ class HTTPNotificationIntegrationTest < ActiveSupport::TestCase
68
68
"POST" ,
69
69
"/" ,
70
70
{ "CONTENT_TYPE" => "application/json" } ,
71
- { jsonrpc : "2.0" , method : "initialize" , id : "123" } . to_json
71
+ { jsonrpc : "2.0" , method : "initialize" , id : "123" } . to_json ,
72
72
)
73
73
init_response1 = @transport . handle_request ( init_request1 )
74
74
session_id1 = init_response1 [ 1 ] [ "Mcp-Session-Id" ]
@@ -77,7 +77,7 @@ class HTTPNotificationIntegrationTest < ActiveSupport::TestCase
77
77
"POST" ,
78
78
"/" ,
79
79
{ "CONTENT_TYPE" => "application/json" } ,
80
- { jsonrpc : "2.0" , method : "initialize" , id : "456" } . to_json
80
+ { jsonrpc : "2.0" , method : "initialize" , id : "456" } . to_json ,
81
81
)
82
82
init_response2 = @transport . handle_request ( init_request2 )
83
83
session_id2 = init_response2 [ 1 ] [ "Mcp-Session-Id" ]
@@ -87,7 +87,7 @@ class HTTPNotificationIntegrationTest < ActiveSupport::TestCase
87
87
get_request1 = create_rack_request (
88
88
"GET" ,
89
89
"/" ,
90
- { "HTTP_MCP_SESSION_ID" => session_id1 }
90
+ { "HTTP_MCP_SESSION_ID" => session_id1 } ,
91
91
)
92
92
response1 = @transport . handle_request ( get_request1 )
93
93
response1 [ 2 ] . call ( io1 ) if response1 [ 2 ] . is_a? ( Proc )
@@ -96,7 +96,7 @@ class HTTPNotificationIntegrationTest < ActiveSupport::TestCase
96
96
get_request2 = create_rack_request (
97
97
"GET" ,
98
98
"/" ,
99
- { "HTTP_MCP_SESSION_ID" => session_id2 }
99
+ { "HTTP_MCP_SESSION_ID" => session_id2 } ,
100
100
)
101
101
response2 = @transport . handle_request ( get_request2 )
102
102
response2 [ 2 ] . call ( io2 ) if response2 [ 2 ] . is_a? ( Proc )
@@ -123,7 +123,7 @@ class HTTPNotificationIntegrationTest < ActiveSupport::TestCase
123
123
"POST" ,
124
124
"/" ,
125
125
{ "CONTENT_TYPE" => "application/json" } ,
126
- { jsonrpc : "2.0" , method : "initialize" , id : "init" } . to_json
126
+ { jsonrpc : "2.0" , method : "initialize" , id : "init" } . to_json ,
127
127
)
128
128
init_response = @transport . handle_request ( init_request )
129
129
session_id = init_response [ 1 ] [ "Mcp-Session-Id" ]
@@ -133,7 +133,7 @@ class HTTPNotificationIntegrationTest < ActiveSupport::TestCase
133
133
get_request = create_rack_request (
134
134
"GET" ,
135
135
"/" ,
136
- { "HTTP_MCP_SESSION_ID" => session_id }
136
+ { "HTTP_MCP_SESSION_ID" => session_id } ,
137
137
)
138
138
response = @transport . handle_request ( get_request )
139
139
response [ 2 ] . call ( io ) if response [ 2 ] . is_a? ( Proc )
@@ -158,7 +158,7 @@ class HTTPNotificationIntegrationTest < ActiveSupport::TestCase
158
158
"POST" ,
159
159
"/" ,
160
160
{ "CONTENT_TYPE" => "application/json" } ,
161
- { jsonrpc : "2.0" , method : "initialize" , id : "init" } . to_json
161
+ { jsonrpc : "2.0" , method : "initialize" , id : "init" } . to_json ,
162
162
)
163
163
init_response = @transport . handle_request ( init_request )
164
164
session_id = init_response [ 1 ] [ "Mcp-Session-Id" ]
@@ -168,7 +168,7 @@ class HTTPNotificationIntegrationTest < ActiveSupport::TestCase
168
168
get_request = create_rack_request (
169
169
"GET" ,
170
170
"/" ,
171
- { "HTTP_MCP_SESSION_ID" => session_id }
171
+ { "HTTP_MCP_SESSION_ID" => session_id } ,
172
172
)
173
173
response = @transport . handle_request ( get_request )
174
174
response [ 2 ] . call ( io ) if response [ 2 ] . is_a? ( Proc )
@@ -179,8 +179,8 @@ class HTTPNotificationIntegrationTest < ActiveSupport::TestCase
179
179
# Define a new tool (simulating dynamic tool addition)
180
180
@server . define_tool (
181
181
name : "dynamic_tool" ,
182
- description : "A dynamically added tool"
183
- ) do |**args |
182
+ description : "A dynamically added tool" ,
183
+ ) do |**_args |
184
184
{ result : "success" }
185
185
end
186
186
@@ -202,7 +202,7 @@ class HTTPNotificationIntegrationTest < ActiveSupport::TestCase
202
202
"POST" ,
203
203
"/" ,
204
204
{ "CONTENT_TYPE" => "application/json" } ,
205
- { jsonrpc : "2.0" , method : "initialize" , id : "init" } . to_json
205
+ { jsonrpc : "2.0" , method : "initialize" , id : "init" } . to_json ,
206
206
)
207
207
init_response = @transport . handle_request ( init_request )
208
208
session_id = init_response [ 1 ] [ "Mcp-Session-Id" ]
@@ -212,7 +212,7 @@ class HTTPNotificationIntegrationTest < ActiveSupport::TestCase
212
212
get_request = create_rack_request (
213
213
"GET" ,
214
214
"/" ,
215
- { "HTTP_MCP_SESSION_ID" => session_id }
215
+ { "HTTP_MCP_SESSION_ID" => session_id } ,
216
216
)
217
217
response = @transport . handle_request ( get_request )
218
218
response [ 2 ] . call ( io ) if response [ 2 ] . is_a? ( Proc )
@@ -226,7 +226,7 @@ class HTTPNotificationIntegrationTest < ActiveSupport::TestCase
226
226
# Check SSE format
227
227
io . rewind
228
228
output = io . read
229
-
229
+
230
230
# SSE format should be "data: <message>\n\n"
231
231
assert_match ( /data: #{ Regexp . escape ( Methods ::NOTIFICATIONS_TOOLS_LIST_CHANGED ) } \n / , output )
232
232
end
@@ -237,11 +237,11 @@ def create_rack_request(method, path, headers, body = nil)
237
237
env = {
238
238
"REQUEST_METHOD" => method ,
239
239
"PATH_INFO" => path ,
240
- "rack.input" => StringIO . new ( body . to_s )
240
+ "rack.input" => StringIO . new ( body . to_s ) ,
241
241
} . merge ( headers )
242
242
243
243
Rack ::Request . new ( env )
244
244
end
245
245
end
246
246
end
247
- end
247
+ end
0 commit comments