@@ -49,7 +49,7 @@ module ModelContextProtocol
4949 name: " my_server" ,
5050 tools: [SomeTool , AnotherTool ],
5151 prompts: [MyPrompt ],
52- context : { user_id: current_user.id },
52+ server_context : { user_id: current_user.id },
5353 )
5454 render(json: server.handle_json(request.body.read).to_h)
5555 end
@@ -69,7 +69,7 @@ module ModelContextProtocol
6969 name: " my_server" ,
7070 tools: [SomeTool , AnotherTool ],
7171 prompts: [MyPrompt ],
72- context : { user_id: current_user.id },
72+ server_context : { user_id: current_user.id },
7373 )
7474 render(json: server.handle(JSON .parse(request.body.read)).to_h)
7575 end
@@ -96,7 +96,7 @@ class ExampleTool < ModelContextProtocol::Tool
9696 required: [" message" ]
9797
9898 class << self
99- def call (message: , context : )
99+ def call (message: , server_context : )
100100 ModelContextProtocol ::Tool ::Response .new ([{
101101 type: " text" ,
102102 text: " Hello from example tool! Message: #{ message } " ,
@@ -137,7 +137,7 @@ server = ModelContextProtocol::Server.new(
137137 name: " my_server" ,
138138 tools: [SomeTool , AnotherTool ],
139139 prompts: [MyPrompt ],
140- context : { user_id: current_user.id },
140+ server_context : { user_id: current_user.id },
141141)
142142request = {
143143 jsonrpc: " 2.0" ,
@@ -154,11 +154,11 @@ The gem can be configured using the `ModelContextProtocol.configure` block:
154154
155155``` ruby
156156ModelContextProtocol .configure do |config |
157- config.exception_reporter = -> (exception, context ) do
157+ config.exception_reporter = -> (exception, server_context ) do
158158 # Your exception reporting logic here
159159 # For example with Bugsnag:
160160 Bugsnag .notify(exception) do |report |
161- report.add_metadata(:model_context_protocol , context )
161+ report.add_metadata(:model_context_protocol , server_context )
162162 end
163163 end
164164
@@ -170,11 +170,11 @@ This is useful for systems where an application hosts more than one MCP server b
170170they might require different instrumentation callbacks.
171171
172172configuration = ModelContextProtocol ::Configuration .new
173- configuration.exception_reporter = -> (exception, context ) do
173+ configuration.exception_reporter = -> (exception, server_context ) do
174174 # Your exception reporting logic here
175175 # For example with Bugsnag:
176176 Bugsnag .notify(exception) do |report |
177- report.add_metadata(:model_context_protocol , context )
177+ report.add_metadata(:model_context_protocol , server_context )
178178 end
179179end
180180
@@ -207,9 +207,9 @@ Be sure to check the [MCP spec](https://spec.modelcontextprotocol.io/specificati
207207The exception reporter receives two arguments:
208208
209209- ` exception ` : The Ruby exception object that was raised
210- - ` context ` : A hash containing contextual information about where the error occurred
210+ - ` server_context ` : A hash containing contextual information about where the error occurred
211211
212- The context hash includes:
212+ The server_context hash includes:
213213
214214- For tool calls: ` { tool_name: "name", arguments: { ... } } `
215215- For general request handling: ` { request: { ... } } `
@@ -248,7 +248,7 @@ class MyTool < ModelContextProtocol::Tool
248248 },
249249 required: [' message' ]
250250
251- def self .call (message: , context : )
251+ def self .call (message: , server_context : )
252252 Tool ::Response .new ([{ type: " text" , text: " OK" }])
253253 end
254254end
@@ -266,12 +266,12 @@ tool = ModelContextProtocol::Tool.define(
266266 title: " My Tool" ,
267267 read_only_hint: true
268268 }
269- ) do |args , context |
269+ ) do |args , server_context |
270270 Tool ::Response .new ([{ type: " text" , text: " OK" }])
271271end
272272```
273273
274- The context parameter is the context passed into the server and can be used to pass per request information,
274+ The server_context parameter is the server_context passed into the server and can be used to pass per request information,
275275e.g. around authentication state.
276276
277277### Tool Annotations
@@ -307,7 +307,7 @@ class MyPrompt < ModelContextProtocol::Prompt
307307 ]
308308
309309 class << self
310- def template (args , context : )
310+ def template (args , server_context : )
311311 Prompt ::Result .new (
312312 description: " Response description" ,
313313 messages: [
@@ -341,7 +341,7 @@ prompt = ModelContextProtocol::Prompt.define(
341341 required: true
342342 )
343343 ]
344- ) do |args , context : |
344+ ) do |args , server_context : |
345345 Prompt ::Result .new (
346346 description: " Response description" ,
347347 messages: [
@@ -358,7 +358,7 @@ prompt = ModelContextProtocol::Prompt.define(
358358end
359359```
360360
361- The context parameter is the context passed into the server and can be used to pass per request information,
361+ The server_context parameter is the server_context passed into the server and can be used to pass per request information,
362362e.g. around authentication state or user preferences.
363363
364364### Key Components
@@ -376,7 +376,7 @@ Register prompts with the MCP server:
376376server = ModelContextProtocol ::Server .new (
377377 name: " my_server" ,
378378 prompts: [MyPrompt ],
379- context : { user_id: current_user.id },
379+ server_context : { user_id: current_user.id },
380380)
381381```
382382
0 commit comments