ForgeGuard MCP
ForgeGuard MCP is a security-hardened file/project management server for AI coding agents, providing guarded filesystem, git, process, transaction, and project-brain tools.
Register, list, and inspect project workspaces, constrained to roots allowed by
FORGEGUARD_ALLOWED_ROOTS.Read, write, and patch UTF-8 files inside registered workspaces, blocking traversal, symlink escapes, sensitive files, and known secret patterns.
List bounded directory trees (up to depth 10) while hiding sensitive files.
Search project files for exact text fragments, ignoring generated/vendor directories and sensitive files.
Run
git status --shortand non-mutatinggit diff(unstaged or staged) without a shell.Run only explicitly allowlisted executables via direct argv (no shell), with configurable timeout and args; disabled by default unless
FORGEGUARD_COMMANDSis set.Manage isolated Git worktree transactions: begin, list, status, diff, file operations, process execution, apply with mandatory policy gates, and abort; refuse apply if the original repo moved or became dirty.
Persist and recover active transactions after restarts, rejecting tampered or unauthorized transaction records.
Store per-project policies that can only narrow the global command allowlist.
Maintain a Project Brain for context, tasks (create/list/get/update/resume), and decisions (add/list).
Provide an audit trail of recent actions via
audit_recent.Fail closed by default: missing configuration denies project registration and process execution until explicitly enabled.
Provides Git integration with tools to inspect repository status and diffs for registered projects.
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., "@ForgeGuard MCP Register ~/Projects/my-app and show its git status and diff"
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.
ForgeGuard MCP
ForgeGuard MCP is an open-source, local-first Model Context Protocol (MCP) server for controlled AI access to software projects.
It is designed for coding agents that need to inspect, modify, test, and resume work on projects without receiving unrestricted access to the entire machine.
Status: early development —
0.2.0-alpha.1.
What the current alpha does
persistently register project workspaces only below explicitly allowed roots
read, atomically write, and exactly patch guarded UTF-8 files
list bounded directory trees and search project text
block common sensitive files such as
.env, private keys, PEM/key files, and credentials filesredact several common token/private-key patterns before returning content
reject lexical traversal and symlink escapes
run
git statusandgit diffwithout a shelloptionally run explicitly allowlisted executables with
shell: falseapply fail-closed per-project policies stored outside project workspaces
enforce mandatory test/build/analyze gates before transaction apply
maintain a structured local JSONL audit log without file bodies or command arguments
start isolated Git worktree transactions
edit, inspect, test, apply, or abort transaction changes without touching the original until apply
refuse transaction apply when the original repository has moved or become dirty
persist and recover valid active transactions after ForgeGuard restarts
reject recovered transaction records that do not match an authorized registered project/worktree
maintain a persistent Project Brain with project context, tasks, progress notes, and decisions
resume task state across ChatGPT/Codex/other MCP client sessions with
task_resume
Related MCP server: WorkspaceGuard MCP
Security defaults
ForgeGuard is intentionally fail-closed.
Important environment variables:
FORGEGUARD_ALLOWED_ROOTS: directories below which projects may be registered. Missing meansproject_registeris denied.FORGEGUARD_COMMANDS: comma-separated executables permitted through generic process tools. Empty by default.FORGEGUARD_STATE_DIR: persistent ForgeGuard state directory. Defaults to~/.forgeguard.FORGEGUARD_MAX_OUTPUT_BYTES: maximum captured process output. Defaults to 1 MiB.
Generic process execution is disabled until the local user explicitly enables commands.
ForgeGuard is not yet an operating-system sandbox. An explicitly permitted executable or repository script can still access OS resources outside the workspace. Git worktree transactions isolate repository changes, not operating-system capabilities.
See SECURITY.md for the current security boundary.
Requirements
Node.js 20+
npm
Git for Git tools and transactions
Install
git clone https://github.com/KatoteshiKuka/forgeguard-mcp.git
cd forgeguard-mcp
npm install
npm run buildConfigure allowed project roots
macOS / Linux
export FORGEGUARD_ALLOWED_ROOTS="$HOME/Projects"
npm startMultiple roots use the operating-system path delimiter:
export FORGEGUARD_ALLOWED_ROOTS="$HOME/Projects:$HOME/Work"Windows PowerShell
$env:FORGEGUARD_ALLOWED_ROOTS = "C:\Users\you\Projects"
npm startMultiple Windows roots are separated with ;.
Optional command execution
process_run and transaction_process_run have no allowed commands by default.
export FORGEGUARD_COMMANDS="npm,flutter,dart"Commands are spawned as an executable plus argv with shell: false. Shell chaining/substitution syntax is not interpreted by ForgeGuard itself.
Persistent state
By default ForgeGuard stores local state under:
~/.forgeguard/
├── projects.json
├── transactions.json
├── audit.jsonl
├── policies/
├── brain/
└── worktrees/Override it with:
export FORGEGUARD_STATE_DIR="$HOME/.local/share/forgeguard"Per-project policy and apply gates
After registering a project, call project_policy_get to see its effective policy and policy file path.
Example Node policy:
{
"allowFileRead": true,
"allowFileWrite": true,
"allowGitRead": true,
"allowProcessRun": true,
"allowedCommands": ["npm"],
"applyGates": [
{ "command": "npm", "args": ["test"], "timeoutMs": 180000 },
{ "command": "npm", "args": ["run", "build"], "timeoutMs": 180000 }
]
}allowedCommands can only narrow the global FORGEGUARD_COMMANDS set. A project policy cannot grant a command that the local administrator did not enable globally.
If an apply gate exits non-zero, times out, or uses a non-authorized command, transaction_apply is refused and the original project remains unchanged. The transaction stays available for correction or abort.
See docs/policies.md.
MCP client configuration
After npm run build, configure an MCP client to launch the compiled server over stdio.
{
"mcpServers": {
"forgeguard": {
"command": "node",
"args": ["/absolute/path/to/forgeguard-mcp/dist/index.js"],
"env": {
"FORGEGUARD_ALLOWED_ROOTS": "/Users/you/Projects",
"FORGEGUARD_COMMANDS": "npm,flutter,dart"
}
}
}
}Adapt the surrounding configuration format to the MCP client you use.
Current MCP tools
Projects and policy
project_registerproject_listproject_infoproject_policy_get
Filesystem
file_readfile_writefile_patchdirectory_treecode_search
Git
git_statusgit_diff
Processes
process_run
Transactions
transaction_begintransaction_listtransaction_statustransaction_difftransaction_file_readtransaction_file_writetransaction_file_patchtransaction_process_runtransaction_applytransaction_abort
Project Brain
project_context_getproject_context_settask_createtask_listtask_gettask_updatetask_resumedecision_adddecision_list
Audit
audit_recent
Recommended agent workflow
project_register
↓
task_create / task_resume
↓
transaction_begin
↓
inspect / edit / patch inside transaction
↓
transaction_process_run (optional manual checks)
↓
transaction_diff
↓
transaction_apply
│
├── mandatory policy gates run
├── refuses if original repo changed or became dirty
└── commit/cherry-pick + cleanup if everything passes
↓
task_update / decision_addIf ForgeGuard or the MCP client restarts while a valid transaction is open, ForgeGuard can recover it from local state after validating it against the registered project and managed worktree directory.
See docs/transactions.md and docs/project-brain.md.
Development
npm install
npm run build
npm testThe suite covers path traversal, symlink escape, sensitive-file handling, atomic writes, project persistence, per-project policy narrowing, apply gates, audit metadata, Project Brain concurrency/persistence, real Git worktree apply/abort/recovery, tampered recovery state, and real MCP stdio restart/handoff flows.
GitHub Actions runs build and tests on Node.js 20 and 22.
Roadmap
Next
named command profiles (
test,analyze,build) with project stack detectionricher transaction diff/risk summaries
task-to-transaction linking and automatic progress checkpoints
project context compiler that selects task-relevant files/symbols/tests
safer process isolation using OS/container sandboxing
Later
remote device agent
multi-machine support
richer handoff between ChatGPT, Codex, IDE agents, and scheduled workers
code graph / symbol dependency index
optional local UI for approvals, audit, tasks, and active transactions
License
Apache License 2.0. See LICENSE.
Available Tools
11 toolscode_searchA
Search UTF-8 project files for an exact text fragment, ignoring generated/vendor directories and sensitive files.
Inputs: query (required), projectId (required), maxResults.
directory_treeA
List a bounded directory tree inside a registered workspace while hiding sensitive files.
Inputs: projectId (required), path, maxDepth.
file_patchA
Replace exactly one matching text block in a UTF-8 project file. Fails when the match is missing or ambiguous.
Inputs: path (required), newText (required), oldText (required), projectId (required).
file_readA
Read a UTF-8 file inside a registered workspace. Traversal, symlink escapes, sensitive files, and known secret patterns are guarded.
Inputs: path (required), projectId (required).
file_writeA
Create or replace one UTF-8 file inside a registered workspace. Sensitive paths and symlink targets are rejected.
Inputs: path (required), content (required), projectId (required).
git_diffB
Run a non-mutating git diff inside a registered project.
Inputs: projectId (required), staged.
git_statusA
Run git status --short inside a registered project without invoking a shell.
Inputs: projectId (required).
process_runA
Run one explicitly allowlisted executable in a project workspace using argv directly (no shell). Disabled by default until FORGEGUARD_COMMANDS is configured.
Inputs: command (required), projectId (required), args, timeoutMs.
project_infoB
Get one registered project by id.
Inputs: projectId (required).
project_listA
List project workspaces registered for this ForgeGuard process.
Inputs: no named parameters.
project_registerA
Register a project directory. The directory must be inside a locally configured allowed root.
Inputs: root (required), name.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 11 tools
Each tool maps to a distinct operation and resource type: workspace registration, file read/write/patch, git read-only inspection, directory/search, and process execution. Even potentially similar tools like file_patch and file_write are clearly separated by exact-match replacement versus full-file write.
All names use lowercase underscores, but the convention is mixed: some are verb-final like file_read and process_run, while others are noun compounds like git_status, directory_tree, and code_search. This is readable but not as predictable as a uniform verb_noun pattern.
Eleven tools is well-scoped for a secure file/git/process workspace server. Each tool has a distinct purpose, and none feel redundant or unnecessary.
The core workflows of registering workspaces, reading/writing/patching files, searching, and inspecting git state are covered. Minor gaps like no project unregister or file deletion are workable but not fatal for typical guarded agent tasks.
Maintenance
Related MCP Connectors
Persistent cloud workspaces for AI agents: run commands, edit files, use git and a browser.
Securely search and manage workspace context files for AI agents and teams.
The trust harness for AI agents. Set what an agent can do before it acts.
Project memory, documentation and controlled secret access for AI coding agents.
Related MCP Servers
- AlicenseAqualityDmaintenanceEnables AI agents to autonomously navigate a codebase by listing directories, reading files, searching code, and running whitelisted commands.521 npmISC
- AlicenseNot gradedqualityCmaintenanceEnables 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
- FlicenseAqualityBmaintenanceEnables coding agents to perform workspace-confined file operations, read-only Git inspection, and structured shell commands, while requiring out-of-band human approval for mutations and external executions and maintaining an audit trail.143-
- AlicenseNot gradedqualityBmaintenanceEnables AI clients to safely read, search, understand, and edit local project code and files, with Git inspection, code indexing, and controlled command execution within permissioned workspaces.4 npm6MIT