server-commands-rtk
An MCP server for executing shell commands with automatic RTK-based token reduction (~90%), persistent caching, and comprehensive execution logging.
run_process: Execute shell commands with optional RTK auto-filtering, configurable working directory, timeout, description, and per-call cache bypass. Supports streaming output to avoidmaxBufferlimitations.get_cache_stats: View cache hit/miss counts and total cached entries.clear_command_cache: Wipe all persistently cached command results.cached_commands: List all cached command keys with timestamps.execution_log: Retrieve the last N entries from the append-only JSONL execution log, including metadata like duration, exit code, and RTK filtering status. Supports historical archives.list_archives: List all rotated execution log archive files.write_file: Write files using base64-encoded content to safely handle special characters that could break JSON serialization.resolve_uri: Resolvescheme://pathURIs to absolute file paths using a TOML config or environment variable.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@server-commands-rtk list files in current directory"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
commands-rtk
MCP server that executes shell commands via MCP tools - with streaming spawn, automatic RTK token reduction, persistent caching, and full execution logging.
Streaming spawn - uses
spawn(notexec), nomaxBufferceiling, pipes stdout/stderr directlyAuto-RTK - transparently wraps commands with RTK for ~90% token reduction
Timeout + cancellation -
AbortControllercancels stream collection immediately,SIGKILLterminates process treePersistent cache - results cached in
~/.local/share/state/commands-rtk/command-cache.jsonacross sessionsExecution logger - append-only JSONL with auto-rotation, gzip compression, archive listing
Safe file writes -
write_filewith base64 content avoids JSON serialization breakage on special charactersURI resolver -
resolve_uriresolvesscheme://pathto absolute file paths via shared TOML config
Includes
ā License - This repository contains a LICENSE file
ā Prompts - This MCP Server includes prompts users can invoke
ā Resources - This MCP Server includes resources for attaching and managing context data
Related MCP server: Whisper CLI MCP Server
Requirements
Node.js 24+ (ESM,
"type": "module"in package.json)rtk CLI - install via
`curl -fsSL https://raw.githubusercontent.com/rtk-ai/rtk/refs/heads/master/install.sh | sh`
Installation
npx (no install)
npx commands-rtk # Run MCP server (downloads on demand)
npx commands-rtk setup # Apply one-time patches (rtk fix, etc.)npm (global install)
npm install -g commands-rtk
commands-rtk setup # One-time patch setupFrom source
git clone https://github.com/Ev3lynx727/server-commands-rtk.git
cd server-commands-rtk
npm install
npm run build
npm run setup # One-time patch setup (rebuilds rtk from source if needed)npx (no install, MCP client config)
{
"mcpServers": {
"commands-rtk": {
"command": "npx",
"args": ["commands-rtk"],
"env": {}
}
}
}First run: Run
npx commands-rtk setuponce before first use to apply one-time patches.
Global install (MCP client config)
{
"mcpServers": {
"commands-rtk": {
"command": "commands-rtk",
"args": [],
"env": {}
}
}
}OpenCode
{
"mcp": {
"commands-rtk": {
"type": "local",
"command": ["node", "/path/to/commands-rtk/dist/index.js"],
"enabled": true,
"timeout": 60000
}
}
}Tools
Tool | Description |
| Execute a shell command with RTK auto-filtering |
| Show cache hit/miss counts and entry count |
| Wipe all cached command results |
| List all cached command keys and timestamps |
| Read execution log entries, optionally from archives |
| List rotated |
| Write a file from base64 content (safe for special characters) |
| Resolve |
Schema
How commands-rtk processes an MCP tool call:
The flow: server.ts receives tools/call ā Zod.parse() validates ā executor.ts spawns with rtk prefix ā result cached + logged ā JSON-RPC response returned.
Usage
// Auto-RTK (default) - ~90% token reduction
run_process({command: "ls -la"})
// Bypass RTK filtering entirely
run_process({command: "ls -la"})
// Explicitly enable/disable RTK
run_process({command: "ls -la"})
// Override default timeout (60s) per call
run_process({command: "sleep 30", timeout_ms: 5000})
// Set working directory and attach metadata
run_process({
command: "npm test",
cwd: "/path/to/project",
description: "run unit tests",
model_used: "claude-sonnet-4",
timeout_ms: 30000
})
// Force cache bypass
run_process({command: "npm install", clear_cache: true})execution_log
// Tail last 100 entries
execution_log({limit: 100})
// Include rotated archives for full history
execution_log({limit: 500, include_archives: true})write_file
MCP tool parameters are JSON-serialized. Content with quotes, backticks, or long special-character strings can break the JSON framing. Use write_file with base64 encoding:
write_file({
path: "/tmp/output.txt",
content_b64: "SGVsbG8gV29ybGQ="
})resolve_uri
resolve_uri({uri: "headquarters://."})
// { scheme: "headquarters", relativePath: ".", absolutePath: "/home/ev3lynx/headquarters" }
resolve_uri({uri: "datasets://train/run-001.parquet"})
// { scheme: "datasets", relativePath: "train/run-001.parquet", absolutePath: "/home/ev3lynx/datasets/memory-graph/train/run-001.parquet" }Schemes are loaded from ~/.config/uri-resolver/config.toml (primary) with MCP_RESOURCE_ROOTS as fallback. scheme://. resolves to the base directory.
list_archives
list_archives()
// Returns: { archives: ["file1.jsonl.gz", ...], count: 7 }Configuration (rtk-hook.toml)
Section | Key | Default | Description |
|
|
| Default per-command timeout (overridable per call) |
|
|
| Max stdout/stderr collected per command |
|
|
| Entries kept in active log before rotation |
|
|
| Max rotated archive files retained |
|
|
| Compress rotated logs with gzip |
|
|
| Window for deduplicating identical commands |
Example:
[execution]
timeout_ms = 60000
max_buffer_mb = 10
max_log_entries = 1000
max_archives = 50
compress_archives = true
[cache]
debounce_ms = 2000State Files
All runtime state lives under ~/.local/share/state/commands-rtk/:
~/.local/share/state/commands-rtk/
āāā command-cache.json # Persistent command cache
āāā execution-log.jsonl # Append-only execution logCreated automatically on first run (mkdirSync with recursive: true).
Cache
File:
command-cache.json- persistent JSON, survives server restartKey: SHA-256 hash of
(command + cwd)Stats: Hit/miss counters via
get_cache_statsFlush: Written to disk on every mutation + on SIGTERM/SIGINT
Execution Log
File:
execution-log.jsonl- append-only, one JSON object per lineRotation: When
max_log_entriesreached, half of entries archived. Rotated files land alongside the active log asexecution-log-{timestamp}.jsonl.gzPer-entry metadata:
timestamp,key,command,rtk_filtered,rtk_rewritten,cached,success,exitCode,duration_ms,error_type,stdout/stderr,stdout_lines/stderr_lines,model_used
MCP Resources & URI Resolution
Resource templates and URI resolution share a unified scheme registry loaded from two sources (TOML wins):
Primary:
~/.config/uri-resolver/config.tomlā shared with the standalone uri-resolver MCP serverFallback:
MCP_RESOURCE_ROOTSenv var ā for deployment-specific overrides
export MCP_RESOURCE_ROOTS='{"headquarters": "~/headquarters"}'Each scheme registers a resource template {scheme}://{path} and is queryable via the resolve_uri tool. Path traversal is denied via startsWith() guard.
Response Format
All tools return JSON:
{
"cached": false,
"key": "sha256-hash",
"command": "echo hello",
"result": {
"success": true,
"stdout": "hello\n",
"stderr": "",
"exitCode": 0,
"duration_ms": 12,
"error_type": null
},
"rtk_filtered": true,
"rtk_rewritten": true
}Error types: timeout, not_found (ENOENT), permission_error (EACCES/EPERM), memory_error (ENOMEM), unknown_error.
Timeout returns exitCode: 124 with message in stderr.
Token Savings
Command | Raw Tokens | RTK Tokens | Savings |
| ~25,000 | ~3,000 | 88% |
| ~50,000 | ~5,000 | 90% |
| ~15,000 | ~500 | 97% |
| ~5,000 | ~200 | 96% |
Environment Variables
Variable | Required | Description |
| No | Custom server root (defaults to directory containing |
| No | Override for |
| No | JSON object mapping scheme names to directory paths (fallback, TOML config is primary) |
| No | Log level ( |
Credit
This project would not work without RTK ā the Rust token reducer that filters shell command output for ~90% token savings.
License
MIT
Available Tools
8 toolscached_commandsA
List all cached commands
Inputs: no named parameters.
clear_command_cacheB
Clear all cached commands
Inputs: no named parameters.
execution_logC
Get execution log (last N entries, optionally including archives)
Inputs: limit, include_archives.
get_cache_statsC
Get cache statistics
Inputs: no named parameters.
list_archivesA
List all rotated log archive files for dataset pipeline
Inputs: no named parameters.
resolve_uriA
Resolve a scheme:// URI to an absolute file path. Uses schemes registered via MCP_RESOURCE_ROOTS env var (headquarters://, vaults://, etc.). scheme://. resolves to the base directory.
Inputs: uri (required).
run_processC
Run shell command. Auto-prefixed with rtk for token minimization (60-90% savings).
Inputs: command (required), cwd, model_used, timeout_ms, +2 more.
write_fileA
Write a file with base64-encoded content. Use this instead of write/filesystem_write_file when content contains special chars that break JSON serialization.
Inputs: path (required), content_b64 (required).
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelogā¦
TDQS
Scored across 8 tools
Each tool targets a distinct action or resource: cache listing/clearing/stats, log retrieval/archives, URI resolution, process execution, and file writing. No overlapping purposes.
All tool names use consistent snake_case and follow a verb_noun pattern (e.g., list_archives, run_process, write_file). No mixed conventions.
8 tools is well-scoped for a command server utility set. Each tool serves a clear need without excess or deficiency.
Covers core operations (run, write, cache management, logging, URI resolution). Minor gap: no tool to delete or manipulate archive files, but core workflows are covered.
Maintenance
Related MCP Connectors
Remote MCP server exposing your Node Command fleet (files, shell, processes, browser) to AI hosts.
Remote MCP server to run your Atako AI agents: chat, projects, files, integrations and channels.
Remote MCP server for supportsheep: run AI interviews and manage support content for your blog.
Remote MCP server for supportsheep: run AI interviews and manage support content for your blog.
Related MCP Servers
- AlicenseNot gradedqualityBmaintenanceGive hands to AI. MCP server to run shell commands securely, auditably, and on demand.110GPL 3.0
- AlicenseNot gradedqualityDmaintenanceAn MCP server that provides shell command execution and OpenAI Whisper transcription capabilities for audio files.1MIT
- AlicenseAqualityDmaintenanceAn MCP server that enables coding agents to execute and manage long-running shell commands asynchronously with capabilities for process monitoring, interaction, and lifecycle management.714MIT
- FlicenseBqualityDmaintenanceAn MCP server that enables users to execute arbitrary shell commands on their local machine and receive the output. It provides a terminal tool for running system commands through MCP-compatible clients using the Python SDK.1-