HU

Human-in-the-Loop MCP Server for Real-Time AI Feedback

Enable real-time human feedback with an MCP server that adds intuitive GUI dialogs for choices, confirmations, and interactive AI-assisted decisions.

Quick Install
npx -y @GongRzhe/Human-In-the-Loop-MCP-Server

Overview

This project implements a Model Context Protocol (MCP) server that brings human-in-the-loop (HITL) controls into real-time AI interactions. It exposes a lightweight server layer that can interpose GUI-style dialogs (choices, confirmations, free-text prompts) into an AI agent’s context stream so a human operator can review, approve, or steer decisions before they propagate to downstream systems.

The server is useful when you need low-friction, interactive oversight for LLM-driven workflows: validation of high-risk outputs, guided decision-making that mixes machine suggestions with human judgment, or data labeling with contextual prompts. It aims to be easy to integrate with existing LLM clients by speaking MCP over HTTP/WebSocket and providing a small web GUI and client SDK for presenting dialog widgets to human reviewers.

Features

  • Real-time dialog injection via MCP-compatible endpoints (HTTP + WebSocket).
  • Built-in GUI dialogs: multiple-choice, confirmations, free-text input, and short forms.
  • Pluggable client SDK for quickly showing dialogs inside a web UI or embedding in operator consoles.
  • Simple authentication and configuration options for deployment behind a reverse proxy or in internal networks.
  • Logging and audit trails for decisions captured during human review.
  • Example integrations and starter templates to connect with LLM pipelines.

Installation / Configuration

Quick start (Node.js example):

# Clone the repository
git clone https://github.com/GongRzhe/Human-In-the-Loop-MCP-Server.git
cd Human-In-the-Loop-MCP-Server

# Install dependencies
npm install

# Run locally
npm start

Environment variables (example .env):

PORT=4000               # HTTP server port
WS_PORT=4001            # WebSocket port (if separate)
MCP_SECRET=your_secret  # Simple shared secret for client/server authentication
LOG_LEVEL=info          # logging verbosity: debug|info|warn|error

Configuration can also be provided via a JSON file. Example config.json:

{
  "port": 4000,
  "wsPath": "/mcp-ws",
  "auth": {
    "type": "shared_secret",
    "secret": "your_secret"
  },
  "dialogs": {
    "timeoutSeconds": 300
  }
}

Start the server by pointing it to the config file:

node server.js --config=config.json

Available Tools / Resources

  • Web GUI: lightweight HTML/JS UI that renders dialogs and pushes responses back to the MCP server.
  • Client SDK (JavaScript): helper functions for connecting over WebSocket and opening dialogs in the GUI.
  • Example integrations: basic connector templates for inserting human-validated responses into LLM agent loops.
  • Audit logs: structured JSON logs that capture dialog metadata, timestamps, user IDs, and responses for compliance.

Example of a minimal client SDK call (JavaScript):

import { connectMCP } from './client-sdk';

const conn = await connectMCP({ url: 'ws://localhost:4001/mcp-ws', secret: 'your_secret' });

const response = await conn.requestDialog({
  type: 'choice',
  prompt: 'Select best answer',
  choices: ['A', 'B', 'C']
});

console.log('Human selected:', response.value);

Use Cases

  • Content moderation and approval: Present potentially problematic LLM outputs to a moderator for accept/reject or rephrase before publishing.
  • High-stakes decision support: Allow a human to confirm or override automated recommendations (e.g., medical triage suggestions or financial alerts).
  • Data labelling and quality control: Show annotators model predictions plus context to speed up labeling and reduce errors.
  • Interactive agent workflows: Agents request human guidance at decision points (e.g., which tool to call next), producing predictable, auditable outcomes.

Concrete examples

  1. Moderation workflow

    • LLM generates a news summary containing potentially sensitive content.
    • Server injects a confirmation dialog with the highlighted excerpt and choices: Approve / Edit / Reject.
    • Moderator selects “Edit”, opens the text field, updates, and submits the corrected version back to the pipeline.
  2. Assisted form-filling

    • LLM suggests filled fields for a complex form.
    • Server presents a compact review dialog listing suggested values and a Confirm/Modify action.
    • Human confirms, and the system saves the verified values.
  3. Decision branching for agents

    • Conversational agent reaches a branching point and requests human preference between two actions.
    • Server shows a multiple-choice dialog. The human’s selection drives the next agent action.

Dialog Types (quick reference)

TypeDescriptionTypical Use
choicePresent multiple labeled optionsAction selection
confirmBinary accept/decline confirmationApprovals
free_textAsk the human to provide or edit textRewrites, comments
formSmall structured inputs (key/value)Data verification

Next Steps

  • Browse the GitHub repository for detailed examples and deployment notes: https://github.com/GongRzhe/Human-In-the-Loop-MCP-Server
  • Try the example integrations to connect this MCP server to your LLM pipeline and adapt the GUI to your operator workflows.
  • Review logging and authentication settings before production deployment to meet security and compliance needs.