Class: Sxn::MCP::Tools::Sessions::GetSession

Inherits:
MCP::Tool
  • Object
show all
Defined in:
lib/sxn/mcp/tools/sessions.rb

Overview

Get detailed session info

Class Method Summary collapse

Class Method Details

.call(name:, server_context:) ⇒ Object



149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
# File 'lib/sxn/mcp/tools/sessions.rb', line 149

def call(name:, server_context:)
  BaseTool.ensure_initialized!(server_context)

  BaseTool::ErrorMapping.wrap do
    session_manager = server_context[:session_manager]
    session = session_manager.get_session(name)

    raise Sxn::SessionNotFoundError, "Session '#{name}' not found" unless session

    # Format session info
    worktrees_info = session[:worktrees].map do |project, info|
      "  - #{project}: #{info[:branch] || info["branch"]} (#{info[:path] || info["path"]})"
    end.join("\n")

    output = "      Session: \#{session[:name]}\n      Status: \#{session[:status]}\n      Path: \#{session[:path]}\n      Created: \#{session[:created_at]}\n      Default Branch: \#{session[:default_branch]}\n      \#{\"Description: \#{session[:description]}\" if session[:description]}\n      \#{\"Linear Task: \#{session[:linear_task]}\" if session[:linear_task]}\n      \#{\"Template: \#{session[:template_id]}\" if session[:template_id]}\n\n      Worktrees (\#{session[:worktrees].keys.length}):\n      \#{worktrees_info.empty? ? \"  (none)\" : worktrees_info}\n    INFO\n\n    BaseTool.text_response(output.strip)\n  end\nend\n"