Skip to content

Commit f3df539

Browse files
authored
A2a catalog closes #298 (#792)
* A2A support Signed-off-by: Mihai Criveti <[email protected]> * A2A support Signed-off-by: Mihai Criveti <[email protected]> * A2A support Signed-off-by: Mihai Criveti <[email protected]> * A2A support Signed-off-by: Mihai Criveti <[email protected]> * A2A support Signed-off-by: Mihai Criveti <[email protected]> * A2A support Signed-off-by: Mihai Criveti <[email protected]> * A2A support Signed-off-by: Mihai Criveti <[email protected]> * A2A support Signed-off-by: Mihai Criveti <[email protected]> * Update agent_langchain Signed-off-by: Mihai Criveti <[email protected]> * Update agent_langchain Signed-off-by: Mihai Criveti <[email protected]> * Update agent_langchain Signed-off-by: Mihai Criveti <[email protected]> * Update agent_langchain Signed-off-by: Mihai Criveti <[email protected]> --------- Signed-off-by: Mihai Criveti <[email protected]>
1 parent afba142 commit f3df539

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+6299
-253
lines changed

.env.example

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,26 @@ MCPGATEWAY_BULK_IMPORT_MAX_TOOLS=200
8787
# Rate limiting for bulk import endpoint (requests per minute)
8888
MCPGATEWAY_BULK_IMPORT_RATE_LIMIT=10
8989

90+
#####################################
91+
# A2A (Agent-to-Agent) Configuration
92+
#####################################
93+
94+
# Enable A2A agent features (true/false)
95+
# Allows registration and management of external AI agents
96+
MCPGATEWAY_A2A_ENABLED=true
97+
98+
# Maximum number of A2A agents allowed
99+
MCPGATEWAY_A2A_MAX_AGENTS=100
100+
101+
# Default timeout for A2A agent HTTP requests (seconds)
102+
MCPGATEWAY_A2A_DEFAULT_TIMEOUT=30
103+
104+
# Maximum retry attempts for failed A2A agent calls
105+
MCPGATEWAY_A2A_MAX_RETRIES=3
106+
107+
# Enable A2A agent metrics collection (true/false)
108+
MCPGATEWAY_A2A_METRICS_ENABLED=true
109+
90110
#####################################
91111
# Header Passthrough Configuration
92112
#####################################

CLAUDE.md

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,13 @@ MCPGATEWAY_BULK_IMPORT_ENABLED=true # Enable/disable bulk import endpoint
142142
MCPGATEWAY_BULK_IMPORT_MAX_TOOLS=200 # Maximum tools per import batch
143143
MCPGATEWAY_BULK_IMPORT_RATE_LIMIT=10 # Requests per minute limit
144144

145+
# A2A (Agent-to-Agent) Features
146+
MCPGATEWAY_A2A_ENABLED=true # Enable/disable A2A agent features
147+
MCPGATEWAY_A2A_MAX_AGENTS=100 # Maximum number of A2A agents allowed
148+
MCPGATEWAY_A2A_DEFAULT_TIMEOUT=30 # Default timeout for A2A HTTP requests (seconds)
149+
MCPGATEWAY_A2A_MAX_RETRIES=3 # Maximum retry attempts for A2A calls
150+
MCPGATEWAY_A2A_METRICS_ENABLED=true # Enable/disable A2A metrics collection
151+
145152
# Federation
146153
MCPGATEWAY_ENABLE_MDNS_DISCOVERY=true
147154
MCPGATEWAY_ENABLE_FEDERATION=true
@@ -214,6 +221,87 @@ pytest -m "not slow"
214221
3. Register in `plugins/config.yaml`
215222
4. Implement required hooks (pre/post request/response)
216223

