traia-iatp 0.1.29__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of traia-iatp might be problematic. Click here for more details.

Files changed (107) hide show
  1. traia_iatp/README.md +368 -0
  2. traia_iatp/__init__.py +54 -0
  3. traia_iatp/cli/__init__.py +5 -0
  4. traia_iatp/cli/main.py +483 -0
  5. traia_iatp/client/__init__.py +10 -0
  6. traia_iatp/client/a2a_client.py +274 -0
  7. traia_iatp/client/crewai_a2a_tools.py +335 -0
  8. traia_iatp/client/d402_a2a_client.py +293 -0
  9. traia_iatp/client/grpc_a2a_tools.py +349 -0
  10. traia_iatp/client/root_path_a2a_client.py +1 -0
  11. traia_iatp/contracts/__init__.py +12 -0
  12. traia_iatp/contracts/iatp_contracts_config.py +263 -0
  13. traia_iatp/contracts/wallet_creator.py +255 -0
  14. traia_iatp/core/__init__.py +43 -0
  15. traia_iatp/core/models.py +172 -0
  16. traia_iatp/d402/__init__.py +55 -0
  17. traia_iatp/d402/chains.py +102 -0
  18. traia_iatp/d402/client.py +150 -0
  19. traia_iatp/d402/clients/__init__.py +7 -0
  20. traia_iatp/d402/clients/base.py +218 -0
  21. traia_iatp/d402/clients/httpx.py +219 -0
  22. traia_iatp/d402/common.py +114 -0
  23. traia_iatp/d402/encoding.py +28 -0
  24. traia_iatp/d402/examples/client_example.py +197 -0
  25. traia_iatp/d402/examples/server_example.py +171 -0
  26. traia_iatp/d402/facilitator.py +453 -0
  27. traia_iatp/d402/fastapi_middleware/__init__.py +6 -0
  28. traia_iatp/d402/fastapi_middleware/middleware.py +225 -0
  29. traia_iatp/d402/fastmcp_middleware.py +147 -0
  30. traia_iatp/d402/mcp_middleware.py +434 -0
  31. traia_iatp/d402/middleware.py +193 -0
  32. traia_iatp/d402/models.py +116 -0
  33. traia_iatp/d402/networks.py +98 -0
  34. traia_iatp/d402/path.py +43 -0
  35. traia_iatp/d402/payment_introspection.py +104 -0
  36. traia_iatp/d402/payment_signing.py +178 -0
  37. traia_iatp/d402/paywall.py +119 -0
  38. traia_iatp/d402/starlette_middleware.py +326 -0
  39. traia_iatp/d402/template.py +1 -0
  40. traia_iatp/d402/types.py +300 -0
  41. traia_iatp/mcp/__init__.py +18 -0
  42. traia_iatp/mcp/client.py +201 -0
  43. traia_iatp/mcp/d402_mcp_tool_adapter.py +361 -0
  44. traia_iatp/mcp/mcp_agent_template.py +481 -0
  45. traia_iatp/mcp/templates/Dockerfile.j2 +80 -0
  46. traia_iatp/mcp/templates/README.md.j2 +310 -0
  47. traia_iatp/mcp/templates/cursor-rules.md.j2 +520 -0
  48. traia_iatp/mcp/templates/deployment_params.json.j2 +20 -0
  49. traia_iatp/mcp/templates/docker-compose.yml.j2 +32 -0
  50. traia_iatp/mcp/templates/dockerignore.j2 +47 -0
  51. traia_iatp/mcp/templates/env.example.j2 +57 -0
  52. traia_iatp/mcp/templates/gitignore.j2 +77 -0
  53. traia_iatp/mcp/templates/mcp_health_check.py.j2 +150 -0
  54. traia_iatp/mcp/templates/pyproject.toml.j2 +32 -0
  55. traia_iatp/mcp/templates/pyrightconfig.json.j2 +22 -0
  56. traia_iatp/mcp/templates/run_local_docker.sh.j2 +390 -0
  57. traia_iatp/mcp/templates/server.py.j2 +175 -0
  58. traia_iatp/mcp/traia_mcp_adapter.py +543 -0
  59. traia_iatp/preview_diagrams.html +181 -0
  60. traia_iatp/registry/__init__.py +26 -0
  61. traia_iatp/registry/atlas_search_indexes.json +280 -0
  62. traia_iatp/registry/embeddings.py +298 -0
  63. traia_iatp/registry/iatp_search_api.py +846 -0
  64. traia_iatp/registry/mongodb_registry.py +771 -0
  65. traia_iatp/registry/readmes/ATLAS_SEARCH_INDEXES.md +252 -0
  66. traia_iatp/registry/readmes/ATLAS_SEARCH_SETUP.md +134 -0
  67. traia_iatp/registry/readmes/AUTHENTICATION_UPDATE.md +124 -0
  68. traia_iatp/registry/readmes/EMBEDDINGS_SETUP.md +172 -0
  69. traia_iatp/registry/readmes/IATP_SEARCH_API_GUIDE.md +257 -0
  70. traia_iatp/registry/readmes/MONGODB_X509_AUTH.md +208 -0
  71. traia_iatp/registry/readmes/README.md +251 -0
  72. traia_iatp/registry/readmes/REFACTORING_SUMMARY.md +191 -0
  73. traia_iatp/scripts/__init__.py +2 -0
  74. traia_iatp/scripts/create_wallet.py +244 -0
  75. traia_iatp/server/__init__.py +15 -0
  76. traia_iatp/server/a2a_server.py +219 -0
  77. traia_iatp/server/example_template_usage.py +72 -0
  78. traia_iatp/server/iatp_server_agent_generator.py +237 -0
  79. traia_iatp/server/iatp_server_template_generator.py +235 -0
  80. traia_iatp/server/templates/.dockerignore.j2 +48 -0
  81. traia_iatp/server/templates/Dockerfile.j2 +49 -0
  82. traia_iatp/server/templates/README.md +137 -0
  83. traia_iatp/server/templates/README.md.j2 +425 -0
  84. traia_iatp/server/templates/__init__.py +1 -0
  85. traia_iatp/server/templates/__main__.py.j2 +565 -0
  86. traia_iatp/server/templates/agent.py.j2 +94 -0
  87. traia_iatp/server/templates/agent_config.json.j2 +22 -0
  88. traia_iatp/server/templates/agent_executor.py.j2 +279 -0
  89. traia_iatp/server/templates/docker-compose.yml.j2 +23 -0
  90. traia_iatp/server/templates/env.example.j2 +84 -0
  91. traia_iatp/server/templates/gitignore.j2 +78 -0
  92. traia_iatp/server/templates/grpc_server.py.j2 +218 -0
  93. traia_iatp/server/templates/pyproject.toml.j2 +78 -0
  94. traia_iatp/server/templates/run_local_docker.sh.j2 +103 -0
  95. traia_iatp/server/templates/server.py.j2 +243 -0
  96. traia_iatp/special_agencies/__init__.py +4 -0
  97. traia_iatp/special_agencies/registry_search_agency.py +392 -0
  98. traia_iatp/utils/__init__.py +10 -0
  99. traia_iatp/utils/docker_utils.py +251 -0
  100. traia_iatp/utils/general.py +64 -0
  101. traia_iatp/utils/iatp_utils.py +126 -0
  102. traia_iatp-0.1.29.dist-info/METADATA +423 -0
  103. traia_iatp-0.1.29.dist-info/RECORD +107 -0
  104. traia_iatp-0.1.29.dist-info/WHEEL +5 -0
  105. traia_iatp-0.1.29.dist-info/entry_points.txt +2 -0
  106. traia_iatp-0.1.29.dist-info/licenses/LICENSE +21 -0
  107. traia_iatp-0.1.29.dist-info/top_level.txt +1 -0
