Skip to main content
Glama

hitl-proxy

Human-in-the-Loop MCP Server for LLM Agents

A Model Context Protocol (MCP) server that enforces human approval before any LLM agent can edit files, create files, or execute shell commands.

Works with any MCP-compatible IDE: opencode, Cursor, Windsurf, VS Code Copilot, and others.


The Problem It Solves

LLMs are trained to be helpful and complete tasks — which means they tend to assume, infer, and act without checking with the human first. In a coding assistant context, this leads to:

  • Unreviewed file edits

  • Destructive commands run without warning

  • Assumed context that was never verified

hitl-proxy inserts a mandatory human checkpoint before every write operation.


Related MCP server: Agent File Guardian

How It Works

LLM wants to edit a file
        │
        ▼
  edit_hitl({ ..., approved: false })     ← First call
        │
        ▼
  HITL Proxy blocks + issues sessionToken
  Returns: "Use question() to ask the user. Token: abc-123"
        │
        ▼
  LLM uses question() → human sees options → human approves
        │
        ▼
  edit_hitl({ ..., approved: true, sessionToken: "abc-123" })  ← Second call
        │
        ▼
  HITL Proxy validates token → executes edit → logs to audit file

Enforcement Mechanisms

Mechanism

Description

Session Tokens

approved: true alone is not enough. LLM must present a valid single-use token issued during the block phase

Violation Counter

Counts how many times the LLM tried to bypass HITL. Escalates warning messages at 2+ violations

declare_intent_hitl

Optional tool for the LLM to declare intent before asking the user. Best practice flow

Self-check Block

Every blocked response includes a mandatory self-evaluation prompt for the LLM

Audit Log

NDJSON log of every action (approved or blocked) with timestamp and metadata

Path Traversal Protection

File paths are validated against HITL_PROJECT_ROOT to prevent access outside the project

Cross-platform Bash

Uses cmd /c on Windows, sh -c on Unix. Configurable timeout


Installation

# In your project directory
mkdir hitl-proxy
cd hitl-proxy

# Copy src/index.js and package.json from this repo
npm install

Configuration

opencode.json

{
  "mcp": {
    "hitl-proxy": {
      "type": "local",
      "command": ["node", "./hitl-proxy/src/index.js"],
      "enabled": true
    }
  },
  "permission": {
    "edit": "deny",
    "write": "deny"
  }
}

Critical: The "edit": "deny" and "write": "deny" permissions are mandatory. Without them, the LLM will use the native IDE tools and bypass the proxy entirely.

See config/opencode.example.json for a full example.

Environment Variables

Variable

Default

Description

HITL_PROJECT_ROOT

process.cwd()

Root directory. File paths are validated against this

HITL_AUDIT_LOG

./hitl-audit.log

Path to the NDJSON audit log file

HITL_TOKEN_TTL

300000 (5 min)

Session token TTL in milliseconds

HITL_BASH_TIMEOUT

30000 (30 sec)

Shell command timeout in milliseconds

HITL_QUESTION_TOOL

question

Name of the IDE's human-input tool

Set them in your MCP server command:

"command": ["node", "./hitl-proxy/src/index.js"],
"env": {
  "HITL_PROJECT_ROOT": "/path/to/your/project",
  "HITL_TOKEN_TTL": "600000"
}

Tools Reference

declare_intent_hitl (best practice — call before question())

Declares what the LLM intends to do and why. Returns a sessionToken.

Parameters:
  action  — "edit" | "write" | "bash"
  target  — file path or command
  reason  — why this action is needed now

edit_hitl

Edits an existing file by replacing a text fragment.

Parameters:
  filePath     — file to edit
  oldString    — exact text to replace
  newString    — replacement text
  replaceAll   — (optional) replace all occurrences, not just first
  approved     — true only if user approved via question()
  sessionToken — token from block response or declare_intent_hitl

write_hitl

Creates or overwrites a file.

