class RubyLLM::MCP

An MCP is a client for a Model Context Protocol server. Describe the server to connect to in a subclass, the way you describe a Tool or an Agent, then hand an instance to a chat:

class Linear < RubyLLM::MCP
  url "https://mcp.linear.app/mcp"
  inputs :user
  bearer_token { user.linear_token }
end

linear = Linear.new(user: current_user)
linear.tools                     # => [#<RubyLLM::MCP::Tool name: "list_issues", ...>, ...]
linear.list_issues(query: "bug") # => #<RubyLLM::MCP::Result ...>

A url connects over Streamable HTTP; a command starts a local server that speaks over stdio:

class Files < RubyLLM::MCP
  command "npx", "-y", "@modelcontextprotocol/server-filesystem", "."
end

Settings that depend on runtime state take a block or a method name, evaluated on the instance, so declared ::inputs and private methods are available. RubyLLM.mcp builds one inline when a class is not worth writing.