Skip to content

Commit ce1c871

Browse files
committed
Remove duplicate method instrumentation
`handle_request` already adds the `method` to the instrumentation data, so there is no need to repeat this. Moreover, consumers can override these anyway.
1 parent 04710ac commit ce1c871

File tree

1 file changed

+0
-10
lines changed

1 file changed

+0
-10
lines changed

lib/mcp/server.rb

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,6 @@ def server_info
176176
end
177177

178178
def init(request)
179-
add_instrumentation_data(method: Methods::INITIALIZE)
180179
{
181180
protocolVersion: configuration.protocol_version,
182181
capabilities: capabilities,
@@ -185,12 +184,10 @@ def init(request)
185184
end
186185

187186
def list_tools(request)
188-
add_instrumentation_data(method: Methods::TOOLS_LIST)
189187
@tools.map { |_, tool| tool.to_h }
190188
end
191189

192190
def call_tool(request)
193-
add_instrumentation_data(method: Methods::TOOLS_CALL)
194191
tool_name = request[:name]
195192
tool = tools[tool_name]
196193
unless tool
@@ -224,12 +221,10 @@ def call_tool(request)
224221
end
225222

226223
def list_prompts(request)
227-
add_instrumentation_data(method: Methods::PROMPTS_LIST)
228224
@prompts.map { |_, prompt| prompt.to_h }
229225
end
230226

231227
def get_prompt(request)
232-
add_instrumentation_data(method: Methods::PROMPTS_GET)
233228
prompt_name = request[:name]
234229
prompt = @prompts[prompt_name]
235230
unless prompt
@@ -246,21 +241,16 @@ def get_prompt(request)
246241
end
247242

248243
def list_resources(request)
249-
add_instrumentation_data(method: Methods::RESOURCES_LIST)
250-
251244
@resources.map(&:to_h)
252245
end
253246

254247
# Server implementation should set `resources_read_handler` to override no-op default
255248
def read_resource_no_content(request)
256-
add_instrumentation_data(method: Methods::RESOURCES_READ)
257249
add_instrumentation_data(resource_uri: request[:uri])
258250
[]
259251
end
260252

261253
def list_resource_templates(request)
262-
add_instrumentation_data(method: Methods::RESOURCES_TEMPLATES_LIST)
263-
264254
@resource_templates.map(&:to_h)
265255
end
266256

0 commit comments

Comments
 (0)