Parameters:
  filePath     — file to create
  content      — full file content
  approved     — true only if user approved via question()
  sessionToken — token from block response or declare_intent_hitl

bash_hitl

Executes a shell command.

Parameters:
  command      — shell command to run
  approved     — true only if user approved via question()
  sessionToken — token from block response or declare_intent_hitl

Ideal LLM Workflow (Best Practice)

1. declare_intent_hitl({ action: "edit", target: "src/app.js", reason: "Fix typo in error message" })
   → receives sessionToken: "uuid-xxx"

2. question("¿Apruebas editar src/app.js para corregir el mensaje de error?", options: ["✅ Sí", "❌ No"])
   → user selects "✅ Sí"

3. edit_hitl({ filePath: "src/app.js", oldString: "...", newString: "...", approved: true, sessionToken: "uuid-xxx" })
   → ✅ Editado: src/app.js

Audit Log Format

Each line is a JSON object:

{"ts":"2026-08-29T21:30:00.000Z","action":"edit","target":"src/app.js","approved":true,"violations":0}
{"ts":"2026-08-29T21:31:00.000Z","action":"bash","target":"rm -rf /","approved":false,"violations":1}

Compatibility

IDE/Tool

Compatible

Notes

opencode

✅ Native

question() is built-in

Cursor

⚠️ Partial

MCP supported; question() depends on implementation

Windsurf

✅ Likely

Active MCP support

VS Code Copilot

⚠️ Partial

Growing MCP support

Custom agents

✅ Adaptable

Replace question() with any human-input mechanism

If your IDE doesn't have question(), the LLM can still ask in plain text — but there's no UI enforcement. Set HITL_QUESTION_TOOL to match your IDE's tool name.


System Prompt Integration

For maximum HITL enforcement, load docs/hitl_protocol.md as the last system instruction in your IDE config.

Tokens at the end of the context receive more attention from transformers (recency bias). Loading HITL rules last maximizes compliance.

See docs/llm_enforcement.md for the full guide on writing effective HITL system prompts.


License

MIT

Available Tools

4 tools
bash_hitlA

Ejecuta un comando shell. REQUIERE aprobación humana. ⚠️ Comandos destructivos (rm, del, drop, truncate, reset) son especialmente sensibles.

Flujo correcto (dos llamadas):

  1. Llama con approved: false → recibirás instrucciones y un sessionToken

  2. Usa question() mostrando el comando exacto y su riesgo potencial

  3. Llama de nuevo con approved: true + el sessionToken recibido

ParametersJSON Schema
NameRequiredDescriptionDefault
commandYesComando completo a ejecutar
approvedYestrue solo si el usuario aprobó via question()
sessionTokenNoToken recibido en el bloqueo previo o de declare_intent_hitl

TDQS

A4.4/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are present, so the description carries the burden. It discloses the approval gate, the two-call interaction, and warns that destructive commands (rm, del, drop, etc.) are especially sensitive. It does not detail failure modes or response format, but the core behavioral requirements are well covered.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is compact and well-structured with numbered steps and a front-loaded warning. No redundant sentences; every line contributes to correct invocation.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a HITL tool with no output schema, the description covers the essential invocation pattern, approval requirement, and risk warning. Missing only minor details like the shape of the second response or what occurs on rejection, but overall it gives an agent enough to call it correctly.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so baseline is 3. The description adds workflow-level semantics beyond the schema: it explains that approved:false is the first call and that sessionToken comes from the first lock or declare_intent_hitl, reinforcing how the parameters interlock.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description opens with a specific verb and resource: 'Ejecuta un comando shell' (execute a shell command), which is unambiguous and distinct from sibling tools like edit_hitl or write_hitl. It also immediately flags the HITL approval nature, making the tool's role clear.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description gives a concrete three-step correct flow: call with approved:false, use question() to present the command, then call with approved:true and the sessionToken. It does not explicitly contrast against sibling tools, but it provides enough procedural guidance for when and how to invoke this tool.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

declare_intent_hitlA

