Class: ActiveadminMcp::McpController

Inherits:
ActionController::API
  • Object
show all
Defined in:
app/controllers/activeadmin_mcp/mcp_controller.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#current_mcp_userObject (readonly)

Returns the value of attribute current_mcp_user.



7
8
9
# File 'app/controllers/activeadmin_mcp/mcp_controller.rb', line 7

def current_mcp_user
  @current_mcp_user
end

Instance Method Details

#callObject



9
10
11
12
13
14
15
16
# File 'app/controllers/activeadmin_mcp/mcp_controller.rb', line 9

def call
  request_body = JSON.parse(request.body.read)
  response = RequestHandler.new(current_user: current_mcp_user).handle(request_body)

  response ? render(json: response) : head(:no_content)
rescue JSON::ParserError => e
  render json: { jsonrpc: "2.0", error: { code: -32_700, message: e.message } }, status: :bad_request
end