@@ -0,0 +1,64 @@
1
+ """General utility functions for traia_iatp package."""
2
+
3
+ import logging
4
+ from datetime import datetime
5
+ import pytz
6
+
7
+
8
+ def get_logger() -> logging.Logger:
9
+ """Get a logger instance configured for the traia_iatp package.
10
+
11
+ Returns:
12
+ logging.Logger: Configured logger instance
13
+ """
14
+ logger = logging.getLogger(__name__)
15
+ if not logger.handlers:
16
+ handler = logging.StreamHandler()
17
+ formatter = logging.Formatter(
18
+ '%(asctime)s - %(name)s - %(levelname)s - %(message)s'
19
+ )
20
+ handler.setFormatter(formatter)
21
+ logger.addHandler(handler)
22
+ logger.setLevel(logging.INFO)
23
+ return logger
24
+
25
+
26
+ def get_now_in_utc() -> datetime:
27
+ """Get the current datetime in UTC timezone.
28
+
29
+ Returns:
30
+ datetime: Current UTC datetime
31
+ """
32
+ return datetime.now(tz=pytz.utc)
33
+
34
+
35
+ def is_empty(obj) -> bool:
36
+ """Check if an object is empty.
37
+
38
+ Args:
39
+ obj: Object to check
40
+
41
+ Returns:
42
+ bool: True if object is None or has length 0
43
+ """
44
+ try:
45
+ if obj is None:
46
+ return True
47
+ if len(obj) == 0:
48
+ return True
49
+ except TypeError:
50
+ # Object doesn't have length (e.g., numbers, booleans)
51
+ return obj is None
52
+ return False
53
+
54
+
55
+ def not_empty(obj) -> bool:
56
+ """Check if an object is not empty.
57
+
58
+ Args:
59
+ obj: Object to check
60
+
61
+ Returns:
62
+ bool: True if object is not None and has length > 0
63
+ """
64
+ return not is_empty(obj)
@@ -0,0 +1,126 @@
1
+ """IATP utility functions for agent card handling and endpoint creation."""
2
+
3
+ import logging
4
+ from typing import Dict, Any, Optional, List
5
+ import httpx
6
+
7
+ from ..core.models import AgentCard, AgentSkill, AgentCapabilities, IATPEndpoints
8
+
9
+ logger = logging.getLogger(__name__)
10
+
11
+
12
+ async def fetch_agent_card(service_url: str, timeout: int = 30) -> Optional[Dict[str, Any]]:
13
+ """Fetch the agent card from a deployed utility agent.
14
+
15
+ Args:
16
+ service_url: Base URL of the deployed service
17
+ timeout: Timeout in seconds
18
+
19
+ Returns:
20
+ Agent card data or None if fetch fails
21
+ """
22
+ try:
23
+ async with httpx.AsyncClient(timeout=timeout) as client:
24
+ # Try the standard .well-known location
25
+ response = await client.get(f"{service_url}/.well-known/agent.json")
26
+ if response.status_code == 200:
27
+ return response.json()
28
+
29
+ # Try the /info endpoint as fallback
30
+ response = await client.get(f"{service_url}/info")
31
+ if response.status_code == 200:
32
+ return response.json()
33
+
34
+ except Exception as e:
35
+ logger.error(f"Error fetching agent card from {service_url}: {e}")
36
+
37
+ return None
38
+
39
+
40
+ def parse_agent_card(agent_card_data: Dict[str, Any]) -> Optional[AgentCard]:
41
+ """Parse agent card data into an AgentCard model.
42
+
43
+ Args:
44
+ agent_card_data: Raw agent card data
45
+
46
+ Returns:
47
+ AgentCard instance or None if parsing fails
48
+ """
49
+ try:
50
+ # Parse skills
51
+ skills = []
52
+ for skill_data in agent_card_data.get("skills", []):
53
+ skill = AgentSkill(
54
+ id=skill_data.get("id", ""),
55
+ name=skill_data.get("name", ""),
56
+ description=skill_data.get("description", ""),
57
+ examples=skill_data.get("examples", []),
58
+ input_modes=skill_data.get("inputModes", []),
59
+ output_modes=skill_data.get("outputModes", []),
60
+ tags=skill_data.get("tags", [])
61
+ )
62
+ skills.append(skill)
63
+
64
+ # Parse capabilities
65
+ cap_data = agent_card_data.get("capabilities", {})
66
+ capabilities = AgentCapabilities(
67
+ streaming=cap_data.get("streaming", False),
68
+ push_notifications=cap_data.get("pushNotifications", False),
69
+ state_transition_history=cap_data.get("stateTransitionHistory", False),
70
+ custom_features=cap_data.get("customFeatures", {})
71
+ )
72
+
73
+ # Create agent card
74
+ agent_card = AgentCard(
75
+ name=agent_card_data.get("name", ""),
76
+ description=agent_card_data.get("description", ""),
77
+ version=agent_card_data.get("version", "1.0.0"),
78
+ skills=skills,
79
+ capabilities=capabilities,
80
+ default_input_modes=agent_card_data.get("defaultInputModes", []),
81
+ default_output_modes=agent_card_data.get("defaultOutputModes", []),
82
+ metadata=agent_card_data.get("metadata", {})
83
+ )
84
+
85
+ return agent_card
86
+
87
+ except Exception as e:
88
+ logger.error(f"Error parsing agent card: {e}")
89
+ return None
90
+
91
+
92
+ def create_iatp_endpoints(base_url: str, supports_streaming: bool = False) -> IATPEndpoints:
93
+ """Create IATP endpoints configuration from base URL.
94
+
95
+ The A2A protocol defines specific endpoints:
96
+ - JSON-RPC endpoint at root path (/)
97
+ - Agent card at /.well-known/agent.json
98
+ - SSE endpoints at /a2a/tasks/* (if streaming is supported)
99
+
100
+ Note: The A2A library creates the main JSON-RPC endpoint at the root path (/),
101
+ not at /a2a as might be expected.
102
+
103
+ Args:
104
+ base_url: Base URL of the service (e.g., "http://localhost:8000" or "https://service.run.app")
105
+ supports_streaming: Whether the service supports streaming
106
+
107
+ Returns:
108
+ IATPEndpoints instance with all endpoint URLs configured
109
+ """
110
+ # Ensure base_url doesn't end with a slash
111
+ base_url = base_url.rstrip('/')
112
+
113
+ endpoints = IATPEndpoints(
114
+ base_url=base_url,
115
+ iatp_endpoint=base_url, # A2A JSON-RPC endpoint is at root path
116
+ health_endpoint=None, # Not part of A2A protocol
117
+ info_endpoint=None, # Not part of A2A protocol
118
+ agent_card_endpoint=f"{base_url}/.well-known/agent.json"
119
+ )
120
+
121
+ if supports_streaming:
122
+ endpoints.streaming_endpoint = base_url # Same root endpoint, different output_mode
123
+ endpoints.subscribe_endpoint = f"{base_url}/a2a/tasks/subscribe"
124
+ endpoints.resubscribe_endpoint = f"{base_url}/a2a/tasks/resubscribe"
125
+
126
+ return endpoints
@@ -0,0 +1,423 @@
1
+ Metadata-Version: 2.4
2
+ Name: traia-iatp
3
+ Version: 0.1.29
4
+ Summary: Inter-Agent Transfer Protocol (IATP) - Enable AI Agents to utilize other AI Agents as tools
5
+ Project-URL: Documentation, https://pypi.org/project/traia-iatp
6
+ Project-URL: Source, https://github.com/Traia-IO/IATP
7
+ Keywords: crewai,iatp,agent-to-agent,a2a,mcp,web3,cryptocurrency,tools
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: Operating System :: OS Independent
10
+ Requires-Python: >=3.12
11
+ Description-Content-Type: text/markdown
12
+ License-File: LICENSE
13
+ Requires-Dist: a2a-sdk==0.2.6
14
+ Requires-Dist: aiohttp>=3.12.13
15
+ Requires-Dist: anyio>=4.0.0
16
+ Requires-Dist: crewai>=0.203.1
17
+ Requires-Dist: crewai-tools[mcp]>=0.76.0
18
+ Requires-Dist: docker>=7.1.0
19
+ Requires-Dist: fastapi>=0.119.0
20
+ Requires-Dist: httpx[http2]>=0.28.1
21
+ Requires-Dist: jinja2>=3.1.6
22
+ Requires-Dist: mcp>=1.1.2
23
+ Requires-Dist: openai>=1.109.1
24
+ Requires-Dist: pydantic>=2.12.2
25
+ Requires-Dist: pymongo[aws]>=4.13.0
26
+ Requires-Dist: python-dotenv>=1.1.1
27
+ Requires-Dist: pytz>=2025.2
28
+ Requires-Dist: requests>=2.32.5
29
+ Requires-Dist: rich>=14.2.0
30
+ Requires-Dist: starlette>=0.45.0
31
+ Requires-Dist: typer>=0.19.2
32
+ Requires-Dist: uvicorn>=0.37.0
33
+ Requires-Dist: agentops>=0.4.21
34
+ Requires-Dist: dnspython==2.6.1
35
+ Requires-Dist: eth-account>=0.11.0
36
+ Requires-Dist: web3>=6.15.0
37
+ Provides-Extra: dev
38
+ Requires-Dist: pytest>=8.4.2; extra == "dev"
39
+ Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
40
+ Requires-Dist: black>=23.0.0; extra == "dev"
41
+ Requires-Dist: flake8>=6.0.0; extra == "dev"
42
+ Requires-Dist: mypy>=1.0.0; extra == "dev"
43
+ Requires-Dist: pre-commit>=3.0.0; extra == "dev"
44
+ Provides-Extra: publish
45
+ Requires-Dist: wheel; extra == "publish"
46
+ Requires-Dist: twine; extra == "publish"
47
+ Requires-Dist: build; extra == "publish"
48
+ Dynamic: license-file
49
+
50
+ # Traia IATP
51
+
52
+ [![PyPI version](https://badge.fury.io/py/traia-iatp.svg)](https://badge.fury.io/py/traia-iatp)
53
+ [![Python 3.12+](https://img.shields.io/badge/python-3.12+-blue.svg)](https://www.python.org/downloads/)
54
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
55
+
56
+ **Traia IATP** is an Inter-Agent Transfer Protocol (IATP) package that enables AI agents to utilize other AI agents as tools via the A2A (Agent-to-Agent) protocol. This implementation allows CrewAI agents to act as both IATP servers (utility agents) and clients.
57
+
58
+ ## Features
59
+
60
+ - 🤖 **Utility Agent Creation**: Convert MCP servers into IATP-compatible utility agents
61
+ - 🔌 **IATP Client Tools**: Enable CrewAI crews to use utility agents as tools via IATP protocol
62
+ - 🌐 **Protocol Support**: HTTP/2 with SSE streaming and optional gRPC for high-performance scenarios
63
+ - 📊 **Registry Management**: MongoDB-based registry for discovering utility agents
64
+ - 🐳 **Docker Support**: Complete containerization for deployment
65
+ - 🐳 **Local Docker Deployment**: Complete containerization for local deployment
66
+
67
+ ## Installation
68
+
69
+ ### From PyPI (Recommended)
70
+
71
+ ```bash
72
+ pip install traia-iatp
73
+ ```
74
+
75
+ ### From Source
76
+
77
+ ```bash
78
+ git clone https://github.com/Traia-IO/IATP.git
79
+ cd IATP
80
+ pip install -e .
81
+ ```
82
+
83
+ ### Development Installation
84
+
85
+ ```bash
86
+ # Install with all dependencies for development
87
+ pip install -e ".[dev]"
88
+ ```
89
+
90
+ ## Quick Start
91
+
92
+ ### 1. Creating a Utility Agency (IATP Server)
93
+
94
+ ```python
95
+ import asyncio
96
+ from traia_iatp import MCPServer, MCPServerType, IATPServerAgentGenerator
97
+
98
+ async def create_utility_agency():
99
+ # Define an MCP server
100
+ mcp_server = MCPServer(
101
+ name="example-mcp-server",
102
+ url="http://example-mcp-server:8080",
103
+ server_type=MCPServerType.STREAMABLE_HTTP,
104
+ description="Example MCP server that provides utility functions"
105
+ )
106
+
107
+ # Generate and deploy utility agency
108
+ generator = IATPServerAgentGenerator()
109
+ agency = await generator.create_from_mcp(mcp_server)
110
+
111
+ # Deploy locally with Docker
112
+ await generator.deploy_local(agency)
113
+ ```
114
+
115
+ ### 2. Using Utility Agencies in CrewAI (IATP Client)
116
+
117
+ ```python
118
+ from crewai import Agent, Task, Crew
119
+ from traia_iatp import find_utility_agent
120
+ from traia_iatp.client import A2AToolkit
121
+
122
+ # Find available utility agents by agent_id
123
+ agent = find_utility_agent(agent_id="finbert-mcp-traia-utility-agent")
124
+
125
+ if agent:
126
+ # Get the IATP endpoint
127
+ endpoint = agent.base_url
128
+ if agent.endpoints and 'iatp_endpoint' in agent.endpoints:
129
+ endpoint = agent.endpoints['iatp_endpoint']
130
+
131
+ # Create tool from agent endpoint
132
+ finbert_tool = A2AToolkit.create_tool_from_endpoint(
133
+ endpoint=endpoint,
134
+ name=agent.name,
135
+ description=agent.description,
136
+ timeout=300,
137
+ retry_attempts=1,
138
+ supports_streaming=False,
139
+ iatp_endpoint=endpoint
140
+ )
141
+
142
+ # Use in CrewAI agent
143
+ sentiment_analyst = Agent(
144
+ role="Financial Sentiment Analyst",
145
+ goal="Analyze sentiment of financial texts using FinBERT models",
146
+ backstory="Expert financial sentiment analyst with deep knowledge of market psychology",
147
+ tools=[finbert_tool],
148
+ verbose=True,
149
+ allow_delegation=False
150
+ )
151
+
152
+ # Create task
153
+ task = Task(
154
+ description="Analyze the sentiment of: 'Apple Inc. reported record quarterly earnings'",
155
+ expected_output="Sentiment classification with confidence score and investment implications",
156
+ agent=sentiment_analyst
157
+ )
158
+
159
+ # Run crew
160
+ crew = Crew(agents=[sentiment_analyst], tasks=[task])
161
+ result = crew.kickoff()
162
+ ```
163
+
164
+ #### Alternative: Batch Tool Creation
165
+
166
+ For creating multiple tools at once, you can use the convenience function:
167
+
168
+ ```python
169
+ from traia_iatp.client import create_utility_agency_tools
170
+
171
+ # Search and create tools in batch
172
+ tools = create_utility_agency_tools(
173
+ query="sentiment analysis",
174
+ tags=["finbert", "nlp"],
175
+ capabilities=["sentiment_analysis"]
176
+ )
177
+
178
+ # Use all found tools in an agent
179
+ agent = Agent(
180
+ role="Multi-Tool Analyst",
181
+ tools=tools,
182
+ goal="Analyze using multiple available utility agents"
183
+ )
184
+ ```
185
+
186
+ ### 3. CLI Usage
187
+
188
+ The package includes a powerful CLI for managing utility agencies:
189
+
190
+ ```bash
191
+ # First, register an MCP server in the registry
192
+ traia-iatp register-mcp \
193
+ --name "Trading MCP" \
194
+ --url "http://localhost:8000/mcp" \
195
+ --description "Trading MCP server" \
196
+ --capability "trading" \
197
+ --capability "crypto"
198
+
199
+ # Create a utility agency from registered MCP server
200
+ traia-iatp create-agency \
201
+ --name "My Trading Agent" \
202
+ --description "Advanced trading utility agent" \
203
+ --mcp-name "Trading MCP" \
204
+ --deploy
205
+
206
+ # List available utility agencies
207
+ traia-iatp list-agencies
208
+
209
+ # Search for agencies by capability
210
+ traia-iatp search-agencies --query "trading crypto"
211
+
212
+ # Deploy from a generated agency directory
213
+ traia-iatp deploy ./utility_agencies/my-trading-agent --port 8001
214
+
215
+ # Find available tools for CrewAI
216
+ traia-iatp find-tools --tag "trading" --capability "crypto"
217
+
218
+ # List registered MCP servers
219
+ traia-iatp list-mcp-servers
220
+
221
+ # Show example CrewAI integration code
222
+ traia-iatp example-crew
223
+ ```
224
+
225
+ ## Architecture
226
+
227
+ ### IATP Operation Modes
228
+
229
+ The IATP protocol supports two distinct operation modes:
230
+
231
+ #### 1. Synchronous JSON-RPC Mode
232
+ For simple request-response patterns:
233
+ - Client sends: `message/send` request via JSON-RPC
234
+ - Server processes the request using CrewAI agents
235
+ - Server returns: A single `Message` result
236
+
237
+ #### 2. Streaming SSE Mode
238
+ For real-time data and long-running operations:
239
+ - Client sends: `message/send` request via JSON-RPC
240
+ - Server returns: Stream of events via Server-Sent Events (SSE)
241
+ - Supports progress updates, partial results, and completion notifications
242
+
243
+ ### Component Overview
244
+
245
+ ```
246
+ ┌─────────────────────┐ ┌─────────────────────┐ ┌─────────────────────┐
247
+ │ CrewAI Agent │───▶│ IATP Client │───▶│ Utility Agency │
248
+ │ (A2A Client) │ │ (HTTP/2 + gRPC) │ │ (A2A Server) │
249
+ └─────────────────────┘ └─────────────────────┘ └─────────────────────┘
250
+
251
+
252
+ ┌─────────────────────┐
253
+ │ MCP Server │
254
+ │ (Tools Provider) │
255
+ └─────────────────────┘
256
+ ```
257
+
258
+ ## Key Components
259
+
260
+ ### Server Components (`traia_iatp.server`)
261
+ - **Template Generation**: Jinja2 templates for creating utility agents
262
+ - **HTTP/2 + SSE Support**: Modern protocol support with streaming
263
+ - **gRPC Integration**: Optional high-performance protocol support
264
+ - **Docker Containerization**: Complete deployment packaging
265
+
266
+ ### Client Components (`traia_iatp.client`)
267
+ - **CrewAI Integration**: Native tools for CrewAI agents
268
+ - **HTTP/2 Client**: Persistent connections with multiplexing
269
+ - **SSE Streaming**: Real-time data consumption
270
+ - **Connection Management**: Pooling and retry logic
271
+
272
+ ### Registry Components (`traia_iatp.registry`)
273
+ - **MongoDB Integration**: Persistent storage and search
274
+ - **Vector Search**: Embedding-based capability discovery
275
+ - **Atlas Search**: Full-text search capabilities
276
+ - **Agent Discovery**: Find agents by capability, tags, or description
277
+
278
+ ## Environment Variables
279
+
280
+ ```bash
281
+ # MongoDB Configuration (choose one method)
282
+ MONGODB_CONNECTION_STRING="mongodb+srv://..."
283
+ # OR
284
+ MONGODB_USER="username"
285
+ MONGODB_PASSWORD="password"
286
+ # OR X.509 Certificate
287
+ MONGODB_X509_CERT_FILE="/path/to/cert.pem"
288
+
289
+ # Optional: Custom MongoDB cluster
290
+ MONGODB_CLUSTER_URI="custom-cluster.mongodb.net"
291
+ MONGODB_DATABASE_NAME="custom_db"
292
+
293
+ # OpenAI for embeddings (optional)
294
+ OPENAI_API_KEY="your-openai-key"
295
+
296
+ # MCP Server Authentication (as needed)
297
+ MCP_API_KEY="your-mcp-api-key"
298
+ ```
299
+
300
+ ## Examples
301
+
302
+ ### Advanced IATP Integration
303
+
304
+ ```python
305
+ from traia_iatp import find_utility_agent
306
+ from traia_iatp.client import A2AToolkit
307
+
308
+ # Find multiple utility agents
309
+ trading_agent = find_utility_agent(agent_id="trading-mcp-agent")
310
+ sentiment_agent = find_utility_agent(agent_id="finbert-mcp-agent")
311
+
312
+ tools = []
313
+ for agent in [trading_agent, sentiment_agent]:
314
+ if agent:
315
+ # Get endpoint and create tool
316
+ endpoint = agent.endpoints.get('iatp_endpoint', agent.base_url)
317
+ tool = A2AToolkit.create_tool_from_endpoint(
318
+ endpoint=endpoint,
319
+ name=agent.name,
320
+ description=agent.description,
321
+ iatp_endpoint=endpoint
322
+ )
323
+ tools.append(tool)
324
+
325
+ # Use multiple IATP tools in one agent
326
+ multi_tool_agent = Agent(
327
+ role="Multi-Domain Analyst",
328
+ goal="Analyze markets using multiple specialized AI agents",
329
+ tools=tools,
330
+ backstory="Expert analyst with access to specialized AI agents for trading and sentiment analysis"
331
+ )
332
+ ```
333
+
334
+ ### Local Docker Deployment
335
+
336
+ ```python
337
+ from traia_iatp.utils.docker_utils import LocalDockerRunner
338
+ from pathlib import Path
339
+
340
+ # Deploy a generated agency locally (not yet configured properly)
341
+ runner = LocalDockerRunner()
342
+ deployment_info = await runner.run_agent_docker(
343
+ agent_path=Path("./utility_agencies/my-trading-agent"),
344
+ port=8000,
345
+ detached=True
346
+ )
347
+
348
+ if deployment_info["success"]:
349
+ print(f"Agency deployed at: {deployment_info['iatp_endpoint']}")
350
+ print(f"Container: {deployment_info['container_name']}")
351
+ print(f"Stop with: {deployment_info['stop_command']}")
352
+ ```
353
+
354
+ ## Development
355
+
356
+ ### Setting Up Development Environment
357
+
358
+ ```bash
359
+ # Clone the repository
360
+ git clone https://github.com/Traia-IO/IATP.git
361
+ cd IATP
362
+
363
+ # Create virtual environment
364
+ python -m venv venv
365
+ source venv/bin/activate # On Windows: venv\Scripts\activate
366
+
367
+ # Install in development mode with dev dependencies
368
+ pip install -e ".[dev]"
369
+
370
+ # Run tests
371
+ pytest
372
+
373
+ # Run linting
374
+ black .
375
+ flake8 .
376
+ mypy .
377
+ ```
378
+
379
+ ### Running Tests
380
+
381
+ ```bash
382
+ # Run all tests
383
+ pytest
384
+
385
+ # Run specific test file
386
+ pytest tests/test_client.py
387
+
388
+ # Run with coverage
389
+ pytest --cov=traia_iatp --cov-report=html
390
+ ```
391
+
392
+ ## Contributing
393
+
394
+ We welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) for details.
395
+
396
+ This is a private code base hence only members of Dcentralab can contribute
397
+
398
+ 1. Fork the repository
399
+ 2. Create a feature branch (`git checkout -b feature/amazing-feature`)
400
+ 3. Commit your changes (`git commit -m 'Add amazing feature'`)
401
+ 4. Push to the branch (`git push origin feature/amazing-feature`)
402
+ 5. Open a Pull Request
403
+
404
+ ## License
405
+
406
+ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
407
+
408
+ ## Support
409
+
410
+ - 📖 **Documentation**: [https://pypi.org/project/traia-iatp](https://pypi.org/project/traia-iatp)
411
+ - 🐛 **Bug Reports**: [GitHub Issues](https://github.com/Traia-IO/IATP/issues)
412
+ - 💬 **Community**: [Visit our website](https://traia.io)
413
+ - 📧 **Email**: support@traia.io
414
+
415
+ ## Related Projects
416
+
417
+ - [A2A Protocol](https://github.com/google-a2a/A2A) - Agent-to-Agent communication protocol
418
+ - [CrewAI](https://github.com/joaomdmoura/crewAI) - Framework for orchestrating role-playing AI agents
419
+ - [FastMCP](https://github.com/modelcontextprotocol/fastmcp) - Fast implementation of Model Context Protocol
420
+
421
+ ---
422
+
423
+ **Made with ❤️ by the Traia Team**