[MEJOR PRÁCTICA — úsalo antes de question()] Declara explícitamente qué vas a hacer y por qué, ANTES de pedir aprobación al usuario. Devuelve un sessionToken para usar en la acción final.

Flujo ideal:

  1. declare_intent_hitl({ action, target, reason }) → obtén sessionToken

  2. question() → pide aprobación al usuario

  3. edit_hitl / write_hitl / bash_hitl con approved: true + sessionToken

ParametersJSON Schema
NameRequiredDescriptionDefault
actionYesTipo de acción que vas a ejecutar
reasonYesJustificación: por qué es necesaria esta acción ahora
targetYesArchivo o comando objetivo

TDQS

A4.5/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries the disclosure burden. It explains that the tool returns a sessionToken, that it is a prerequisite for later approved actions, and that it should precede user approval. It does not elaborate on failure modes or consequences, but the core behavior is well disclosed.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is compact, front-loaded with the best-practice directive, and uses a clear numbered flow. Every sentence adds relevant information without redundancy.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a coordination tool with three required parameters and no output schema, the description fully explains the intended sequence, the returned token, and how subsequent sibling tools should be invoked. An agent has enough context to call it correctly and understand the resulting workflow.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so the schema already documents action, target, and reason. The description adds a usage example and clarifies the role of reason, but provides little additional meaning beyond the schema. Baseline 3 is appropriate.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states this tool declares intent and returns a sessionToken before user approval, distinguishing it from sibling execution tools (edit_hitl, write_hitl, bash_hitl). The verb 'declarar' plus the explicit flow makes its role unambiguous.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description explicitly instructs to use it before question(), presents a numbered ideal flow, and names the subsequent tools that require the sessionToken and approved: true. This is strong when-to-use guidance with concrete sequencing.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

edit_hitlA

Edita un archivo existente reemplazando un fragmento de texto. REQUIERE aprobación humana.

Flujo correcto (dos llamadas):

  1. Llama con approved: false → recibirás instrucciones y un sessionToken

  2. Usa question() para mostrar el cambio al usuario y pedir aprobación

  3. Llama de nuevo con approved: true + el sessionToken recibido

ParametersJSON Schema
NameRequiredDescriptionDefault
approvedYestrue solo si el usuario aprobó via question()
filePathYesRuta del archivo (relativa al PROJECT_ROOT o absoluta)
newStringYesTexto de reemplazo
oldStringYesTexto exacto a reemplazar
replaceAllNoSi true, reemplaza TODAS las ocurrencias. Default: false (solo la primera)
sessionTokenNoToken recibido en el bloqueo previo o de declare_intent_hitl

TDQS

A4.4/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the safety burden. It discloses the human-approval requirement and the two-phase behavior, including that the first call returns instructions and a sessionToken and the second call performs the edit only after approval. It does not detail error cases or the response of the approved call, but the core behavioral trait is transparent.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is compact and front-loaded: one purpose sentence, one requirement line, and a numbered flow. Every sentence earns its place, and the numbered steps make the required sequence easy to follow.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a multi-step HITL tool with no output schema and no annotations, the description covers the essential call sequence, the role of the token, and the need for question(). Minor gaps exist around what the second call returns and what happens on failure, but an agent can invoke the tool correctly from this definition.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so the baseline is 3. The description adds protocol-level meaning to 'approved' and 'sessionToken' by explaining how they relate across the two required calls, which goes beyond the individual schema field descriptions.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description opens with a specific verb+resource sentence ('Edita un archivo existente reemplazando un fragmento de texto') that clearly identifies the operation and scope. The word 'existente' and the HITL approval requirement distinguish it from siblings like write_hitl and bash_hitl.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

It provides a clear two-call protocol: call with approved:false, ask the user via question(), then call with approved:true and the sessionToken. This is strong when-to-use guidance for the HITL flow, though it does not explicitly state when not to use the tool or name alternative tools for other file operations.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

write_hitlA

Crea o sobreescribe un archivo completo. REQUIERE aprobación humana.