224+
## A2A (Agent-to-Agent) Integration
225+
226+
The gateway supports A2A (Agent-to-Agent) compatible agents that can be integrated as tools within virtual servers. A2A agents represent external AI agents (e.g., OpenAI, Anthropic, custom agents) that support standardized Agent-to-Agent communication protocols.
227+
228+
### A2A Agent Features
229+
230+
- **Multi-Agent Support**: Support for different agent types (OpenAI, Anthropic, custom, etc.)
231+
- **Protocol Versioning**: A2A protocol version support for compatibility
232+
- **Authentication**: Flexible auth types (API key, OAuth, bearer tokens)
233+
- **Metrics & Monitoring**: Full metrics collection for agent interactions
234+
- **Virtual Server Integration**: Agents can be exposed as tools within virtual servers
235+
- **Tagging System**: Tag-based categorization and filtering
236+
- **Admin UI**: Dedicated tab in admin interface for agent management
237+
238+
### A2A Agent Configuration
239+
240+
```json
241+
{
242+
"name": "my-assistant-agent",
243+
"description": "Custom AI assistant for specific tasks",
244+
"endpoint_url": "https://api.example.com/agent",
245+
"agent_type": "custom",
246+
"protocol_version": "1.0",
247+
"capabilities": {
248+
"chat": true,
249+
"tools": false,
250+
"streaming": true
251+
},
252+
"config": {
253+
"max_tokens": 1000,
254+
"temperature": 0.7
255+
},
256+
"auth_type": "api_key",
257+
"auth_value": "your-api-key",
258+
"tags": ["ai", "assistant", "production"]
259+
}
260+
```
261+
262+
### A2A Agent Integration Workflow
263+
264+
1. **Register Agent**: Add A2A agent via `/a2a` API or Admin UI
265+
2. **Associate with Server**: Include agent ID in virtual server's `associated_a2a_agents`
266+
3. **Auto-Tool Creation**: Gateway automatically creates tools for associated agents
267+
4. **Tool Invocation**: Tools can be invoked normally, routing calls to A2A agents
268+
5. **Metrics Collection**: All interactions are tracked with comprehensive metrics
269+
270+
### A2A Configuration Options
271+
272+
The A2A features can be configured via environment variables:
273+
274+
```bash
275+
# Core A2A Settings
276+
MCPGATEWAY_A2A_ENABLED=true # Master switch for A2A features
277+
MCPGATEWAY_A2A_MAX_AGENTS=100 # Limit on number of agents
278+
MCPGATEWAY_A2A_METRICS_ENABLED=true # Enable metrics collection
279+
280+
# Performance Settings
281+
MCPGATEWAY_A2A_DEFAULT_TIMEOUT=30 # HTTP timeout for agent calls (seconds)
282+
MCPGATEWAY_A2A_MAX_RETRIES=3 # Retry attempts for failed calls
283+
```
284+
285+
**Configuration Effects:**
286+
287+
- `MCPGATEWAY_A2A_ENABLED=false`: Completely disables A2A features
288+
- A2A API endpoints return 404
289+
- A2A tab hidden in admin UI
290+
- A2A agents cannot be invoked as tools
291+
- A2A metrics excluded from aggregations
292+
293+
- `MCPGATEWAY_A2A_METRICS_ENABLED=false`: Disables metrics for A2A agents
294+
- Agent interactions still work
295+
- No performance data collected
296+
- Metrics endpoints exclude A2A data
297+
298+
**Security Considerations:**
299+
300+
- A2A agents can access external endpoints
301+
- Credentials are stored encrypted in the database
302+
- Rate limiting applies to agent invocations
303+
- All interactions are logged for audit trails
304+
217305
## API Endpoints Overview
218306

219307
### Core MCP Operations
@@ -227,8 +315,18 @@ pytest -m "not slow"
227315
- `GET/POST /prompts` - Prompt templates
228316
- `GET/POST /servers` - Virtual servers
229317
- `GET/POST /gateways` - Peer gateways
318+
- `GET/POST /a2a` - A2A (Agent-to-Agent) agent management
230319
- `GET /admin` - Admin UI dashboard
231320

