-
Notifications
You must be signed in to change notification settings - Fork 75
Open
Description
Problem
When using the Rails controller example in the README the notifications/initialized
request returns 200
instead of 202
.
It doesn't seem like a major thing but when adding the MCP server to Claude it's impossible to add it when the notifications/initialized
request returns 200
instead of 202
. When updating it to return 202
it works fine.
Proposed solution
Getting the status from the transport object instead of server.handle_json
like this makes it work though, so the updated example would then look like this:
class ApplicationController < ActionController::Base
def index
server = MCP::Server.new(
name: "my_server",
title: "Example Server Display Name", # WARNING: This is a `Draft` and is not supported in the `Version 2025-06-18 (latest)` specification.
version: "1.0.0",
instructions: "Use the tools of this server as a last resort",
tools: [SomeTool, AnotherTool],
prompts: [MyPrompt],
server_context: { user_id: current_user.id },
)
transport = MCP::Server::Transports::StreamableHTTPTransport.new(server)
server.transport = transport
response = transport.handle_request(request)
status, headers, body = response
json = JSON.parse(body.first) if body.present? && body.is_a?(Array)
render(json:, status:, headers:)
end
end
Let me know if you want me to create a PR for it!
Metadata
Metadata
Assignees
Labels
No labels