Skip to content

preserve scrollback buffer [feature request] #165

@tomasohara

Description

@tomasohara

Under Linux, when the screen is cleared via clear, the scrollback buffer also gets cleared. This should be retained, such as via the -x option:

$ man clear
Usage: clear [options]

Options:
  -T TERM     use this instead of $TERM
  -V          print curses-version
  -x          do not try to clear scrollback

This has the advantage that the initialization status messages are preserved. For example,

$ python -m mcp_client_for_ollama.cli
Auto-discovering servers from Claude's config at /home/tomohara/.config/Claude/claude_desktop_confi     def display_available_tools(self):
         """Display available tools with their enabled/disabled status"""

g.json
Auto-discovered server: pubmed
Auto-discovered server: weather
Auto-discovered server: time
...
Auto-discovered server: Bible MCP
Connecting to server: pubmed
...
ReferenceError: File is not defined
...
Successfully connected to Bible MCP with 3 tool(s) and 2 prompt(s)

╭───────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│                                  Welcome to the MCP Client for Ollama 🦙                                  │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────╯
╭─────────────────────────────────────────── 🔧 Available Tools ────────────────────────────────────────────╮
│ ✓ time.get_current_time                                   ✓ time.convert_time                             │
│ ✓ Bible MCP.get_verse_by_reference                        ✓ Bible MCP.get_random_verse_tool               │
│ ✓ Bible MCP.list_available_translations                                                                   │
╰──────────────────────────────────────────── 5/5 tools enabled ────────────────────────────────────────────╯

In this example, my pubmed configuration got messed up, so it is good to preserve the error messages.

This can be implemented as follows:

$ git diff mcp_client_for_ollama/client.py
...
 import os
+import platform
 import sys
...
     def clear_console(self):
         """Clear the console screen"""
-        os.system('cls' if os.name == 'nt' else 'clear')
+        os.system('cls' if os.name == 'nt' else
+                  'clear -x' if platform.system() == 'Linux' else
+                  'clear') 
...

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions