Class: Sxn::MCP::Tools::Sessions::SwapSession
- Inherits:
-
MCP::Tool
- Object
- MCP::Tool
- Sxn::MCP::Tools::Sessions::SwapSession
- Defined in:
- lib/sxn/mcp/tools/sessions.rb
Overview
Swap to a different session with navigation info
Class Method Summary collapse
Class Method Details
.call(name:, server_context:, project: nil) ⇒ Object
296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 |
# File 'lib/sxn/mcp/tools/sessions.rb', line 296 def call(name:, server_context:, project: nil) BaseTool.ensure_initialized!(server_context) BaseTool::ErrorMapping.wrap do session_manager = server_context[:session_manager] workspace_path = server_context[:workspace_path] # Activate the session session = session_manager.use_session(name) # Determine target path target_path = if project worktrees = session[:worktrees] worktree_info = worktrees[project] if worktree_info worktree_info[:path] || worktree_info["path"] else session[:path] end else session[:path] end # Determine navigation strategy = (workspace_path, target_path) # Build response worktrees_list = session[:worktrees].map do |proj, info| "- #{proj}: #{info[:path] || info["path"]}" end.join("\n") output = <<~SWAP Switched to session '#{name}'. Session path: #{session[:path]} Target path: #{target_path} Navigation (#{[:strategy]}): #{[:instruction]} Worktrees: #{worktrees_list.empty? ? "(none)" : worktrees_list} SWAP # Add structured data for programmatic use BaseTool.text_response(output.strip) end end |