321+
### A2A Agent Management
322+
- `GET /a2a` - List A2A agents with filtering
323+
- `POST /a2a` - Register new A2A agent
324+
- `GET /a2a/{agent_id}` - Get specific agent details
325+
- `PUT /a2a/{agent_id}` - Update agent configuration
326+
- `DELETE /a2a/{agent_id}` - Remove agent
327+
- `POST /a2a/{agent_id}/toggle` - Enable/disable agent
328+
- `POST /a2a/{agent_name}/invoke` - Direct agent invocation
329+
232330
# You have access to cli tools
233331
- You can use `gh` for github commands, e.g. gh issue view 586
234332

README.md

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ ContextForge MCP Gateway is a feature-rich gateway, proxy and MCP Registry that
123123
It currently supports:
124124

125125
* Federation across multiple MCP and REST services
126+
* **A2A (Agent-to-Agent) integration** for external AI agents (OpenAI, Anthropic, custom)
126127
* Virtualization of legacy APIs as MCP-compliant tools and servers
127128
* Transport over HTTP, JSON-RPC, WebSocket, SSE (with configurable keepalive), stdio and streamable-HTTP
128129
* An Admin UI for real-time management, configuration, and log monitoring
@@ -1048,6 +1049,25 @@ You can get started by copying the provided [.env.example](.env.example) to `.en
10481049
> 🖥️ Set both UI and Admin API to `false` to disable management UI and APIs in production.
10491050
> 📥 The bulk import endpoint allows importing up to 200 tools in a single request via `/admin/tools/import`.
10501051

1052+
### A2A (Agent-to-Agent) Features
1053+
1054+
| Setting | Description | Default | Options |
1055+
| ------------------------------ | -------------------------------------- | ------- | ------- |
1056+
| `MCPGATEWAY_A2A_ENABLED` | Enable A2A agent features | `true` | bool |
1057+
| `MCPGATEWAY_A2A_MAX_AGENTS` | Maximum number of A2A agents allowed | `100` | int |
1058+
| `MCPGATEWAY_A2A_DEFAULT_TIMEOUT` | Default timeout for A2A HTTP requests (seconds) | `30` | int |
1059+
| `MCPGATEWAY_A2A_MAX_RETRIES` | Maximum retry attempts for A2A calls | `3` | int |
1060+
| `MCPGATEWAY_A2A_METRICS_ENABLED` | Enable A2A agent metrics collection | `true` | bool |
1061+
1062+
> 🤖 **A2A Integration**: Register external AI agents (OpenAI, Anthropic, custom) and expose them as MCP tools
1063+
> 📊 **Metrics**: Track agent performance, success rates, and response times
1064+
> 🔒 **Security**: Encrypted credential storage and configurable authentication
1065+
> 🎛️ **Admin UI**: Dedicated tab for agent management with test functionality
1066+
1067+
**A2A Configuration Effects:**
1068+
- `MCPGATEWAY_A2A_ENABLED=false`: Completely disables A2A features (API endpoints return 404, admin tab hidden)
1069+
- `MCPGATEWAY_A2A_METRICS_ENABLED=false`: Disables metrics collection while keeping functionality
1070+
10511071
### Security
10521072

10531073
| Setting | Description | Default | Options |
@@ -1571,6 +1591,82 @@ curl -X DELETE -H "Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN" http://localh
15711591

15721592
---
15731593

1594+
<details>
1595+
<summary><strong>🤖 A2A Agent Management /a2a</strong></summary>
1596+
1597+
```bash
1598+
# Register a new A2A agent
1599+
curl -X POST -H "Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN" \
1600+
-H "Content-Type: application/json" \
1601+
-d '{
1602+
"name":"hello_world_agent",
1603+
"endpoint_url":"http://localhost:9999/",
1604+
"agent_type":"jsonrpc",
1605+
"description":"External AI agent for hello world functionality",
1606+
"auth_type":"api_key",
1607+
"auth_value":"your-api-key",
1608+
"tags":["ai", "hello-world"]
1609+
}' \
1610+
http://localhost:4444/a2a
1611+
1612+
# List A2A agents
1613+
curl -H "Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN" http://localhost:4444/a2a
1614+
1615+
# Get agent by ID
1616+
curl -H "Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN" http://localhost:4444/a2a/agent-id
1617+
1618+
# Update agent
1619+
curl -X PUT -H "Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN" \
1620+
-H "Content-Type: application/json" \
1621+
-d '{ "description":"Updated description" }' \
1622+
http://localhost:4444/a2a/agent-id
1623+
1624+
# Test agent (direct invocation)
1625+
curl -X POST -H "Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN" \
1626+
-H "Content-Type: application/json" \
1627+
-d '{
1628+
"parameters": {
1629+
"method": "message/send",
1630+
"params": {
1631+
"message": {
1632+
"messageId": "test-123",
1633+
"role": "user",
1634+
"parts": [{"type": "text", "text": "Hello!"}]
1635+
}
1636+
}
1637+
},
1638+
"interaction_type": "test"
1639+
}' \
1640+
http://localhost:4444/a2a/agent-name/invoke
1641+
1642+
# Toggle agent status
1643+
curl -X POST -H "Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN" \
1644+
http://localhost:4444/a2a/agent-id/toggle?activate=false
1645+
1646+
# Delete agent
1647+
curl -X DELETE -H "Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN" \
1648+
http://localhost:4444/a2a/agent-id
1649+
1650+
# Associate agent with virtual server (agents become available as MCP tools)
1651+
curl -X POST -H "Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN" \
1652+
-H "Content-Type: application/json" \
1653+
-d '{
1654+
"name":"AI Assistant Server",
1655+
"description":"Virtual server with AI agents",
1656+
"associated_a2a_agents":["agent-id"]
1657+
}' \
1658+
http://localhost:4444/servers
1659+
```
1660+
1661+
> 🤖 **A2A Integration**: A2A agents are external AI agents that can be registered and exposed as MCP tools
1662+
> 🔄 **Protocol Detection**: Gateway automatically detects JSONRPC vs custom A2A protocols
1663+
> 📊 **Testing**: Built-in test functionality via Admin UI or `/a2a/{agent_id}/test` endpoint
1664+
> 🎛️ **Virtual Servers**: Associate agents with servers to expose them as standard MCP tools
1665+
1666+
</details>
1667+
1668+
---
1669+
15741670
<details>
15751671
<summary><strong>🌐 Gateway Management /gateways</strong></summary>
15761672

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# Python
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
*.so
6+
.Python
7+
build/
8+
develop-eggs/
9+
dist/
10+
downloads/
11+
eggs/
12+
.eggs/
13+
lib/
14+
lib64/
15+
parts/
16+
sdist/
17+
var/
18+
wheels/
19+
*.egg-info/
20+
.installed.cfg
21+
*.egg
22+
MANIFEST
23+
24+
# Testing
25+
.pytest_cache/
26+
.coverage
27+
htmlcov/
28+
.tox/
29+
.nox/
30+
coverage.xml
31+
*.cover
32+
.hypothesis/
33+
34+
# Development
35+
.env
36+
.env.*
37+
!.env.example
38+
.venv/
39+
venv/
40+
ENV/
41+
env/
42+
43+
# IDE
44+
.vscode/
45+
.idea/
46+
*.swp
47+
*.swo
48+
*~
49+
50+
# OS
51+
.DS_Store
52+
.DS_Store?
53+
._*
54+
.Spotlight-V100
55+
.Trashes
56+
ehthumbs.db
57+
Thumbs.db
58+
59+
# Git
60+
.git/
61+
.gitignore
62+
63+
# Documentation
64+
docs/
65+
*.md
66+
!README.md
67+
68+
# Security
69+
bandit-report.json
70+
71+
# Logs
72+
*.log

0 commit comments

Comments
 (0)