local-mcp
local-mcp
Zero-dependency MCP server for local file operations. 13 filesystem tools + 3 meta-tools for progressive discovery — no SDKs, no frameworks, no npm install needed.
MCP Protocol: 2024-11-05 · Transport: stdio + Streamable HTTP · Runtime: Node.js ≥ 22.0.0
Architecture
local-mcp.mjs — 595 lines, 13 tools, entry point
lib/mcp-core.mjs — 229 lines, stdio + HTTP transport, 9 MCP methods
lib/config.mjs — 31 lines, MCP_WORKSPACE/DATA env config with validationTotal: ~855 lines, zero runtime dependencies.
Tools
Filesystem Tools (13)
Tool | Description | Annotation |
| Read file with line numbers, optional |
|
| File search by name (glob) then content (grep) |
|
| Compact directory listing with lazy stat |
|
| Streaming command execution with stdin support and timeout |
|
| Diff two files or text strings (Myers O(ND)) |
|
| Copy file or directory |
|
| Move or rename file/directory |
|
| Run multiple ops sequentially; atomic rollback, |
|
| Unified: read, write, edit, append, delete, info, mkdir, move | — |
| Read/replace/insert/delete code blocks by range or function name | — |
| Persistent path aliases (add/get/list/delete) | — |
| Compact |
|
| Watch file/directory for changes; max 20 concurrent watchers | — |
Meta-Tools (3) — Progressive Discovery
Tool | Description |
| Search available tools by keyword — saves ~90% tokens vs listing all |
| Get full input schema for a specific tool (loaded on demand) |
| Execute any tool by name with arguments |
Instead of sending all 13 tool schemas (~3,000 tokens) in every request, progressive discovery with these 3 meta-tools reduces it to ~50 tokens — ~90% token savings.
Performance Optimizations (v1.1.1)
# | Optimization | Impact |
A | Stream head/tail read |
|
B | Lazy stat in ls | Only calls |
C | Adaptive grep concurrency |
|
D | LRU cache eviction | Map insertion-order LRU — hot small files no longer evicted by cold large files |
E | Grep byte protection |
|
F | Progress notification |
|
Additional Optimizations
Area | Detail |
Read cache | Size-aware eviction (max 50 items, 10 MB) + 5s TTL |
Myers diff | O(ND) algorithm, used by |
Search scoring | Name-match first (no I/O), then stat only top 50 candidates |
Output format |
|
Protocol | O(1) Map dispatch, sync handler short-circuit |
Getting Started
# Zero install — no dependencies
node local-mcp.mjs
# With configuration
MCP_WORKSPACE=D:/projects node local-mcp.mjsstdio mode (default)
{
"mcpServers": {
"local-mcp": {
"command": "node",
"args": ["D:/path/to/local-mcp.mjs"],
"env": {
"MCP_WORKSPACE": "D:/projects"
}
}
}
}HTTP mode
node local-mcp.mjs --http
node local-mcp.mjs --http --port 3456Supports JSON-RPC 2.0 POST, SSE streaming (Accept: text/event-stream), CORS, and GET /tools.
CLI flags
node local-mcp.mjs --help # Show usage + env vars
node local-mcp.mjs --list-tools # Print available tools and exit
node local-mcp.mjs --http # Start HTTP mode
node local-mcp.mjs --http --port 3456Configuration
Variable | Default | Description |
|
| Working directory root (security boundary) |
|
| Data directory (bookmarks, temp files) |
|
| Default directory for tree/ls commands |
|
| HTTP server port (when using |
|
| Set to |
| — | Comma-separated extra dirs to exclude from search |
Security
All file operations restricted to
MCP_WORKSPACEand subdirectoriesPrototype-safe bookmark keys (blocks
__proto__/constructor/prototypeinjection)Atomic writes (temp + rename) prevent partial file writes
Binary file detection prevents reading non-text files
.gitignoreand common exclude dirs (node_modules,.git, etc.) respected
Dependencies
Zero runtime dependencies. Uses only Node.js built-ins:
Module | Purpose |
| File system + |
| Streaming shell execution |
| HTTP transport (no Express needed) |
| Path resolution |
|
|
| Streaming line-by-line processing |
Changelog
v1.1.1 — Performance Optimizations
A. Stream head/tail read: 500MB logs 3s → 5ms
B. Lazy stat in ls: 1000-file dir 50ms → 2ms
C. Adaptive grep concurrency with
availableParallelism()D. LRU cache eviction via Map insertion order
E. Grep byte protection (100MB / 1000 files)
F. Progress notification passthrough for MCP 2025 spec
Fix:
streamHeadscope bug —donedefined outside Promise callback
v1.1.0
13 filesystem tools + 3 meta-tools for progressive discovery
stdio + Streamable HTTP transport
Myers diff engine, read cache, streaming exec
Environment-based configuration with validation
Development
# Run tests
node --test test/*.test.mjs
# Adding a tool
# 1. Define schema + handler in local-mcp.mjs
# 2. Register with server.tool()
# 3. Add testsContributing
Maintain zero-dependency constraint
Add tests for new functionality
Update the Optimizations table for performance changes
License
MIT
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
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/fan-67/local-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server