Skip to content

Conversation

@telnet2
Copy link
Owner

@telnet2 telnet2 commented Dec 21, 2025

No description provided.

…cket

Adds a complete implementation of the Tool Bridge Protocol for enabling
server-side LLM agents to invoke tools on local machines behind NAT/firewall.

Packages added:
- @opencode-ai/tool-bridge-protocol: Shared protocol schemas and message types
- @opencode-ai/tool-relay: Server-side gateway that forwards tool invocations
- @opencode-ai/tool-bridge: Client-side agent that executes tools locally
- @opencode-ai/tool-bridge-opencode: Adapter for integrating opencode tools
- @opencode-ai/tool-bridge-tests: End-to-end integration tests

Key features:
- WebSocket-based reverse RPC with multiplexed tool calls
- Session-aware routing with reconnect support
- Heartbeat mechanism for connection health monitoring
- Tool registration and discovery
- Streaming support for progressive results
- Cancellation support for long-running operations
- Comprehensive integration test suite
Adds Model Context Protocol (MCP) client integration to the Tool Bridge,
allowing it to connect to MCP servers and expose their tools through the
bridge protocol.

New components:
- McpClientManager: Manages connections to multiple MCP servers
- McpConfig types: Configuration for local (stdio) and remote (HTTP/SSE) MCP servers
- Bridge.attachMcpServers(): Convenience method to attach MCP servers

Features:
- Support for local MCP servers via stdio transport
- Support for remote MCP servers via StreamableHTTP and SSE transports
- Automatic tool discovery and registration with the bridge
- Configurable tool prefix for namespacing MCP tools
- Connection timeout and error handling
- Ability to add/remove servers dynamically

Usage:
```typescript
const bridge = new ToolBridge({ url: "ws://relay:8080" })
await bridge.attachMcpServers({
  "filesystem": {
    type: "local",
    command: ["npx", "-y", "@modelcontextprotocol/server-filesystem", "/path"]
  },
  "api": {
    type: "remote",
    url: "https://mcp.example.com/api"
  }
})
await bridge.connect()
```
Adds a detailed design document explaining the Tool Bridge and Tool Relay
architecture in narrative style with ASCII diagrams. The document covers:

- Problem statement and motivation for reverse RPC
- High-level architecture with visual diagrams
- Core concepts (tools, sessions, calls, multiplexing)
- Protocol message types and flow diagrams
- Component deep dive (Relay and Bridge)
- MCP integration for external tool servers
- Connection lifecycle and reconnection handling
- Tool invocation flow with streaming and cancellation
- Error handling and recovery scenarios
- Security considerations
- Code references to actual implementation files

Written for first-time readers and junior engineers without requiring
deep understanding of LLM agents.
Add support for dynamically enabling/disabling tools on a per-session
basis. The server (relay) can now control which tools are available
for each session, enabling denylist or allowlist modes.

Changes:
- Add SetToolsAccessMessage and ToolsAccessUpdatedMessage to protocol
- Add TOOL_ACCESS_DENIED error code
- Add setToolsAccess/getToolsAccess/getAccessibleTools methods to relay
- Update bridge to track disabled tools and respect permissions
- Add comprehensive tests for tool access control
- Update design documentation with new feature
@telnet2 telnet2 merged commit 4bd1fb3 into main Dec 21, 2025
0 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants