Skip to content

Commit a8785de

Browse files
committed
Rubocop
1 parent fb2b06b commit a8785de

File tree

4 files changed

+74
-74
lines changed

4 files changed

+74
-74
lines changed

lib/mcp/transports/stdio.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,10 @@ def send_response(message)
4040
def send_notification(method, params = nil)
4141
notification = {
4242
jsonrpc: "2.0",
43-
method: method
43+
method: method,
4444
}
4545
notification[:params] = params if params
46-
46+
4747
send_response(notification)
4848
true
4949
rescue => e

test/mcp/server_notification_test.rb

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,13 @@ def handle_request(request); end
2929
setup do
3030
configuration = MCP::Configuration.new
3131
configuration.instrumentation_callback = instrumentation_helper.callback
32-
32+
3333
@server = Server.new(
3434
name: "test_server",
3535
version: "1.0.0",
36-
configuration: configuration
36+
configuration: configuration,
3737
)
38-
38+
3939
@mock_transport = MockTransport.new(@server)
4040
@server.transport = @mock_transport
4141
end
@@ -69,7 +69,7 @@ def handle_request(request); end
6969

7070
test "notification methods work without transport" do
7171
server_without_transport = Server.new(name: "test_server")
72-
72+
7373
# Should not raise any errors
7474
assert_nothing_raised do
7575
server_without_transport.notify_tools_list_changed
@@ -85,16 +85,16 @@ def send_notification(method, params = nil)
8585
raise StandardError, "Transport error"
8686
end
8787
end.new(@server)
88-
88+
8989
@server.transport = error_transport
90-
90+
9191
# Mock the exception reporter
9292
expected_contexts = [
9393
{ notification: "tools_list_changed" },
9494
{ notification: "prompts_list_changed" },
95-
{ notification: "resources_list_changed" }
95+
{ notification: "resources_list_changed" },
9696
]
97-
97+
9898
call_count = 0
9999
@server.configuration.exception_reporter.expects(:call).times(3).with do |exception, context|
100100
assert_kind_of StandardError, exception
@@ -103,14 +103,14 @@ def send_notification(method, params = nil)
103103
call_count += 1
104104
true
105105
end
106-
106+
107107
# Should not raise errors to the caller
108108
assert_nothing_raised do
109109
@server.notify_tools_list_changed
110110
@server.notify_prompts_list_changed
111111
@server.notify_resources_list_changed
112112
end
113-
113+
114114
assert_equal 3, call_count
115115
end
116116

@@ -120,7 +120,7 @@ def send_notification(method, params = nil)
120120
@server.notify_resources_list_changed
121121

122122
assert_equal 3, @mock_transport.notifications.size
123-
123+
124124
notifications = @mock_transport.notifications
125125
assert_equal Methods::NOTIFICATIONS_TOOLS_LIST_CHANGED, notifications[0][:method]
126126
assert_equal Methods::NOTIFICATIONS_PROMPTS_LIST_CHANGED, notifications[1][:method]
@@ -133,4 +133,4 @@ def send_notification(method, params = nil)
133133
assert_equal "notifications/resources/list_changed", Methods::NOTIFICATIONS_RESOURCES_LIST_CHANGED
134134
end
135135
end
136-
end
136+
end

