human-loop-mcp

human-loop-mcp

Enables AI agents to ask human operators questions through polished browser dialogs, supporting text/choice/confirmation inputs and file attachments.

Category
访问服务器

README

<h1 align="center"> human-loop-mcp </h1>

<p align="center"> <strong>Browser-based human-in-the-loop MCP server</strong><br> Ask your AI agent to ask <em>you</em> — via polished browser dialogs. </p>

<p align="center"> <a href="#features">Features</a> · <a href="#install">Install</a> · <a href="#quick-start">Quick Start</a> · <a href="#tools">Tools</a> · <a href="#file-attachments">Attachments</a> · <a href="#configuration">Configuration</a> · <a href="#architecture">Architecture</a> · <a href="#development">Development</a> </p>


What Is This?

An MCP (Model Context Protocol) server that gives AI agents a way to ask the human operator questions through the browser.

  1. A lightweight localhost HTTP server spins up
  2. Your default browser opens a dialog page
  3. You fill in the form (optionally attaching files) and submit
  4. The response flows back to the agent through MCP

No Python, no Tkinter, no Electron — just a Node.js process, a browser tab, and clean HTML.

Why?

GUI-based human-in-the-loop tools often break on macOS (Accessibility permissions, focus stealing, Python framework builds). This project sidesteps all of that by using the browser as the UI layer — it works everywhere Node.js runs.


Features

7 MCP tools Text input, multiline, choice, confirmation, info, health check, and usage guidance
File attachments Drag-and-drop, paste, or click-to-upload files in the multiline dialog. Files are base64-encoded and returned alongside the text response (5 MB per-file limit)
Autocomplete @ files, # GitHub issues/PRs, / slash commands, ? keyboard shortcuts
Dark/light mode Follows system preference automatically
Keyboard-first Cmd+Enter submit, Esc cancel, arrow-key navigation in dropdowns
Command-palette UI Linear/Raycast-inspired design with purple accents, monospace labels, noise texture background
Zero bloat Only two runtime dependencies: @modelcontextprotocol/sdk and zod
Single-file HTML No static assets, no bundler — fully server-rendered

Install

npm (recommended)

npm install -g human-loop-mcp

Or run directly without installing:

npx human-loop-mcp

From source

git clone https://github.com/dzulfiikar/human-loop-mcp.git
cd human-loop-mcp
npm install
npm run build

Quick Start

Claude Desktop

Add to ~/Library/Application Support/Claude/claude_desktop_config.json:

{
  "mcpServers": {
    "human-loop": {
      "command": "npx",
      "args": ["-y", "human-loop-mcp"]
    }
  }
}

Cursor / Windsurf

Add to .cursor/mcp.json or equivalent:

{
  "mcpServers": {
    "human-loop": {
      "command": "npx",
      "args": ["-y", "human-loop-mcp"]
    }
  }
}

GitHub Copilot CLI

[mcp_servers.human-loop]
command = "npx"
args = ["-y", "human-loop-mcp"]

From source (development)

[mcp_servers.human-loop-dev]
command = "npx"
args = ["tsx", "/path/to/human-loop-mcp/src/index.ts"]

Tools

Tool Description
get_user_input Single-line text, password, integer, or float input
get_user_choice Single or multi-select from a list of choices
get_multiline_input Large text area with autocomplete and file attachments
show_confirmation_dialog Binary confirm/cancel dialog
show_info_message Informational message with acknowledgement
get_human_loop_prompt Returns guidance text on when to use the tools
health_check Returns server health status and available tools

Example: Text Input

{
  "title": "API Key",
  "prompt": "Enter your OpenAI API key:",
  "input_type": "password"
}

Example: Choice

{
  "title": "Database",
  "prompt": "Which database should I use?",
  "choices": ["PostgreSQL", "MySQL", "SQLite"],
  "allow_multiple": false
}

Example: Confirmation

