Skip to content

Conversation

anivar
Copy link

@anivar anivar commented Aug 24, 2025

Adds MCP-to-A2A bridge enabling MCP tools in A2A agents.

What it does:

  • Translates MCP tool calls to A2A protocol
  • Exposes MCP tools as A2A agent
  • Supports MCPD transport

Identity handling:

  • Accepts identity configuration
  • Stores internally, not used in A2A protocol

Example:

mcp_config = MCPStdio(command="uvx", args=["mcp-server-time"])
bridge_config = MCPToA2ABridgeConfig(
    mcp_config=mcp_config,
    server_name="time-server",
    identity_id="did:example:123"  # Stored only
)

Part of protocol interoperability work.

This PR introduces a bridge that allows MCP (Model Context Protocol) servers to be exposed as A2A (Agent-to-Agent) compatible services, enabling seamless protocol interoperability between the two major agent communication standards.

## Implementation

### Core Components
- MCPBridgeExecutor: Translates A2A requests to MCP tool calls
- MCPToA2ABridgeConfig: Configuration for bridge settings
- serve_mcp_as_a2a_async: Main function to start the bridge server

### Features
- Full protocol translation between MCP and A2A
- Support for AGNTCY Identity (tracked internally, not exposed via A2A due to protocol limitations)
- Comprehensive error handling and logging
- Clean integration with existing any-agent patterns
- Zero custom rules or patterns - follows any-agent conventions exactly

### Documentation
- Added detailed section in docs/serving.md
- Created cookbook example (mcp_a2a_bridge.ipynb) with practical usage patterns
- Added bridge feature to README.md
- Complete example script in examples/mcp_a2a_bridge_demo.py

### Testing
- Integration tests covering basic bridge, identity support, and tool invocation
- Test for multiple concurrent bridges
- All tests properly handle the simplified single-tool bridge design

## Design Decisions

1. Single-tool bridges only - Keeps implementation simple and follows any-agent patterns
2. Identity support - Accepts AGNTCY Identity DIDs from mcpd but acknowledges A2A limitations
3. No custom patterns - Strictly follows existing any-agent conventions
4. Clean separation - Bridge is separate from native A2A serving implementation

## Usage Example

```python
from any_agent.config import MCPStdio
from any_agent.serving import MCPToA2ABridgeConfig, serve_mcp_as_a2a_async

# Configure MCP server
mcp_config = MCPStdio(
    command="uvx",
    args=["mcp-server-time"],
    tools=["get_current_time"],
)

# Configure and start bridge
bridge_config = MCPToA2ABridgeConfig(
    mcp_config=mcp_config,
    port=8080,
    endpoint="/time-bridge",
    server_name="time-server",
)

bridge_handle = await serve_mcp_as_a2a_async(mcp_config, bridge_config)
```

This bridge enables Mozilla's any-agent to connect local MCP tools with Google's A2A ecosystem, providing a unified interface for agent communication across protocols.
@anivar anivar changed the title feat: Add MCP-to-A2A bridge for protocol interoperability feat: Add MCP-to-A2A and MCP-to-ACP bridges for protocol interoperability Aug 26, 2025
@anivar anivar changed the title feat: Add MCP-to-A2A and MCP-to-ACP bridges for protocol interoperability feat: Add MCP-to-A2A bridge for protocol interoperability Aug 26, 2025
@anivar anivar force-pushed the feat/mcp-to-a2a-bridge branch from e2e8c16 to 975d7f9 Compare August 26, 2025 02:34
- Cache callable tools during initialization
- Replace O(n) linear search with O(1) dictionary lookup
- Avoid repeated list_tools() calls on every request
- Maintain simple, readable code structure
@anivar anivar changed the title feat: Add MCP-to-A2A bridge for protocol interoperability feat: MCP-to-A2A bridge with enterprise identity and audit trails Aug 26, 2025
@anivar anivar changed the title feat: MCP-to-A2A bridge with enterprise identity and audit trails feat: MCP-to-A2A bridge Aug 26, 2025
@njbrake
Copy link
Contributor

njbrake commented Aug 26, 2025

Hi @anivar thank you so much for your work on this! We love the enthusiasm and are excited at your contributions. However, we're a small team and have limited bandwith to manage contributions. We're not quite ready to review and implement additional MCP/ACP/A2A functionality.

We're working on continuing to update our Contributing.md to help clarify how we can accept contributions.

We are really thankful for your effort and contributions, but we need to take a step back and coordinate better to make sure we are focused on the issues that we will have time to properly review and collaborate on. Thanks for your understanding 🙏

@njbrake njbrake closed this Aug 26, 2025
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.

2 participants