Skip to main content
Glama
README.md
# Union MCP

[English](README.md) | [繁體中文](README.zh-TW.md)

[![Node.js](https://img.shields.io/badge/node-%3E%3D22.13%20%7C%7C%20%3E%3D23.4-339933)](https://nodejs.org/)
[![TypeScript](https://img.shields.io/badge/TypeScript-7.0-3178C6)](https://www.typescriptlang.org/)
[![MCP Tools](https://img.shields.io/badge/MCP-22%20fixed%20tools-111827)](https://modelcontextprotocol.io/)
[![Platform](https://img.shields.io/badge/platform-Windows-0078D4)](docs/configuration.md)
[![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)

A lightweight, native local Model Context Protocol (MCP) host that delivers mandatory rules before protected operations, maintains durable operation receipts across restarts, and connects local or web AI agents (ChatGPT, Gemini, Claude, Cursor, Codex) to your Windows machine without virtual OS layers or wrapper runtimes.

> [!WARNING]
> **Security boundary**: Union MCP executes with your native local OS user permissions. It is **not** an OS sandbox. Never expose its HTTP server directly to the public internet; always keep HTTP bound to `127.0.0.1` behind Cloudflare Tunnel and Cloudflare Access OAuth (or use OpenAI Secure MCP Tunnel over stdio). See [SECURITY.md](SECURITY.md).

---

## Setup with an AI Agent

If you use a coding agent (Claude Code, Codex, Cursor, Antigravity, etc.), paste this prompt to install, build, test, and configure Union MCP automatically using the concise agent runbook:

```text
Read https://github.com/Evanlau1798/union-mcp/blob/main/docs/agent-setup.md (or docs/agent-setup.md after cloning) and follow it step by step to install, build, test, and configure Union MCP on this Windows machine. Stop and ask me before entering credentials, OAuth flows, domains, or optional provider paths.
```

See [docs/agent-setup.md](docs/agent-setup.md) for the complete agent runbook.

---

## Key Features

- **Document-First Reading Gate**: Agents must open a task `context` and read all applicable core, project (`AGENTS.md` / `AGENTS.override.md`), and capability guides to EOF before protected file, process, or provider operations execute. Content is verified by SHA-256 hash on continuation and admission.
- **Native Windows Execution without Wrappers**: Runs directly on Node.js with native Windows drive/UNC paths, exact executable + `argv` launches, discovered PowerShell/shell commands, interactive `stdin`, output spools, and owned process-tree cancellation. No WSL, Bash emulation, or Docker layer required.
- **Durable Receipts and Deduplication**: Side-effecting calls require a stable `operation_id`, persist receipts with SQLite inter-process locks (`node:sqlite`), prevent silent replays of `unknown` outcomes, and support receipt inspection after host restarts.
- **Fixed 22-Tool Interface**: Exposes a predictable catalog of 9 read-only tools and 13 action tools covering files, native processes, skills, downstream MCP servers (stdio and loopback Streamable HTTP, including multi-project Unity workflows), Codex sessions, Ego Browser, Desktop automation, and read-only Antigravity history.
- **Local stdio and Authenticated Remote HTTP**: Works out of the box over `stdio` for local MCP clients and OpenAI Secure MCP Tunnel, or as a loopback-only stateless Streamable HTTP server (`POST /mcp`) protected by Cloudflare Access RS256 JWT verification for Gemini Web.
- **Duplicate-Safe Windows Logon Autostart**: Includes native PowerShell Task Scheduler scripts that start only missing services using cross-session mutexes, exact executable/argument identity checks, process-tree port verification, and Windows DPAPI token decryption.

---

## Architecture

```mermaid
flowchart LR
    subgraph Clients["MCP Clients"]
        Local["Local MCP Clients (Claude / Cursor / Codex)"]
        ChatGPT["ChatGPT Web"]
        Gemini["Gemini Web"]
    end

    subgraph Transports["Secure Transports"]
        Stdio["Local stdio"]
        OpenAITunnel["OpenAI Secure MCP Tunnel (stdio)"]
        CFTunnel["Cloudflare Tunnel + Access OAuth (RS256 JWT)"]
    end

    subgraph Host["Union MCP Host (Node.js)"]
        Gate["Document-First Gate + Context Store"]
        Store["Durable Receipts + SQLite Lock + Output Spool"]
    end

    subgraph Capabilities["Built-in & Optional Providers"]
        Native["Files, Search, Run, Jobs, Skills"]
        Downstream["Downstream MCP (stdio / loopback HTTP)"]
        History["Antigravity Read-Only History"]
        Optional["Optional: Codex, Ego Browser, agent-desktop / cua-driver"]
    end

    Local --> Stdio --> Gate
    ChatGPT --> OpenAITunnel --> Gate
    Gemini --> CFTunnel --> Gate
    Gate <--> Store
    Gate --> Native
    Gate --> Downstream
    Gate --> History
    Gate --> Optional
```

---

## Quick Start (Local stdio)

### Prerequisites

- **OS**: Windows 10 or Windows 11 (primary tested platform; non-Windows environments are unverified)
- **Node.js**: `^22.13.0` or `>=23.4.0` (required for unflagged built-in `node:sqlite`; Node 20 is not supported)

### 1. Clone, Install, Build, and Test

Run in native PowerShell:

```powershell
git clone https://github.com/Evanlau1798/union-mcp.git
cd union-mcp
npm.cmd ci --ignore-scripts --no-audit --no-fund
npm.cmd run typecheck
npm.cmd run build
npm.cmd test
```

### 2. Configure Your MCP Client

Point your MCP client at the compiled `dist\server.js` using exact absolute paths (template: [examples/mcp-client.example.json](examples/mcp-client.example.json)):

```json
{
  "mcpServers": {
    "union-mcp": {
      "command": "C:\\Program Files\\nodejs\\node.exe",
      "args": ["C:\\path\\to\\union-mcp\\dist\\server.js"]
    }
  }
}
```

> [!NOTE]
> Running `node dist\server.js` directly without `UNION_MCP_HTTP_CONFIG` starts the stdio MCP server and waits for JSON-RPC messages on `stdin`. It is not an interactive CLI shell. `stdout` carries protocol frames only; diagnostics are written to `stderr`.

### 3. Verify with a Read-Only Prompt

Once connected in your MCP client, send this verification prompt (replace the path with your local repository path):

```text
Verify the Union MCP connection using read-only operations only:

1. Call context(action="open", cwd="C:/path/to/union-mcp", task="Read-only setup check").
2. Read every document in required_documents to EOF using read and following next_cursor.
3. Read C:/path/to/union-mcp/package.json and report its package name, version, and full snapshot SHA-256.
4. Call task_close to close this context and report context_id, closed, and owned_jobs.

Do not run commands, edit files, or access desktop/browser tools.
```

A valid verification returns a real `context_id`, the parsed package fields with a SHA-256 digest, and `closed: true`.

---

## Tool Catalog (22 Fixed Tools)

Union MCP exposes a fixed catalog (`catalog_revision: union-mcp-0.7.0`). Optional external providers stay cleanly disabled until their paired environment variables are configured.

| Category | Tools | Access | Required Guide(s) | Notes |
|---|---|---|---|---|
| **Context & Gate** | `context`, `read`, `task_close` | Mixed | `core` + project rules | Opens task scope, delivers documents/files via cursors, releases snapshots and owned providers |
| **Discovery & Skills** | `discover` | Read-only | `core` (+ `guide:skills`) | Inspects tool schemas, local/configured skill catalogs, and imported MCP previews without spawning providers |
| **Native Files** | `search`, `write`, `edit` | Read / Write | `core` + project rules | UTF-8 search and atomic writes/edits with `operation_id` deduplication and optional `expected_sha256` |
| **Native Processes** | `run`, `job` | Action | `guide:native-exec`, `guide:output` | Runs exact executables or discovered shells (`oneshot` / `interactive` / `service`) with spooled output and process-tree cancel |
| **Downstream MCP** | `mcp` | Action | `guide:mcp` | Previews JSON/TOML configs safely; connects stdio or loopback Streamable HTTP servers (including multi-project Unity) |
| **Codex Sessions** | `codex_list`, `codex_status`, `codex_read`, `codex_send`, `codex_resume`, `codex_stop`, `codex_watch` | Read / Action | `guide:codex` | Optional; inspects and controls existing Codex Desktop and Windows daemon threads without auto-compaction |
| **Browser** | `browser_use` | Action | `guide:browser`, `guide:native-exec` | Optional; runs scoped JavaScript in an explicit Ego Browser TaskSpace after reading the installed Ego guide |
| **Desktop / CUA** | `computer_use` | Action | `guide:desktop`, `guide:native-exec`, `guide:mcp` | Optional; pinned `agent-desktop` (1.3.1) and supplemental `cua-driver` (0.70.7) with explicit background/foreground lanes |
| **Antigravity History** | `antigravity_list`, `antigravity_status`, `antigravity_read` | Read-only | `guide:antigravity` | Reads persisted SQLite WAL public messages across `app`, `ide`, and `cli` sources; never controls or wakes sessions |

Full tool contracts, capacity limits, and protocol details are documented in [docs/tools-and-architecture.md](docs/tools-and-architecture.md).

---

## Remote Web Access (ChatGPT & Gemini)

Union MCP supports both major web agent platforms with distinct private transport models:

| Surface | Recommended Transport | Local Mode | Setup Guide |
|---|---|---|---|
| **ChatGPT Web** | OpenAI Secure MCP Tunnel | `stdio` backend | [docs/web-mcp-setup.md#2-chatgpt-web](docs/web-mcp-setup.md#2-chatgpt-web-openai-secure-mcp-tunnel) |
| **Gemini Web** | Cloudflare Tunnel + Cloudflare Access OAuth | Loopback HTTP (`POST /mcp`) | [docs/web-mcp-setup.md#3-gemini-web](docs/web-mcp-setup.md#3-gemini-web-cloudflare-tunnel--access-oauth) |

Both remote backends can be started automatically at Windows user logon using [docs/autostart.md](docs/autostart.md).

---

## Documentation

| Document | Description |
|---|---|
| [docs/agent-setup.md](docs/agent-setup.md) | Concise, staged setup runbook designed for AI agents with strict credential guardrails |
| [docs/configuration.md](docs/configuration.md) | Complete environment variable reference, local MCP client setup, Skills, and optional providers |
| [docs/web-mcp-setup.md](docs/web-mcp-setup.md) | From-scratch setup for ChatGPT Web (OpenAI Tunnel) and Gemini Web (Cloudflare Tunnel + Access), verification prompts, and known platform limits |
| [docs/autostart.md](docs/autostart.md) | Windows Task Scheduler logon autostart, duplicate-safe service startup, and DPAPI token protection |
| [docs/tools-and-architecture.md](docs/tools-and-architecture.md) | Detailed 22-tool reference, document-first gate lifecycle, durable receipts, output spool, and capacity limits |
| [docs/troubleshooting.md](docs/troubleshooting.md) | Error code reference, remote connection debugging, schema sync, and provider troubleshooting |
| [examples/](examples/) | Sanitized configuration templates for MCP clients, HTTP mode, Skill sources, launchers, and Windows autostart |
| [SECURITY.md](SECURITY.md) | Trust boundaries, authentication design, and vulnerability reporting |
| [CONTRIBUTING.md](CONTRIBUTING.md) | Development workflow, coding standards, and pull request checklist |

---

## Development

```powershell
npm.cmd run typecheck   # Strict TypeScript type checking
npm.cmd run build       # Compile TypeScript to dist/
npm.cmd test            # Run full test suite (node:test)
```

---

## License

Licensed under the [MIT License](LICENSE).

TDQS

B3.1/5.0

Scored across 22 tools

Disambiguation4/5

Most tools target clearly distinct surfaces: core files, execution, MCP, browser/computer use, and prefixed Antigravity/Codex backends. The only notable overlap is codex_send versus codex_resume, both of which message an existing Codex thread, though the descriptions help distinguish them.

Naming Consistency3/5

There are recognizable subsystem prefixes such as antigravity_* and codex_*, but the overall set mixes bare verbs (read, search, run), noun-only names (job, mcp, context), and noun_verb names (task_close, browser_use, computer_use). It remains readable, but the convention is not predictable across the server.

Tool Count3/5

At 22 tools this is a heavy surface, falling into the borderline 16–25 range. The broad local-orchestration scope explains some size, but the many Codex/Antigravity-specific tools could likely be consolidated without losing coverage.

Completeness4/5

The set covers core file operations, execution/job handling, MCP, browser/computer use, context/task lifecycle, and multiple agent backends. There are minor gaps such as no dedicated file delete or new Codex-thread creation, but native execution can work around some file-management omissions.

Maintenance

ActivityMaintained
ResponsivenessNo recent community issues