Skip to main content
Glama

MCP ShellKeeper

by tranhuucanh

🐚 MCP ShellKeeper

Persistent Terminal Sessions + File Transfer for AI Assistants

SSH into servers, run commands, transfer files β€” all through your AI assistant. No more stateless limitations.

License: MIT Node Version MCP npm npm downloads

Real-World Example β€’ Installation β€’ Core Features β€’ Use Cases β€’ Tools


🎯 The Problem

AI assistants like Cursor execute commands statelessly β€” each command runs in a fresh environment:

❌ ssh user@server # Hangs forever - no output until exit ❌ Can't run commands after SSH ❌ Each command starts from scratch ❌ No way to transfer files to/from servers ❌ Must re-authenticate for every operation

✨ The Solution

ShellKeeper transforms AI assistants into stateful operators with persistent sessions and file transfer capabilities.


πŸš€ Core Features

πŸ”„ Stateful Execution

Traditional AI (Stateless)

You: "SSH to server" AI: ❌ Command hangs forever You: "List files" AI: ❌ Runs on local, not server

ShellKeeper (Stateful)

You: "Connect to my server" AI: βœ… Establishes SSH session You: "What files are there?" AI: βœ… Lists files on server You: "Go to the logs folder" AI: βœ… Changes to /var/log You: "Show me recent errors" AI: βœ… Displays log content

AI maintains full context between your questions!

🎯 Persistent Sessions

Natural Conversation Flow

You: "SSH to production server" AI: βœ… Connected to prod-01 Session: prod-01 You: "How much disk space left?" AI: βœ… 45GB available (same session, no re-auth) You: "Show me today's logs" AI: βœ… Displaying logs... (same session continues) You: "Restart the API service" AI: βœ… Service restarted (still same session!)

The AI remembers everything:

  • βœ… Your SSH connections

  • βœ… Current directories

  • βœ… Environment variables

  • βœ… All previous context

πŸ“ Seamless File Transfer

Just Ask in Natural Language

You: "Upload my config to the server" AI: βœ… Uploaded config.json /app/config/config.json --- You: "Download the error logs" AI: βœ… Downloaded app.log Saved to ./logs/app.log --- You: "Get database backup" AI: βœ… Downloaded backup.sql (even through SSH jumps!)

It just works:

  • βœ… Through any SSH session

  • βœ… Multiple jump hosts

  • βœ… Up to 10MB files

  • βœ… Binary and text files


🎬 Real-World Example

Watch how a natural conversation becomes automated operations:

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ πŸ‘€ YOU ASK: "Debug the slow API on prod-server-01" ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ πŸ€– AI EXECUTES: [Connecting...] β†’ ssh user@prod-server-01 βœ… Connected to prod-server-01 [Investigating processes...] β†’ ps aux | grep api πŸ“Š API process found: PID 1234, using 98% CPU [Checking logs...] β†’ cd /var/log/api && tail -n 100 error.log πŸ” ERROR: Memory leak in /api/v1/users endpoint [Downloading for analysis...] β†’ Download: /var/log/api/error.log β†’ ./local-debug/ βœ… Downloaded 2.4MB (analyzed: 500+ memory errors) [Applying fix...] β†’ Upload: ./fixed-config.yml β†’ /app/config/ βœ… Uploaded new rate-limiting config [Restarting service...] β†’ systemctl restart api-service β†’ systemctl status api-service βœ… Service restarted, CPU now at 12% ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ πŸ€– AI RESPONDS: "Fixed! The API had a memory leak in the users endpoint. β€’ Downloaded logs and found 500+ memory allocation errors β€’ Applied rate-limiting configuration β€’ Restarted service - CPU dropped from 98% to 12% β€’ All operations completed in one persistent session" ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ✨ All in ONE session, NO re-authentication needed! ✨

πŸ“¦ Installation

npm install -g mcp-shellkeeper

Configuration

Cursor

Settings JSON:

{ "mcpServers": { "shellkeeper": { "command": "npx", "args": ["-y", "mcp-shellkeeper"] } } }

(Cmd+Shift+P β†’ Preferences: Open Settings)

Claude Code

Config file:

{ "mcpServers": { "shellkeeper": { "command": "npx", "args": ["-y", "mcp-shellkeeper"] } } }

(~/.config/claude/config.json)

VS Code (Cline)

Settings JSON:

{ "cline.mcpServers": { "shellkeeper": { "command": "npx", "args": ["-y", "mcp-shellkeeper"] } } }

Restart your AI assistant and you're ready! πŸŽ‰


πŸ’‘ Use Cases

Scenario

What You Ask

What AI Does

πŸ” Debug Production

"Why is prod-api slow?"

SSH β†’ Check CPU/memory β†’ Download logs β†’ Analyze β†’ Upload fix β†’ Restart

πŸš€ Deploy Updates

"Deploy v2.0 to staging"

SSH β†’ Backup β†’ Upload files β†’ Migrate DB β†’ Restart β†’ Verify

πŸ”§ Update Configs

"Update SSL certs on web servers"

SSH β†’ Download old certs β†’ Upload new β†’ Test β†’ Reload nginx

πŸ—„οΈ Backup Database

"Backup prod DB to local"

SSH through bastion β†’ Dump DB β†’ Compress β†’ Download β†’ Verify

πŸ“Š Analyze Logs

"Find all 500 errors today"

SSH β†’ Parse logs β†’ Download β†’ Analyze locally β†’ Report patterns