Flujo correcto (dos llamadas):

  1. Llama con approved: false → recibirás instrucciones y un sessionToken

  2. Usa question() para mostrar el archivo al usuario y pedir aprobación

  3. Llama de nuevo con approved: true + el sessionToken recibido

ParametersJSON Schema
NameRequiredDescriptionDefault
contentYesContenido completo del archivo
approvedYestrue solo si el usuario aprobó via question()
filePathYesRuta del archivo a crear (relativa al PROJECT_ROOT o absoluta)
sessionTokenNoToken recibido en el bloqueo previo o de declare_intent_hitl

TDQS

A4.3/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

There are no annotations, so the description carries the behavioral burden. It clearly discloses the human-approval requirement, the two-phase call pattern, and that the second call needs the sessionToken. It does not explicitly state that no write occurs on the first call, but the approved:false step strongly implies a pre-approval staging behavior.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is compact and front-loaded with the primary action and the approval requirement. The numbered flow is easy to follow, though calling it 'dos llamadas' while listing three steps (including question()) introduces a minor structural inconsistency.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a human-in-the-loop write tool with no output schema, the description covers the essential invocation flow, approval gate, and token handling. It does not describe the return value of the approved:true call or what happens if the user rejects, but the main steps an agent needs to complete a successful write are present.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the baseline is 3. The description adds meaningful workflow semantics beyond the schema by explaining the exact order of approved values and the role of sessionToken across the two calls. This helps an agent understand how the parameters interact in the full flow.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description states a specific action and resource: 'Crea o sobreescribe un archivo completo' (create or overwrite a complete file). The word 'completo' helps distinguish it from the sibling edit_hitl, which likely handles partial edits, making the tool's purpose clear and differentiated.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides a clear, structured correct flow: first call with approved:false to receive instructions and a sessionToken, then use question() for approval, then call again with approved:true. It does not explicitly mention alternatives like edit_hitl or bash_hitl, but the context for when to use this tool is clearly implied by the full-file write behavior and the approval workflow.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

  1. 4 tool updatesv2.0.0
    • First observedbash_hitl
    • First observeddeclare_intent_hitl
    • First observededit_hitl
    • First observedwrite_hitl

TDQS

A4.4/5.0

Scored across 4 tools

Disambiguation4/5

Each tool targets a distinct action (declare intent, edit, write, bash), but edit_hitl and write_hitl both handle file changes and the relationship between declare_intent_hitl's sessionToken and the per-action sessionToken is not fully clear. Overall, agents should be able to select the right tool with the guidance provided.

Naming Consistency4/5

All tools share the _hitl suffix and follow a verb prefix pattern. declare_intent_hitl uses a compound verb while the others use single verbs, creating a slight inconsistency, but the pattern remains predictable and readable.

Tool Count5/5

Four tools is well-scoped for a proxy server that adds human-in-the-loop approval to common operations. Each tool has a clear role and no redundant entries inflate the surface.

Completeness4/5

The server covers the core file edit/write and shell execution actions needed for an approval proxy, plus an explicit intent declaration step. Missing session audit/cancel tools are minor gaps that don't block the primary workflow.

Maintenance

ActivityMaintained
ResponsivenessNo issues

Related MCP Connectors

Related MCP Servers

  • A
    license
    Not graded
    quality
    Not graded
    maintenance
    Enables secure, audited file operations with LLMs by enforcing implementation plans, restricting writes to approved file scopes, and maintaining a tamper-evident audit log with stub detection.
    291 npm
    -
  • A
    license
    Not graded
    quality
    D
    maintenance
    Provides a human-in-the-loop security layer for AI agents by intercepting file operations, explaining them with a local LLM, and enforcing a deterministic policy that requires user approval for risky actions.
    MIT
  • F
    license
    Not graded
    quality
    B
    maintenance
    Enables AI coding agents to evaluate actions against team-defined policies, record decisions, and obtain human approvals for potentially risky operations.
    88 npm
    1
    -