21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
# File 'lib/groww_mcp/tools/auth_tools.rb', line 21
def call(server_context:, force: false)
auth = server_context[:auth]
if force || !auth.token_valid?
auth.authenticate!
MCP::Tool::Response.new([{
type: "text",
text: "✅ Authenticated successfully. Token valid until #{auth.token_expiry || 'unknown (manual token)'}.",
}])
else
MCP::Tool::Response.new([{
type: "text",
text: "Token is still valid (expires: #{auth.token_expiry}). Use force: true to re-authenticate.",
}])
end
rescue GrowwMcp::AuthError => e
MCP::Tool::Response.new([{ type: "text", text: "❌ Authentication failed: #{e.message}" }])
end
|