test/mcp/transports/http_notification_integration_test.rb

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class HTTPNotificationIntegrationTest < ActiveSupport::TestCase
1414
name: "test_server",
1515
tools: [],
1616
prompts: [],
17-
resources: []
17+
resources: [],
1818
)
1919
@transport = HTTP.new(@server)
2020
@server.transport = @transport
@@ -26,7 +26,7 @@ class HTTPNotificationIntegrationTest < ActiveSupport::TestCase
2626
"POST",
2727
"/",
2828
{ "CONTENT_TYPE" => "application/json" },
29-
{ jsonrpc: "2.0", method: "initialize", id: "init" }.to_json
29+
{ jsonrpc: "2.0", method: "initialize", id: "init" }.to_json,
3030
)
3131
init_response = @transport.handle_request(init_request)
3232
session_id = init_response[1]["Mcp-Session-Id"]
@@ -36,7 +36,7 @@ class HTTPNotificationIntegrationTest < ActiveSupport::TestCase
3636
get_request = create_rack_request(
3737
"GET",
3838
"/",
39-
{ "HTTP_MCP_SESSION_ID" => session_id }
39+
{ "HTTP_MCP_SESSION_ID" => session_id },
4040
)
4141
response = @transport.handle_request(get_request)
4242
response[2].call(io) if response[2].is_a?(Proc)
@@ -68,7 +68,7 @@ class HTTPNotificationIntegrationTest < ActiveSupport::TestCase
6868
"POST",
6969
"/",
7070
{ "CONTENT_TYPE" => "application/json" },
71-
{ jsonrpc: "2.0", method: "initialize", id: "123" }.to_json
71+
{ jsonrpc: "2.0", method: "initialize", id: "123" }.to_json,
7272
)
7373
init_response1 = @transport.handle_request(init_request1)
7474
session_id1 = init_response1[1]["Mcp-Session-Id"]
@@ -77,7 +77,7 @@ class HTTPNotificationIntegrationTest < ActiveSupport::TestCase
7777
"POST",
7878
"/",
7979
{ "CONTENT_TYPE" => "application/json" },
80-
{ jsonrpc: "2.0", method: "initialize", id: "456" }.to_json
80+
{ jsonrpc: "2.0", method: "initialize", id: "456" }.to_json,
8181
)
8282
init_response2 = @transport.handle_request(init_request2)
8383
session_id2 = init_response2[1]["Mcp-Session-Id"]
@@ -87,7 +87,7 @@ class HTTPNotificationIntegrationTest < ActiveSupport::TestCase
8787
get_request1 = create_rack_request(
8888
"GET",
8989
"/",
90-
{ "HTTP_MCP_SESSION_ID" => session_id1 }
90+
{ "HTTP_MCP_SESSION_ID" => session_id1 },
9191
)
9292
response1 = @transport.handle_request(get_request1)
9393
response1[2].call(io1) if response1[2].is_a?(Proc)
@@ -96,7 +96,7 @@ class HTTPNotificationIntegrationTest < ActiveSupport::TestCase
9696
get_request2 = create_rack_request(
9797
"GET",
9898
"/",
99-
{ "HTTP_MCP_SESSION_ID" => session_id2 }
99+
{ "HTTP_MCP_SESSION_ID" => session_id2 },
100100
)
101101
response2 = @transport.handle_request(get_request2)
102102
response2[2].call(io2) if response2[2].is_a?(Proc)
@@ -123,7 +123,7 @@ class HTTPNotificationIntegrationTest < ActiveSupport::TestCase
123123
"POST",
124124
"/",
125125
{ "CONTENT_TYPE" => "application/json" },
126-
{ jsonrpc: "2.0", method: "initialize", id: "init" }.to_json
126+
{ jsonrpc: "2.0", method: "initialize", id: "init" }.to_json,
127127
)
128128
init_response = @transport.handle_request(init_request)
129129
session_id = init_response[1]["Mcp-Session-Id"]
@@ -133,7 +133,7 @@ class HTTPNotificationIntegrationTest < ActiveSupport::TestCase
133133
get_request = create_rack_request(
134134
"GET",
135135
"/",
136-
{ "HTTP_MCP_SESSION_ID" => session_id }
136+
{ "HTTP_MCP_SESSION_ID" => session_id },
137137
)
138138
response = @transport.handle_request(get_request)
139139
response[2].call(io) if response[2].is_a?(Proc)
@@ -158,7 +158,7 @@ class HTTPNotificationIntegrationTest < ActiveSupport::TestCase
158158
"POST",
159159
"/",
160160
{ "CONTENT_TYPE" => "application/json" },
161-
{ jsonrpc: "2.0", method: "initialize", id: "init" }.to_json
161+
{ jsonrpc: "2.0", method: "initialize", id: "init" }.to_json,
162162
)
163163
init_response = @transport.handle_request(init_request)
164164
session_id = init_response[1]["Mcp-Session-Id"]
@@ -168,7 +168,7 @@ class HTTPNotificationIntegrationTest < ActiveSupport::TestCase
168168
get_request = create_rack_request(
169169
"GET",
170170
"/",
171-
{ "HTTP_MCP_SESSION_ID" => session_id }
171+
{ "HTTP_MCP_SESSION_ID" => session_id },
172172
)
173173
response = @transport.handle_request(get_request)
174174
response[2].call(io) if response[2].is_a?(Proc)
@@ -179,8 +179,8 @@ class HTTPNotificationIntegrationTest < ActiveSupport::TestCase
179179
# Define a new tool (simulating dynamic tool addition)
180180
@server.define_tool(
181181
name: "dynamic_tool",
182-
description: "A dynamically added tool"
183-
) do |**args|
182+
description: "A dynamically added tool",
183+
) do |**_args|
184184
{ result: "success" }
185185
end
186186

@@ -202,7 +202,7 @@ class HTTPNotificationIntegrationTest < ActiveSupport::TestCase
202202
"POST",
203203
"/",
204204
{ "CONTENT_TYPE" => "application/json" },
205-
{ jsonrpc: "2.0", method: "initialize", id: "init" }.to_json
205+
{ jsonrpc: "2.0", method: "initialize", id: "init" }.to_json,
206206
)
207207
init_response = @transport.handle_request(init_request)
208208
session_id = init_response[1]["Mcp-Session-Id"]
@@ -212,7 +212,7 @@ class HTTPNotificationIntegrationTest < ActiveSupport::TestCase
212212
get_request = create_rack_request(
213213
"GET",
214214
"/",
215-
{ "HTTP_MCP_SESSION_ID" => session_id }
215+
{ "HTTP_MCP_SESSION_ID" => session_id },
216216
)
217217
response = @transport.handle_request(get_request)
218218
response[2].call(io) if response[2].is_a?(Proc)
@@ -226,7 +226,7 @@ class HTTPNotificationIntegrationTest < ActiveSupport::TestCase
226226
# Check SSE format
227227
io.rewind
228228
output = io.read
229-
229+
230230
# SSE format should be "data: <message>\n\n"
231231
assert_match(/data: #{Regexp.escape(Methods::NOTIFICATIONS_TOOLS_LIST_CHANGED)}\n/, output)
232232
end
@@ -237,11 +237,11 @@ def create_rack_request(method, path, headers, body = nil)
237237
env = {
238238
"REQUEST_METHOD" => method,
239239
"PATH_INFO" => path,
240-
"rack.input" => StringIO.new(body.to_s)
240+
"rack.input" => StringIO.new(body.to_s),
241241
}.merge(headers)
242242

243243
Rack::Request.new(env)
244244
end
245245
end
246246
end
247-
end
247+
end

0 commit comments

Comments
 (0)