Token-Efficient MCP Server
Supports running JavaScript code in a sandboxed environment to perform data analysis and script execution.
Provides OS-level sandboxing via bubblewrap for the secure execution of multi-language scripts and system commands.
Leverages sandbox-exec to provide a secure, isolated environment for executing code and shell commands on macOS.
Provides a secure environment to execute Node.js code and scripts for task automation and tool execution.
Enables sandboxed execution of Python scripts for data processing and code verification with high token efficiency.
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., "@Token-Efficient MCP Server Filter sales.csv for rows where price > 500 and show a summary"
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.
Token-Efficient MCP Server
A project-agnostic MCP (Model Context Protocol) server that provides 95%+ token savings through sandboxed data processing, progressive tool loading, and multi-language code execution.
๐ Key Features
Multi-Language Code Execution
Execute code in sandboxed environment:
Python, Bash, Node.js/JavaScript support
Critical for agent systems (initializer, coding, tester, verifier)
Run commands, tests, and validations with 98% token savings
Progressive Tool Disclosure
Load tools on-demand to reduce context usage:
Level 1: Tool names only (~100 tokens)
Level 2: Names + summaries (~2K tokens)
Level 3: Full definitions (only when needed)
Sandboxed Data Processing
Process data securely before returning to context:
CSV filtering and aggregation (99% savings)
Log file analysis (95% savings)
Code execution with output filtering
Token measurement and optimization
Project Agnostic
Works with any project that needs:
Multi-language code execution
Large dataset processing
Log analysis
Token optimization
Related MCP server: Code Execution MCP
๐ฆ Installation
# Clone the repository
git clone https://github.com/your-repo/token-efficient-mcp.git
cd token-efficient-mcp
# Install dependencies
npm install
# Build TypeScript
npm run buildโ๏ธ Configuration
Add to your global ~/.claude.json:
{
"mcpServers": {
"token-efficient": {
"command": "srt",
"args": [
"node",
"/path/to/token-efficient-mcp/dist/index.js"
]
}
}
}Note: The srt command provides OS-level sandboxing via sandbox-exec (macOS) or bubblewrap (Linux).
๐ ๏ธ Available Tools
1. execute_code
Execute code in multiple languages with sandboxing.
// Run bash commands
execute_code({
code: "npm test",
language: "bash"
})
// Run Python scripts
execute_code({
code: "import sys; print(sys.version)",
language: "python"
})
// Run Node.js code
execute_code({
code: "console.log('Hello from Node')",
language: "node"
})
// Check health endpoint
execute_code({
code: "curl -m 3 http://localhost:8000/api/health",
language: "bash"
})Supported Languages: python, bash, sh, node, javascript
2. list_token_efficient_tools
Discover available tools with progressive disclosure.
// Level 1: Names only (100 tokens)
list_token_efficient_tools({ level: "names_only" })
// Level 2: Summaries (2K tokens)
list_token_efficient_tools({ level: "summary" })
// Level 3: Full definitions
list_token_efficient_tools({ level: "full" })4. process_csv
Process CSV files with filtering and aggregation.
// Example: Find expensive stocks
process_csv({
file_path: "data/stocks.csv",
filter_expr: "price > 100 and volume > 1000000",
columns: ["symbol", "price", "volume", "change"],
limit: 10,
response_format: "summary"
})5. process_logs
Filter and analyze log files efficiently.
// Example: Find all errors with context
process_logs({
file_path: "logs/application.log",
pattern: "ERROR|CRITICAL",
context_lines: 2,
limit: 50,
response_format: "summary"
})6. get_token_savings_report
Get optimization tips and savings potential.
๐ Token Savings Examples
Code Execution
// Without execute_code: Multi-turn conversation
// Agent: "Should I run npm test?" โ User: "Yes" โ Run โ Parse output
// Estimated: 5,000+ tokens across multiple turns
// With execute_code: Single call
execute_code({ code: "npm test", language: "bash" })
// Returns: { success: true, output: "Tests passed", exit_code: 0 }
// Result: 200 tokens (98% savings)CSV Processing
// Without optimization: 200,000 tokens
// All 10,000 rows returned to context
// With token-efficient MCP: 2,000 tokens (99% savings)
// Only 100 filtered rows returnedLog Analysis
// Without optimization: 500,000 tokens
// All 100,000 log lines returned
// With token-efficient MCP: 5,000 tokens (99% savings)
// Only 500 matching lines with context returnedTool Loading
// Traditional MCP: 150,000 tokens
// All tool definitions loaded at startup
// Token-efficient MCP: 2,000 tokens (98.7% savings)
// Tools loaded on-demand๐ Security
The server uses OS-level sandboxing via srt wrapper:
Filesystem isolation: Limited to temp directories for code execution
Network restrictions: No outbound connections by default
Process monitoring: Timeouts (1-300s) and resource limits
Multi-language support: Sandboxed Python, Bash, Node.js execution
๐งช Testing
# Build the project
npm run build
# Test execute_code tool
node -e "
const { exec } = require('child_process');
const code = \`echo 'Hello from test'\`;
exec(\`node dist/index.js\`, (err, stdout) => {
console.log(stdout);
});
"
# Or test directly with MCP
# The server will be loaded by Claude Code via ~/.claude.json config๐ Performance Metrics
The server tracks and reports:
Input tokens: Size of request
Output tokens: Size of response
Processing efficiency: Items processed per token
Estimated savings: Percentage of tokens saved
Example response:
{
"token_metrics": {
"input_tokens": 250,
"output_tokens": 1500,
"estimated_savings_percent": 98.5
}
}๐ค Contributing
Fork the repository
Create a feature branch
Add tests for new functionality
Ensure token efficiency principles are followed
Submit a pull request
๐ License
MIT License - see LICENSE file for details.
๐ Related Resources
Available Tools
7 toolsbatch_process_csvBatch Process Multiple CSV FilesB
Process multiple CSV files in a single call with consistent filtering. Achieves 80% token savings for multiple files vs individual calls.
Inputs: file_paths (required), filter_expr, columns, limit, +1 more.
execute_codeExecute Code in SandboxB
Execute code in sandboxed environment. Supports Python, Bash, Node.js. Now with heredoc support for bash scripts (<<EOF, <<'EOF', <<EOT). Achieves 98%+ token savings by processing in execution environment.
Inputs: code (required), language, timeout, response_format.
get_token_savings_reportGet Token Savings ReportB
Get detailed token savings report and optimization best practices
list_token_efficient_toolsList Token-Efficient ToolsB
List available token-efficient tools with progressive disclosure (names_only, summary, full)
Inputs: level.
process_csvProcess CSV FilesA
Process CSV files efficiently with filters, groupby aggregation, and pagination. Use offset for large files (>10K rows) to achieve 99% token savings.
Inputs: file_path (required), filter_expr, columns, limit, +4 more.
process_logsProcess Log FilesC
Process log files efficiently with pattern matching and pagination. Use offset to skip previous matches.
Inputs: file_path (required), pattern (required), limit, offset, +2 more.
search_toolsSearch Tools by KeywordC
Search available tools by keyword with optional category filter. Achieves 95% token savings vs loading all tool definitions.
Inputs: query (required), category, level.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelogโฆ
TDQS
Scored across 7 tools
Most tools have distinct purposes, such as batch_process_csv for multiple files, process_csv for single files, and execute_code for code execution. However, list_token_efficient_tools and search_tools could be confused as both involve tool discovery, though search_tools adds keyword filtering.
All tool names follow a consistent verb_noun pattern using snake_case, such as batch_process_csv, execute_code, and get_token_savings_report. This uniformity makes the set predictable and easy to navigate.
With 7 tools, the count is well-scoped for a server focused on token-efficient operations. Each tool serves a clear purpose, such as processing files, executing code, and reporting savings, without being overly sparse or bloated.
The tool set covers key areas like file processing (CSV/logs), code execution, and tool discovery, with a focus on token efficiency. A minor gap is the lack of tools for updating or deleting processed data, but agents can work around this given the server's optimization-centric domain.
Related MCP Connectors
Up to 90% fewer tokens: deterministic, declared tool calls, each with a receipt and an audit trail.
See, price, and control every tool call your AI agents make: policy checks, cost, and audit tools.
Run AI agent tasks in isolated sandboxes with a cost cap, saved workflows and scoped connections.
Build Apps and run code in 30 languages โ sandboxed, with persistent sessions for agent loops.
Related MCP Servers
- FlicenseNot gradedqualityNot gradedmaintenanceEnables efficient code execution in a secure sandbox with 98.7% token reduction by allowing agents to write JavaScript/TypeScript code to interact with tools, process data, and maintain state instead of loading all tool definitions into context.-
- FlicenseNot gradedqualityDmaintenanceEnables efficient AI agent operations through sandboxed Python code execution with progressive tool discovery, PII tokenization, and skills persistence, achieving up to 98.7% token reduction by processing data in a sandbox rather than in context.-
- AlicenseNot gradedqualityCmaintenanceProvides sandboxed code execution for AI agents with support for Python, JavaScript, and shell commands. Includes comprehensive safety features like destructive pattern blocking, timeout protection, and restricted file access for secure production use.35 PyPIMIT
- AlicenseNot gradedqualityDmaintenanceCuts AI token costs by running user code in a secure sandbox, so data never enters the context window, enabling efficient data processing with MCP protocol.10Business Source 1.1