{
  "title": "Deploy",
  "message": "Deploy v2.1.0 to production?",
  "confirm_label": "Deploy",
  "cancel_label": "Abort"
}

File Attachments

The get_multiline_input dialog supports file attachments through three methods:

Method How
Drag and drop Drag files onto the textarea — a drop overlay appears
Paste Cmd+V / Ctrl+V with an image or file in the clipboard
Upload button Click the paperclip "Attach" button below the textarea

Attachment behavior

  • Any file type is accepted
  • 5 MB per-file limit — oversized files are rejected with an inline error
  • Files are base64-encoded and returned in the tool result alongside the text value
  • Image previews are shown as thumbnails in the attachment chips
  • Each chip shows the file name, size, and a remove button
  • When no files are attached, the result is identical to the previous format (fully backward-compatible)

Result format

When attachments are present, the get_multiline_input tool returns:

{
  "action": "submit",
  "value": "Here is the screenshot",
  "attachments": [
    {
      "name": "screenshot.png",
      "type": "image/png",
      "size": 48210,
      "data": "iVBORw0KGgo..."
    }
  ]
}

When no attachments are provided, the attachments field is omitted entirely.


Configuration

Environment variables

Variable Default Description
HITL_HOST 127.0.0.1 HTTP server bind address
HITL_PORT (ephemeral) Fixed HTTP port. If unset, the OS assigns a random port
HITL_NO_LAUNCH (unset) Set to 1 to print dialog URLs to stderr instead of auto-opening the browser

Programmatic usage

import { BrowserDialogServer } from "human-loop-mcp/browser/browser-dialog-server";

const server = new BrowserDialogServer({
  port: 8080,
  launchUrl: async (url) => {
    console.log(`Open: ${url}`);
  },
});

Architecture

┌──────────────────────────────────────────┐
│           MCP Client (AI Agent)          │
│      Claude / Cursor / Copilot CLI       │
└──────────────┬───────────────────────────┘
               │ stdio (JSON-RPC)
┌──────────────▼───────────────────────────┐
│  index.ts        Tool registration       │
│  service.ts      Business logic          │
│  browser-dialog-server.ts   HTTP + APIs  │
│  dialog-session-manager.ts  Sessions     │
│  html.ts         HTML/CSS/JS renderer    │
└──────────────┬───────────────────────────┘
               │ HTTP (localhost)
┌──────────────▼───────────────────────────┐
│         Browser Dialog UI                │
│  Forms · Autocomplete · Attachments      │
│  Dark/light · Keyboard shortcuts         │
└──────────────────────────────────────────┘

Data flow

  1. MCP client calls a tool (e.g. get_multiline_input) via stdio JSON-RPC
  2. index.ts routes the call to HumanLoopService
  3. service.ts transforms args and calls BrowserDialogServer.openDialog()
  4. browser-dialog-server.ts creates a session, starts HTTP if needed, opens the browser
  5. html.ts renders a self-contained HTML page with the dialog form
  6. User submits (with optional file attachments) — the POST handler validates and resolves the session promise
  7. Response flows back through MCP to the AI agent, including any base64-encoded attachments

Development

npm install          # Install dependencies
npm run dev          # Run from source (tsx, hot-reload)
npm run build        # Compile to dist/
npm test             # Run tests (Vitest)
npm run typecheck    # Type-check without emitting

Project structure

src/
├── index.ts                       MCP server entry point & tool registration
├── service.ts                     Tool handler business logic
└── browser/
    ├── browser-dialog-server.ts   HTTP server, browser launcher, API endpoints
    ├── dialog-session-manager.ts  Session lifecycle, validation & attachment types
    └── html.ts                    Dialog page renderer (forms, autocomplete, attachments)

tests/
├── service.test.ts
├── dialog-session-manager.test.ts
└── browser-dialog-server.test.ts

Contributing

See CONTRIBUTING.md for development setup, code style, and PR guidelines.

License

MIT

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选