localmcp
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
localmcp
A local MCP server for AI coding workflows. It gives ChatGPT a constrained view of one project directory plus the tools needed to inspect, edit, test, commit, and push code.
What it can do
localmcp exposes 16 tools:
workspace_info— server, workspace, mode, and tool diagnosticsproject_snapshot— bootstrap a coding session with root files, a shallow tree, README content, git status, and diff statistics in one calllist_funcs— discover hot-reloadable JavaScript functions fromfunctions/execute_func— execute a discovered dynamic function by name and argumentslist_files— list a directorytree— recursively inspect the workspace with depth and entry limitssearch_files— substring or regex search with globs and context linesread_file— read a whole file or a numbered line rangeread_files— batch-read up to 50 files/ranges in one MCP round tripread_image— return a workspace PNG, JPEG, GIF, or WebP as MCP image content for vision-capable clients/modelswrite_file— create or replace a fileedit_file— guarded exact-text replacementapply_patch— atomically apply multiple guarded edits to one filedelete_file— delete a filemove_file— move or rename a filerun_command— execute a program directly without a shell
project_snapshot is intended as the first call in a coding session. It is language-agnostic: rather than interpreting a particular manifest or build system, it returns root files, a bounded .gitignore-aware tree, the root README (up to a configurable byte limit), and optional read-only git status plus diff statistics. Clients can use those facts to decide what to inspect next. It also returns structured content so clients do not need to parse the human-readable summary.
Dynamic functions live in functions/*.js. For security, list_funcs and execute_func are only registered in yolo mode because workspace files are writable and importing a workspace JavaScript module is equivalent to arbitrary code execution with the localmcp process permissions. Each module exports a default object with name, description, optional inputSchema metadata, and an async run(args, context) function. The included functions/hello.js is a minimal example.
Together these are enough for a coding-agent loop such as:
inspect → search → read → edit → test → diff → commit → pushWorkspace traversal respects the root .gitignore by default, and .git is always excluded. tree also accepts explicit exclude globs (for example build* or .cache/**) so generated trees can be omitted without changing .gitignore.
Related MCP server: Kastor
Security model
All localmcp file tools are confined to LOCALMCP_ROOT. Absolute paths, .. traversal, and symbolic-link escapes are rejected.
Command execution has two modes.
Strict mode
strict is the default. run_command only accepts executables listed in LOCALMCP_ALLOWED_COMMANDS. Dynamic workspace JavaScript functions are disabled in this mode so writable files cannot bypass the command allowlist.
LOCALMCP_ROOT="$HOME/src/my-project" \
LOCALMCP_MODE=strict \
LOCALMCP_ALLOWED_COMMANDS="git,node,npm" \
npm startWith an empty allowlist, command execution is effectively disabled.
YOLO mode
For a trusted coding workspace, yolo removes the executable allowlist:
LOCALMCP_ROOT="$HOME/src/my-project" \
LOCALMCP_MODE=yolo \
npm startlocalmcp still requires the command cwd to resolve inside LOCALMCP_ROOT.
YOLO mode is not an OS sandbox. An executed program can still read or modify files outside the workspace, access the network, spawn other processes, or execute code with the permissions of the localmcp process. Use an OS/container sandbox if you need process-level isolation.
Commands use Node.js spawn(..., { shell: false }), so localmcp does not wrap command input in a shell. Child processes receive a minimal environment (PATH, home/temp/locale variables as applicable) instead of inheriting all server environment variables, reducing accidental secret leakage. run_command accepts an optional per-call timeout_ms (1–600000 ms), overriding LOCALMCP_TIMEOUT_MS for that invocation. Its MCP result includes structured exit_code, signal, stdout, stderr, timed_out, truncated, and duration_ms fields in addition to the human-readable text result.
Requirements
Node.js 18+
Any command-line tools you want to execute must be installed and available on
PATH
Install
npm installRun
macOS/Linux:
LOCALMCP_ROOT="$HOME/src/my-project" npm startPowerShell:
$env:LOCALMCP_ROOT = "C:\src\my-project"
npm startThe default mode is strict.
The MCP endpoint is:
http://127.0.0.1:8787/mcpServer-side tool logs
Every MCP tool call is logged to stderr with its tool name, status, duration, and summarized input:
[localmcp] 2026-10-01T05:50:55.635Z tool=tree status=ok duration_ms=7.5 input={"path":".","max_depth":1,"max_entries":20,"respect_gitignore":true}Large edit/file contents are summarized instead of being printed verbatim. These logs make it possible to follow the sequence of actions an AI client performs against the workspace.
Configuration
PORT— HTTP port (default8787)LOCALMCP_ROOT— exposed workspace root (default: current directory)LOCALMCP_MODE— execution mode:strict(default) oryoloLOCALMCP_ALLOWED_COMMANDS— comma-separated executable allowlist used by strict mode (default: empty)LOCALMCP_TIMEOUT_MS— default command timeout (default120000); individualrun_commandcalls may override it withtimeout_msLOCALMCP_MAX_OUTPUT— maximum chars captured per stdout/stderr stream (default200000)LOCALMCP_MAX_FILE— maximum text file size in bytes (default1000000)LOCALMCP_MAX_IMAGE— maximum image size in bytes returned byread_image(default10000000)LOCALMCP_APPROVAL_CODE— optional fixed code entered on the local OAuth approval page; if omitted, a random code is generated and printed at startupLOCALMCP_PUBLIC_URL— public HTTPS origin used in OAuth metadata, for examplehttps://example.ngrok-free.app; recommended whenever a tunnel or reverse proxy is usedLOCALMCP_ALLOWED_ORIGINS— comma-separated exact browser origins permitted to call/mcp(default: none)
Test
npm testThe test suite covers workspace path confinement, symlink escape rejection, command allowlisting, per-call command timeouts and truncation, gitignore/exclude-aware traversal, safe ranged reads, search, line slicing, guarded edits, and multi-edit patching.
Test with MCP Inspector
npx @modelcontextprotocol/inspector@latestChoose Streamable HTTP and connect to http://127.0.0.1:8787/mcp.
Connect to ChatGPT
ChatGPT needs a reachable HTTPS /mcp URL. For development, expose port 8787 with a tunnel and use the resulting HTTPS URL ending in /mcp.
A public tunnel creates an entry point to your machine. Keep LOCALMCP_ROOT narrow and use strict mode. localmcp now exposes an OAuth 2.1 authorization-code flow with PKCE, protected-resource metadata, dynamic client registration, short-lived access tokens, and rotating refresh tokens.
When using a tunnel, pass its public origin explicitly so OAuth metadata and the MCP resource audience are stable:
localmcp "$HOME/src/my-project" \
--strict \
--allow git \
--public-url "https://your-tunnel.example"At startup localmcp prints an OAuth approval code. In ChatGPT, create the MCP app using:
https://your-tunnel.example/mcpChoose OAuth. ChatGPT will open the localmcp authorization page in your browser. Enter the approval code printed by the server and choose Allow. ChatGPT then completes PKCE and stores its OAuth access/refresh tokens.
The OAuth endpoints are:
/.well-known/oauth-protected-resource/.well-known/oauth-authorization-server/oauth/register/oauth/authorize/oauth/token
Use --approval-code or LOCALMCP_APPROVAL_CODE only when you intentionally want a stable approval code across restarts. This code is not an MCP bearer token; it is only used by the human authorization page.
Set LOCALMCP_ALLOWED_ORIGINS (or repeat --origin) only when browser-origin access to /mcp is required. OAuth discovery and token exchange do not require a CORS origin entry.
Persistent OAuth sessions
localmcp persists OAuth client registrations, access tokens, refresh tokens, and the local approval code automatically. The default state file lives under your OS user state directory (for example ~/.local/state/localmcp/) and is keyed by the localmcp instance identity, not the workspace. By default the public URL is the instance identity, so switching from one project directory to another keeps the same ChatGPT connection.
This means the normal flow is:
Connect ChatGPT and enter the approval code once.
Stop and restart localmcp whenever needed.
ChatGPT keeps using the existing connection and refreshes tokens without asking for the approval code again.
The state directory is created with owner-only permissions and the state file is written with mode 0600 on POSIX systems. Short-lived authorization codes are never persisted.
Set LOCALMCP_OAUTH_STATE=/path/to/state.json only if you need to override the default state location. Changing the workspace root does not change OAuth identity. Changing the public URL selects a different OAuth identity because tokens are bound to that protected resource. If you intentionally run multiple independent localmcp instances behind the same public URL, use --instance-id <id> or LOCALMCP_INSTANCE_ID to separate their stored credentials. On first startup after upgrading, localmcp automatically merges compatible legacy workspace-scoped OAuth state files for the same public URL into the new instance-scoped state.
This server cannot be deployed
Maintenance
Related MCP Connectors
Safe folder access for ChatGPT and Claude: read, write and search files, risky tools opt-in.
Work on your own computers from Claude or ChatGPT: run commands, edit and search files.
Use your Mac, Windows or Linux computer from ChatGPT, Claude or Codex: files, commands, documents.
Operate GitHub from your AI assistant: repos, PRs, issues, Actions. Previews and read-only mode.
Related MCP Servers
- AlicenseNot gradedqualityAmaintenanceEnables ChatGPT to inspect and edit local projects through a secure MCP interface, offering workspace management, file operations, git integration, and safe command execution.6MIT
- AlicenseNot gradedqualityCmaintenanceLets ChatGPT or MCP clients work with files on your machine, with tools for reading, editing, searching, git operations, and safety checks.MIT
- AlicenseNot gradedqualityBmaintenanceEnables ChatGPT or any MCP client to operate safely on a designated workspace by listing, reading, searching, writing, and trashing files, inspecting Git status/log/diff, and optionally running allowlisted executables without a shell.Apache 2.0
- AlicenseAqualityBmaintenanceEnables AI clients like ChatGPT or Codex to manage files and local Git repositories within an explicitly authorized workspace, with server-enforced path boundary checks and optional remote Git operations.181MIT