0.0
The project is in a healthy, maintained state
Ruby / Rails host SDK for Sveda: embed tokens, streaming chat, and host MCP. Docs: https://sveda.dev/docs/hosts/ruby
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Runtime

>= 2.2
 Project Readme

sveda-ruby-sdk

Ruby SDK for the Sveda sidecar HTTP API.

Docs: sveda.dev/docs/hosts/ruby

RubyGems: sveda-ruby-sdk

Install

gem "sveda-ruby-sdk"
gem install sveda-ruby-sdk

Sidecar client

require "sveda"

client = Sveda::Client.new(base_url: "https://sveda.example.com", host_api_key: host_key)
token = client.embed.create_token(visitor_id: "user-1")

client = Sveda::Client.new(base_url: "https://sveda.example.com", embed_token: token.token)
client.chat.create_streamed(
  messages: [{ role: "user", content: "Hello" }],
  chatId: "chat-1"
) do |event|
  puts event.type
end

Host integration (embed session + MCP tools)

Sveda::Host::Server mirrors the Laravel SDK: mint an embed token with host_mcp_url / host_mcp_token, and expose POST /mcp/sveda for the sidecar.

server = Sveda::Host::Server.new(
  base_url: ENV["SVEDA_CLIENT_BASE_URL"],
  host_api_key: ENV["SVEDA_CLIENT_HOST_API_KEY"],
  mcp_url: ENV["SVEDA_CLIENT_MCP_URL"],
  server_name: "My App",
  instructions: "Tools for the current user."
)
server.resolve_tools_using { |user| [SearchPostsTool.new] }
server.policy_using { |_user| "agent" }

# Rails routes.rb
post "/sveda/session", to: "sveda_sessions#create"
match "/mcp/sveda", to: server.rack_app, via: :post

# SvedaSessionsController
render json: server.start_session(visitor_id: "user-#{current_user.id}")

Subclass Sveda::Host::Tool with name, description, input_schema, mode, domain, and handle.

By default, the server mints opaque MCP bearer tokens with MemoryTokenStore. Override with mint_token_using and authenticate_using for production auth.

Lower-level session minting:

session = Sveda::Client.start_host_session(
  base_url: "https://sveda.example.com",
  host_api_key: host_key,
  visitor_id: "user-1",
  host_mcp_url: "https://app.example.com/mcp/sveda",
  host_mcp_token: mcp_token
)

Agent introspection

manifest = server.describe(current_user)
puts JSON.pretty_generate(manifest)

In Rails apps that assign config.x.sveda_host, run bin/rails sveda:tools (optional USER=email@example.com). Playground apps also expose GET /sveda/tools when logged in.

License

Apache License 2.0. See LICENSE.