HITL MCP CLI
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.
๐ค HITL MCP CLI
Human-in-the-Loop MCP Server โ Bridge the gap between AI autonomy and human judgment
โโโ โโโโโโโโโโโโโโโโโโ โโโโ โโโโ โโโโโโโโโโโโโโ
โโโ โโโโโโโโโโโโโโโโโโ โโโโโ โโโโโโโโโโโโโโโโโโโโโ
โโโโโโโโโโโ โโโ โโโ โโโโโโโโโโโโโโ โโโโโโโโ
โโโโโโโโโโโ โโโ โโโ โโโโโโโโโโโโโโ โโโโโโโ
โโโ โโโโโโ โโโ โโโโโโโโ โโโ โโโ โโโโโโโโโโโโโโ
โโโ โโโโโโ โโโ โโโโโโโโ โโโ โโโ โโโโโโโโโโ๐ฏ Why Human-in-the-Loop?
AI agents are transforming how we work, but they shouldn't operate in isolation. HITL MCP CLI enables AI agents to request human input at critical decision points, combining the speed of automation with the wisdom of human judgment.
The Problem
AI agents face situations where they need human guidance:
๐ค Ambiguity: Requirements aren't always clear-cut
โ ๏ธ Risk: Some operations are too sensitive to automate blindly
๐จ Preference: Multiple valid approaches exist, but humans have context
โ Validation: Assumptions need confirmation before proceeding
The Solution
HITL MCP CLI provides a standardized, elegant interface for AI agents to request human input without breaking their workflow. Instead of agents making potentially wrong assumptions or halting entirely, they can:
Ask clarifying questions when requirements are ambiguous
Request approval before destructive or sensitive operations
Present options and let humans choose the best approach
Confirm assumptions to ensure alignment with human intent
Real-World Scenarios
๐ค Agent: "I found 3 ways to implement this feature. Which approach do you prefer?"
๐ค Human: [Selects Option B: Balanced performance and maintainability]
๐ค Agent: "Implementing Option B..."
๐ค Agent: "I'm about to delete 150 deprecated files. Proceed?"
๐ค Human: "Yes, proceed"
๐ค Agent: "Deleted 150 files. โ
Complete"
๐ค Agent: "Should I deploy to staging or production?"
๐ค Human: "Staging first"
๐ค Agent: "Deploying to staging environment..."Related MCP server: Relay
โจ Features
๐ฏ 5 Interactive Tools: Collect input, ask questions, choose from options, confirm actions, and send notifications
๐ฅ๏ธ Full TUI: Textual-based terminal UI with sessions panel, queue history, and collapsible messages
๐ Instant Setup: Works with
uvxโ no installation required๐ MCP Standard: Seamless integration with any MCP-compatible AI agent
โก Lightning Fast: Async-first design with minimal overhead
๐ก๏ธ Type-Safe: Full type hints for reliability and IDE support
๐ Interaction Logging: All tool calls logged to
~/.local/state/hitl-mcp/interactions.jsonl๐ง Customizable: Customize host/port, log level
โ ๏ธ Critical Configuration
Timeout Setting Required: HITL operations require infinite timeout because human response time is unpredictable. Without this, tool calls will fail after 60 seconds.
Set "timeout": 0 in your MCP client configuration (see below).
๐ Quick Start
Installation
# Run directly without installation (recommended)
uvx hitl-mcp-cli
# Or install globally
uv tool install hitl-mcp-cliStart the Server
# Default: TUI mode on localhost:5555
hitl-mcp
# Custom host/port
hitl-mcp --host 0.0.0.0 --port 8080
# Using environment variables
export HITL_HOST=0.0.0.0
export HITL_PORT=8080
export HITL_LOG_LEVEL=INFO
hitl-mcpEnvironment Variables:
HITL_HOST: Server host (default: 127.0.0.1)HITL_PORT: Server port (default: 5555)HITL_LOG_LEVEL: Logging level - DEBUG, INFO, WARNING, ERROR (default: ERROR)HITL_NO_BANNER: Disable startup banner - true/false (default: false)
Configure Your AI Agent
Add to your MCP client configuration (e.g., Claude Desktop, Cline):
{
"mcpServers": {
"hitl": {
"url": "http://127.0.0.1:5555/mcp",
"transport": "streamable-http",
"timeout": 0
}
}
}โ ๏ธ Important: Set "timeout": 0 for infinite timeout. Human input is unpredictable - users may take seconds or minutes to respond. The default 60-second MCP timeout will cause tool calls to fail if users don't respond quickly enough.
Note: The server runs in stateless HTTP mode, which is required for MCP clients that make independent HTTP requests (including Kiro CLI and most MCP clients).
That's it! Your AI agent can now request human input.
๐ ๏ธ Available Tools
1. hitl_collect โ Collect Input
Collect a single input value from the user. Use for text, file paths, or multiline content.
When to use:
Collecting names, descriptions, or free-form input
Getting file/directory paths with completion
Requesting multi-line content (code snippets, descriptions)
Example:
name = await hitl_collect(
message="What should we name this project?",
default="my-project",
validation_pattern=r"^[a-z0-9-]+$"
)
# Path input
config = await hitl_collect(
message="Select configuration file:",
input_type="path"
)
# Multiline input
description = await hitl_collect(
message="Enter project description:",
input_type="multiline"
)Parameters:
message(str): Question to displayinput_type(Literal["text", "path", "multiline"]): Input mode (default: "text")default(str, optional): Pre-filled valuevalidation_pattern(str, optional): Regex pattern for validationvalidation_message(str, optional): Custom validation error messagecontext(str, optional): Additional context displayed above the promptstrip_whitespace(bool): Strip leading/trailing whitespace from input (default: False)required(bool): Reject empty input (default: False)path_type(Literal["file", "dir", "any"], optional): Validate path type wheninput_type="path"agent_name(str, optional): Calling agent identifier (shown in Sessions panel)project_id(str, optional): Project identifier for session groupingstep(int, optional): Current step number (shown as "Step X/Y")total_steps(int, optional): Total steps in workflownotes(str, optional): Freeform context displayed as a dimmed line below the message
2. hitl_ask โ Ask a Question
Alias for hitl_collect. Use whichever name reads more naturally in your agent's workflow.
3. hitl_choose โ Present Choices
Present a list of options for the user to select from. Supports single or multiple selection, fuzzy search for long lists, and rich option descriptions.
When to use:
Choosing between implementation approaches
Selecting deployment environments
Picking features to enable
Example:
# Simple choices
env = await hitl_choose(
message="Which environment should I deploy to?",
choices=["Development", "Staging", "Production"],
default="Staging"
)
# Rich options with descriptions
approach = await hitl_choose(
message="Select implementation approach:",
options=[
{"value": "fast", "label": "Fast", "description": "Quick but uses more memory"},
{"value": "safe", "label": "Safe", "description": "Slower but reliable"},
]
)
# Multiple selections
features = await hitl_choose(
message="Which features should I enable?",
choices=["Authentication", "Caching", "Logging", "Monitoring"],
multiple=True
)Parameters:
message(str): Question to displaychoices(list[str], optional): Simple option stringsoptions(list[dict], optional): Rich options with value/label/descriptionmultiple(bool): Enable checkbox mode (default: False)default(str, optional): Pre-selected optionfuzzy_search(bool, optional): Force fuzzy search on/off (auto for >15 items)context(str, optional): Additional context displayed above the promptagent_name(str, optional): Calling agent identifier (shown in Sessions panel)project_id(str, optional): Project identifier for session groupingstep(int, optional): Current step number (shown as "Step X/Y")total_steps(int, optional): Total steps in workflownotes(str, optional): Freeform context displayed as a dimmed line below the message
Escape hatch: In multiple-selection mode, if the user selects all or none of the options, they are offered a free-text input to explain their intent.
4. hitl_confirm โ Get Confirmation
Ask the user to confirm or reject an action. Use severity='high' for destructive operations.
When to use:
Before destructive operations (delete, overwrite)
Before expensive operations (API calls, deployments)
Confirming assumptions or interpretations
Example:
# Standard confirmation
result = await hitl_confirm(
message="I will delete 50 unused dependencies. Proceed?",
default=False
)
if result["action"] == "accept":
...
# High severity โ requires typed "yes"
result = await hitl_confirm(
message="Delete production database?",
severity="high",
context="This will affect 10,000 active users.\nDowntime: ~30 seconds."
)
# Timed confirmation
result = await hitl_confirm(
message="Deploy to production?",
severity="high",
timeout_seconds=300
)
if result.get("timed_out"):
print("Approval timed out")Parameters:
message(str): Yes/no questiondefault(bool): Default answer (default: False)severity(Literal["low", "medium", "high"]): Confirmation intensity (default: "medium")context(str, optional): Additional context displayed in a panel above the prompttimeout_seconds(int): Seconds to wait, 0 = infinite (default: 0)agent_name(str, optional): Calling agent identifier (shown in Sessions panel)project_id(str, optional): Project identifier for session groupingstep(int, optional): Current step number (shown as "Step X/Y")total_steps(int, optional): Total steps in workflownotes(str, optional): Freeform context displayed as a dimmed line below the message
Returns: {"action": "accept"|"decline"|"cancel"}. When timeout_seconds > 0, also includes "timed_out": bool.
5. hitl_notify โ Display Notifications
Display a styled notification to the user. Non-blocking โ does not wait for input.
When to use:
Confirming successful operations
Reporting errors or warnings
Providing progress updates
Example:
await hitl_notify(
message="Successfully deployed v2.1.0 to production\n\nURL: https://app.example.com",
level="success",
title="Deployment Complete"
)
await hitl_notify(
message="The old API will be removed in v3.0",
level="warning",
title="Deprecation Warning"
)Parameters:
message(str): Detailed message (supports multi-line)level(Literal["success", "info", "warning", "error"]): Visual style (default: "info")title(str, optional): Notification titleagent_name(str, optional): Calling agent identifier (shown in Sessions panel)project_id(str, optional): Project identifier for session groupingstep(int, optional): Current step number (shown as "Step X/Y")total_steps(int, optional): Total steps in workflownotes(str, optional): Freeform context displayed as a dimmed line below the notification
๐ Usage Patterns
Pattern 1: Clarification
When requirements are ambiguous, ask specific questions:
approach = await hitl_choose(
message="I can implement this feature in two ways. Which do you prefer?",
choices=[
"Option A: Fast implementation, higher memory usage",
"Option B: Slower but more memory efficient",
"Option C: Balanced approach (recommended)"
],
default="Option C: Balanced approach (recommended)"
)Pattern 2: Approval Gate
Request approval before significant actions:
files_to_delete = find_unused_files()
result = await hitl_confirm(
message=f"I found {len(files_to_delete)} unused files. Delete them?",
default=False
)
if result["action"] == "accept":
delete_files(files_to_delete)
await hitl_notify(
message=f"Deleted {len(files_to_delete)} unused files",
level="success",
title="Cleanup Complete"
)
else:
await hitl_notify(
message="No files were deleted",
level="info",
title="Cancelled"
)Pattern 3: Information Gathering
Collect structured data through multiple prompts:
project_name = await hitl_collect(
message="Project name:",
validation_pattern=r"^[a-z0-9-]+$"
)
language = await hitl_choose(
message="Programming language:",
choices=["Python", "TypeScript", "Go", "Rust"]
)
features = await hitl_choose(
message="Select features to include:",
choices=["Testing", "Linting", "CI/CD", "Documentation"],
multiple=True
)
output_dir = await hitl_collect(
message="Output directory:",
input_type="path"
)Pattern 4: Progressive Disclosure
Start with high-level choices, then drill down:
action = await hitl_choose(
message="What would you like to do?",
choices=["Deploy", "Rollback", "View Logs", "Run Tests"]
)
if action == "Deploy":
env = await hitl_choose(
message="Deploy to which environment?",
choices=["Staging", "Production"]
)
if env == "Production":
result = await hitl_confirm(
message="Deploy to PRODUCTION?",
context="This will affect live users.",
severity="high"
)
if result["action"] == "accept":
await deploy_to_production()๐๏ธ Architecture
AI Agent (Claude, GPT, etc.)
โ HTTP (MCP Protocol)
FastMCP Server
โ Async Calls
TUI Layer (Textual)
โ Terminal I/O
UserSee docs/ARCHITECTURE.md for detailed architecture documentation.
๐ฅ๏ธ TUI Features
The Textual-based TUI provides a rich terminal interface:
Sessions panel: Shows agent names and projects, color-coded by recency (active <10min = bright, idle = normal, inactive = dim). Toggle with
ctrl+borf3.Queue panel: Full history of all requests with color-coded status (PENDING/DONE/CANCELLED). Click any row to restore a pending request or view a summary of an answered one.
Collapsible messages: Messages longer than 200 chars are collapsed by default โ click to expand, or use
ctrl+eto expand/collapse all.Step indicators: When
stepandtotal_stepsare provided, the screen header shows "Step X/Y".
Key Bindings
Key | Action |
| Quit |
| Clear activity log |
| Toggle sessions panel |
| Cycle log level (DEBUG/INFO/WARNING/ERROR) |
| Toggle sessions panel (VS Code-safe alternative) |
| Expand/collapse all collapsible messages |
| Cancel/close dialog |
๐ Logs
HITL MCP logs every tool interaction to ~/.local/state/hitl-mcp/interactions.jsonl as JSONL. Each entry includes tool name, duration, result type, and a preview of the message and result. The log auto-rotates at 10 MB.
A sample logrotate config is provided at contrib/logrotate.conf:
sudo cp contrib/logrotate.conf /etc/logrotate.d/hitl-mcp๐งช Development
Setup
git clone https://github.com/geehexx/hitl-mcp-cli.git
cd hitl-mcp-cli
uv sync --all-extrasTesting
# Run tests
uv run poe test
# With coverage
uv run pytest --cov --cov-report=html
# Lint and format
uv run poe lint
uv run poe format
# All checks
uv run poe checkSee docs/TESTING.md for comprehensive testing guide.
Manual Testing
# Run example script
uv run python example.py
# Test with FastMCP dev server
fastmcp dev hitl_mcp_cli/server.py
# Test with MCP Inspector
npx @modelcontextprotocol/inspector hitl-mcp๐ Documentation
Architecture: System design and component details
Testing Guide: Comprehensive testing documentation
Accessibility: Accessibility features and guidelines
Roadmap: Future considerations
Changelog: Version history and changes
โฟ Accessibility
HITL MCP CLI is designed to be accessible:
โ Keyboard-only navigation: All interactions work without a mouse
โ Non-color visual cues: Icons distinguish prompt types independent of color
โ Color blindness support: Icons ensure users with color vision deficiencies can use all features
โ Fuzzy search: Long choice lists (>15 items) automatically enable search filtering
โ Terminal compatibility: Works with screen readers through terminal emulators
See docs/ACCESSIBILITY.md for detailed accessibility information, testing methodology, and recommendations for users with diverse needs.
๐ป VS Code Terminal
For the best experience in VS Code's integrated terminal, add to your settings.json:
{
"terminal.integrated.allowChords": false,
"terminal.integrated.sendKeybindingsToShell": true
}This ensures Ctrl+\ (command palette) and other key bindings reach the TUI.
Note:
ctrl+bandctrl+\may be intercepted by VS Code. Add these tocommandsToSkipShellin your VS Code settings, or usef2(log level) andf3(toggle sessions) as alternatives.
๐ง Troubleshooting
Tool Calls Timeout After 60 Seconds
Problem: Tools fail with "Request timed out" error when user takes longer than 60 seconds to respond.
Solution: Set "timeout": 0 in your MCP client configuration:
{
"mcpServers": {
"hitl": {
"url": "http://127.0.0.1:5555/mcp",
"transport": "streamable-http",
"timeout": 0
}
}
}Why: The MCP protocol has a default 60-second timeout. Human input is unpredictable - users may need minutes to make decisions. Setting timeout to 0 means infinite wait.
Server Won't Start
Problem: Port already in use.
Solution: Either stop the other process using port 5555, or start the server on a different port:
hitl-mcp --port 8080Don't forget to update your MCP client configuration to match the new port.
Tools Not Appearing in Agent
Problem: Agent doesn't see the HITL tools.
Solution:
Verify the server is running (
hitl-mcpshould show startup banner)Check your MCP client configuration file location
Restart your MCP client (e.g., Claude Desktop) after configuration changes
Verify the URL matches:
http://127.0.0.1:5555/mcp
GET /mcp Returns 400 Bad Request
Problem: Seeing "GET /mcp HTTP/1.1" 400 Bad Request in logs.
Solution: This is expected behavior. The MCP endpoint only accepts POST requests with JSON-RPC messages. GET requests are not part of the MCP protocol and will return 400. This typically happens when:
A browser tries to access the endpoint
A health check system uses GET instead of POST
An agent incorrectly probes the endpoint
If you need a health check endpoint, this is tracked in docs/ROADMAP.md as a future consideration.
Verbose Server Logs
Problem: Too many INFO logs from uvicorn ("Started server process", "Waiting for application startup", etc.)
Solution: The default log level is ERROR, which suppresses these messages. If you're seeing them:
Check if
HITL_LOG_LEVELenvironment variable is set to INFO or DEBUGAccess logs only appear when
HITL_LOG_LEVEL=DEBUGTo completely silence the server:
HITL_LOG_LEVEL=ERROR hitl-mcp --no-banner
Multiline Text Input Clears Terminal
Problem: Terminal screen clears after submitting multiline text with Esc+Enter.
Solution: This has been fixed in v0.4.0. The multiline input now preserves screen content by:
Using explicit keybindings for Esc+Enter
Adding a newline after input to prevent terminal clearing
If you're still experiencing this issue, ensure you're running the latest version:
uvx hitl-mcp-cli@latest
# or
uv tool upgrade hitl-mcp-cliConnection Errors or Timeouts
Problem: Tool calls fail with connection errors or timeout errors.
Solution:
Verify server is running: Check that
hitl-mcpis running and accessibleCheck network connectivity: Ensure the MCP client can reach the server URL
Verify timeout configuration: Ensure
"timeout": 0is set in MCP client configCheck firewall settings: Ensure port 5555 (or your custom port) is not blocked
For AI Agents: If you encounter timeout or connection errors:
The error indicates a configuration or network issue, not a user cancellation
Check the troubleshooting section above
Inform the user about the error and suggest checking server status
Do not retry indefinitely - after 2-3 failures, report the issue to the user
Error Handling Best Practices
For AI Agent Developers:
When integrating HITL MCP tools, handle errors appropriately:
try:
result = await hitl_collect(message="Enter value:")
except Exception as e:
if "User cancelled" in str(e):
# User pressed Ctrl+C - respect their decision
print("Operation cancelled by user")
return
elif "timed out" in str(e).lower() or "connection" in str(e).lower():
# Configuration or network issue
print("Error: Cannot connect to HITL server")
print("Please check that hitl-mcp is running and timeout is configured")
return
else:
# Unexpected error
print(f"Unexpected error: {e}")
raiseNote:
hitl_collectandhitl_confirmreturn{"action": "cancel"}on Ctrl+C instead of raising, so check the return value first.
Error Categories:
User Cancellation (Ctrl+C): Respect the cancellation, don't retry
Timeout/Connection: Configuration issue, inform user, don't retry indefinitely
Validation Errors: User input doesn't match requirements, tool will re-prompt automatically
Unexpected Errors: Log and report to user
๐ค Contributing
Contributions are welcome! Please:
Fork the repository
Create a feature branch (
git checkout -b feature/amazing-feature)Add tests for new functionality
Ensure all tests pass (
uv run pytest)Commit your changes (
git commit -m 'Add amazing feature')Push to the branch (
git push origin feature/amazing-feature)Open a Pull Request
๐ License
Apache License 2.0 - see LICENSE for details.
๐ Acknowledgments
Built with:
๐ฌ Support
Issues: GitHub Issues
Discussions: GitHub Discussions
MCP Community: Model Context Protocol
โญ Star this repo if you find it useful!
Made with โค๏ธ for the AI agent community
v1.0.0rc1 โ MCP three-primitive idiom
As of v1.0.0rc1, the server splits its surface across the three MCP primitive types per the MCP spec idiom:
Primitive | Surface | What you get |
Tools (5) |
| Model-controlled actions; block on user response. Same signatures as v0.9.0. |
Resources (4) |
| Read-only JSON snapshots of live HITL state. Polled by clients (CC has closed subscriptions as |
Prompts (4) |
| User-controlled reusable templates for common HITL decision shapes. Invoke via slash command in the MCP host. |
What's not in v1.0
The v1.0 line ships the foundational refactor only. The following land in subsequent releases:
v1.1 โ MCP elicitation (form / URL modes per CC v2.1.76+), timeout-then-poll state machine, configurable wait-time settings.
v1.2 โ auq-mcp-server feature parity (native OS notifications, question rejection, agent-skills support), A2A v1.0 endpoint + AgentCard, phraseturner content-quality integration.
See docs/ROADMAP.md and CHANGELOG.md for the full migration guide.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelogโฆ
This server cannot be deployed
Maintenance
Related MCP Connectors
Give any AI agent a way to ask a person โ for approval, a decision, an answer or a review.
Human-input bridge for AI agents with voice-first answer links, MCP tools, and HTTP APIs.
Zero-secret MCP gateway for AI agents: risk-scored, audited calls with human-in-the-loop approval.
MCP server for your apps' tools and custom tools, plus hosted AI agents and approval-gated workflows
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceEnables AI assistants to request human input through a web interface, allowing them to pause execution and wait for responses via interactive tools like single questions, multiple choice selections, hypothesis challenges, and decision workflows.2MIT
- AlicenseNot gradedqualityDmaintenanceAdds a human-in-the-loop checkpoint to MCP-capable AI coding agents, enabling them to pause and request user feedback before executing actions.72MIT
- AlicenseAqualityBmaintenanceAn MCP server that enables AI agents to pause and request human approval or information via Slack, Telegram, or macOS dialogs before proceeding with actions.29 PyPI15Apache 2.0
- AlicenseAqualityDmaintenanceProvides a human-approval tool for MCP-compatible agents, pausing execution until a human approves or edits the action, with every decision logged.28 npm2MIT