@agentrq/acp-gateway
v0.1.23
Published
ACP+MCP bridge CLI for agentrq workspaces
Maintainers
Readme
@agentrq/acp-gateway
ACP+MCP Bridge brings Experimentation Claude Notification Channels feature to all agents that supports Agent Client Protocol.
[!WARNING] Pre-Alpha: This project is in early development. APIs, configurations, and behaviors are subject to change without notice.
Note:
claude/notificationsis an experimental feature of Claude Code.@agentrq/acp-gatewayextends this same capability to any--acpcompatible agent (e.g., Gemini CLI).
Overview
@agentrq/acp-gateway bridges the Agent Client Protocol (ACP) with the Model Context Protocol (MCP) to connect ACP-compatible AI agents (e.g., Gemini) to an agentrq MCP server.
It automates task execution by:
- Loading your workspace's
.mcp.jsonconfiguration. - Connecting to the agentrq MCP server.
- Spawning an ACP-compatible agent subprocess.
- Bridging MCP notifications (tasks, permission requests) to ACP prompts and vice versa.
- Providing file read/write capabilities through the ACP protocol.
- Auto-reconnecting the MCP transport on disconnection.
Prerequisites
- Node.js >= 24
- npm or yarn
- An ACP-compatible agent (e.g., Gemini CLI)
- An agentrq workspace with an HTTP MCP server
Installation
cd acp-gateway
npm installTo use globally:
npm install -g @agentrq/acp-gatewayCurrent Version
0.1.23
Usage
Quick Start
Run acp-gateway from your agentrq workspace root (the directory containing .mcp.json):
# From workspace root
acp-gateway -- gemini --acpOr with a custom command:
acp-gateway -- your-acp-agent --flag1 --flag2CLI Options
You can specify gateway options before the -- separator:
--max-concurrency/--maxConcurrency<number>: Sets the maximum number of concurrent tasks allowed to prompt the ACP agent at once. Defaults to2.
Example:
acp-gateway --max-concurrency 4 -- gemini --acpConfiguration
acp-gateway searches for .mcp.json starting in the current working directory and up to 3 parent directories.
Example .mcp.json:
{
"mcpServers": {
"agentrq": {
"type": "http",
"url": "http://localhost:3000/mcp"
}
}
}acp-gateway prefers servers with agentrq in the name; it falls back to the first HTTP server with a url.
How It Works
┌─────────────┐ ACP (JSON-RPC) ┌──────────────────┐
│ ACP Agent │ ◄─────────────────────────► │ │
│ (Gemini) │ │ acp-gateway │
└─────────────┘ │ │
│ MCP Bridge │
│ │
┌─────────────────────────────────────────────┤ │
│ │ │
│ │ │
│ ▼ │
│ ┌──────────────────────────┐ │
│ │ agentrq MCP Server │ │
│ │ (HTTP / StreamableHTTP) │ │
│ └──────────────────────────┘ │
└────────────────────────────────────────────────────────────────┘Flow
- Config Loading — Reads
.mcp.jsonto find the agentrq MCP server. - MCP Connection — Establishes a
StreamableHTTPClientTransportto the MCP server with automatic retry and reconnection. - Agent Spawning — Launches the specified ACP agent as a subprocess with stdio piping.
- ACP Handshake — Initializes the ACP connection.
- Task Bridge & Multi-Session Isolation — When a task is received from the MCP server:
acp-gatewayextracts thechat_id(Task ID).- It checks if the task content is a duplicate of the last processed task for this Task ID. If it is repetitive, the task is dropped to prevent redundant processing.
- If not repetitive, the task is added to a concurrency-limiting queue (honoring the
--max-concurrencylimit). - It ensures a dedicated ACP session for that specific task.
- If the task belongs to a different session than the current one, a new ACP session is initialized, providing clean state isolation between concurrent or sequential tasks.
- Permission Bridge — Permission requests from the ACP agent are forwarded to the MCP server; verdicts are sent back.
- Recursive Execution — After each task completes,
acp-gatewaychecks for the next pending task automatically.
Key Components
| File | Description |
|---|---|
| src/index.ts | Entry point; orchestrates config loading, MCP connection, agent spawning, and ACP session lifecycle. |
| src/acpClient.ts | Implements the ACP Client interface — routes permission requests, handles session updates, and provides file operations. |
| src/mcpClient.ts | EventEmitter-based MCP client with auto-reconnection, notification handling, and tool call dispatch. |
| src/config.ts | Parses .mcp.json from the current directory tree up to 3 levels deep. |
Development
Scripts
# Run in development mode
npm run dev
# Type-check
npm run typecheck
# Run tests
npm testProject Structure
acp-gateway/
├── src/
│ ├── acpClient.ts # ACP Client implementation
│ ├── config.ts # .mcp.json loader
│ ├── index.ts # Entry point & orchestrator
│ ├── mcpClient.ts # MCP Bridge with auto-reconnect
│ └── __tests__/ # Unit tests
├── package.json
└── tsconfig.jsonArchitecture Notes
- Auto-reconnection: The MCP transport auto-reconnects on disconnection with exponential backoff (1s → 30s max).
- Notification-driven tasks: The MCP server pushes task content via
notifications/claude/channel;acp-gatewayreacts immediately. - Permission flow: ACP agent requests permission →
acp-gatewayforwards to MCP server → waits for verdict → resolves the ACP permission. - File I/O:
readTextFile/writeTextFileare proxied directly to the filesystem; paths are resolved relative toprocess.cwd().
Contributing
Contributions are welcome! Please feel free to submit pull requests or open issues.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add: amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
Contributing License
By contributing to this project, you agree that your contributions will be licensed under the project's Apache License 2.0.
License
Apache License 2.0
Copyright (c) 2026 Contextual, Inc.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