πŸ”„ Batch Operations

"Update configs on all servers"

Parallel sessions β†’ Upload β†’ Restart β†’ Download results

All through natural conversation with your AI! No scripts, no manual SSH juggling.


πŸ“– Available Tools

The AI uses these tools automatically, but you can reference them for advanced use:

Tool

Purpose

Key Features

terminal_execute

Run commands in persistent session

Timeout config, exit code capture, clean output

terminal_upload_file

Upload local β†’ remote (max 10MB)

Auto-detect directory, handle duplicates, works through SSH

terminal_download_file

Download remote β†’ local (max 10MB)

Auto-create dirs, preserve permissions, verify integrity

terminal_new_session

Create isolated session

Parallel operations, separate environments

terminal_list_sessions

View all active sessions

Status, uptime, last command

terminal_close_session

Clean up session

Free resources when done

terminal_get_buffer

Debug raw output

Useful for troubleshooting

πŸ’‘ Tip: The AI handles these automatically based on your natural language requests!


πŸ”’ Security Best Practices

βœ… DO:

  • Use SSH key authentication (not passwords): ssh-keygen -t ed25519

  • Jump through bastion hosts for production: ssh -J bastion.com user@prod

  • Limit file upload destinations (avoid /etc, /root, .ssh/)

  • Use read-only accounts for investigation

  • Clean up sessions after tasks

  • Audit all AI operations

❌ DON'T:

  • Store passwords in commands or configs

  • Upload untrusted files to production

  • Download sensitive data without encryption

  • Run destructive commands without verification

  • Grant unnecessary permissions


πŸ› οΈ How It Works

Persistent Sessions:

  • Uses PTY (Pseudo-Terminal) for full TTY emulation with state persistence

  • Smart markers detect command completion automatically

  • Exit codes captured for error detection

  • Output parsed clean (no ANSI codes)

File Transfer:

  • Base64 encoding through existing SSH sessions (no separate SCP/SFTP)

  • Works through jump hosts without re-authentication

  • Max 10MB, 5-minute timeout (completes early if faster)


πŸ› Troubleshooting

// Increase timeout for long-running commands terminal_execute({ command: "npm install", timeout: 120000 // 2 minutes }) // Check if SSH keys are set up correctly ssh -v user@server
# Set up passwordless authentication ssh-keygen -t ed25519 ssh-copy-id user@server # Verify ssh user@server "echo Success"
// Check if in SSH session first terminal_execute({ command: "pwd" }) // Verify you're on remote server // Ensure remote directory exists terminal_execute({ command: "mkdir -p /app/uploads" }) // Then upload terminal_upload({ local_path: "file.txt", remote_path: "/app/uploads/file.txt" })
// Verify remote file exists terminal_execute({ command: "ls -lh /path/to/file" }) // Check permissions terminal_execute({ command: "cat /path/to/file | wc -l" }) // Try download with absolute path terminal_download({ remote_path: "/full/path/to/file", local_path: "./" })
// List all sessions terminal_list_sessions() // Close problematic session terminal_close_session({ session_id: "stuck-session" }) // Create fresh session terminal_new_session({ session_id: "new-session" })

πŸ§ͺ Development

# Clone repository git clone https://github.com/tranhuucanh/mcp-shellkeeper.git cd mcp-shellkeeper # Install dependencies npm install # Build npm run build # Test locally with stdio transport node dist/index.js # Test with MCP Inspector npm run inspector

🀝 Contributing

Contributions welcome! Help make AI-assisted server management better.

  1. Fork the repository

  2. Create feature branch (git checkout -b feature/amazing-feature)

  3. Commit changes (git commit -m 'Add amazing feature')

  4. Push to branch (git push origin feature/amazing-feature)

  5. Open Pull Request


πŸ“„ License

MIT License - see LICENSE file for details.

You can:

  • βœ… Use commercially

  • βœ… Modify

  • βœ… Distribute

  • βœ… Private use


πŸ™ Acknowledgments


πŸ“ž Support


Built with ❀️ for the AI developer community

Stateful execution + File transfer = Limitless possibilities

Star History Chart

⬆ Back to top

-
security - not tested
A
license - permissive license
-
quality - not tested

local-only server

The server can only run on the client's local machine because it depends on local resources.

Enables AI assistants to maintain persistent SSH terminal sessions and transfer files to/from remote servers. Allows stateful command execution, natural language server management, and seamless file operations through SSH connections.

  1. 🎯 The Problem
    1. ✨ The Solution
      1. πŸš€ Core Features
        1. πŸ”„ Stateful Execution
        2. 🎯 Persistent Sessions
        3. πŸ“ Seamless File Transfer
      2. 🎬 Real-World Example
        1. πŸ“¦ Installation
          1. Configuration
        2. πŸ’‘ Use Cases
          1. πŸ“– Available Tools
            1. πŸ”’ Security Best Practices
              1. πŸ› οΈ How It Works
                1. πŸ› Troubleshooting
                  1. πŸ§ͺ Development
                    1. 🀝 Contributing
                      1. πŸ“„ License
                        1. πŸ™ Acknowledgments
                          1. πŸ“ž Support

                            MCP directory API

                            We provide all the information about MCP servers via our MCP API.

                            curl -X GET 'https://glama.ai/api/mcp/v1/servers/tranhuucanh/mcp-shellkeeper'

                            If you have feedback or need assistance with the MCP directory API, please join our Discord server