kailash 0.6.3__py3-none-any.whl → 0.6.5__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.
Files changed (122) hide show
  1. kailash/__init__.py +3 -3
  2. kailash/api/custom_nodes_secure.py +3 -3
  3. kailash/api/gateway.py +1 -1
  4. kailash/api/studio.py +1 -1
  5. kailash/api/workflow_api.py +2 -2
  6. kailash/core/resilience/bulkhead.py +475 -0
  7. kailash/core/resilience/circuit_breaker.py +92 -10
  8. kailash/core/resilience/health_monitor.py +578 -0
  9. kailash/edge/discovery.py +86 -0
  10. kailash/mcp_server/__init__.py +309 -33
  11. kailash/mcp_server/advanced_features.py +1022 -0
  12. kailash/mcp_server/ai_registry_server.py +27 -2
  13. kailash/mcp_server/auth.py +789 -0
  14. kailash/mcp_server/client.py +645 -378
  15. kailash/mcp_server/discovery.py +1593 -0
  16. kailash/mcp_server/errors.py +673 -0
  17. kailash/mcp_server/oauth.py +1727 -0
  18. kailash/mcp_server/protocol.py +1126 -0
  19. kailash/mcp_server/registry_integration.py +587 -0
  20. kailash/mcp_server/server.py +1228 -96
  21. kailash/mcp_server/transports.py +1169 -0
  22. kailash/mcp_server/utils/__init__.py +6 -1
  23. kailash/mcp_server/utils/cache.py +250 -7
  24. kailash/middleware/auth/auth_manager.py +3 -3
  25. kailash/middleware/communication/api_gateway.py +1 -1
  26. kailash/middleware/communication/realtime.py +1 -1
  27. kailash/middleware/mcp/enhanced_server.py +1 -1
  28. kailash/nodes/__init__.py +2 -0
  29. kailash/nodes/admin/audit_log.py +6 -6
  30. kailash/nodes/admin/permission_check.py +8 -8
  31. kailash/nodes/admin/role_management.py +32 -28
  32. kailash/nodes/admin/schema.sql +6 -1
  33. kailash/nodes/admin/schema_manager.py +13 -13
  34. kailash/nodes/admin/security_event.py +15 -15
  35. kailash/nodes/admin/tenant_isolation.py +3 -3
  36. kailash/nodes/admin/transaction_utils.py +3 -3
  37. kailash/nodes/admin/user_management.py +21 -21
  38. kailash/nodes/ai/a2a.py +11 -11
  39. kailash/nodes/ai/ai_providers.py +9 -12
  40. kailash/nodes/ai/embedding_generator.py +13 -14
  41. kailash/nodes/ai/intelligent_agent_orchestrator.py +19 -19
  42. kailash/nodes/ai/iterative_llm_agent.py +2 -2
  43. kailash/nodes/ai/llm_agent.py +210 -33
  44. kailash/nodes/ai/self_organizing.py +2 -2
  45. kailash/nodes/alerts/discord.py +4 -4
  46. kailash/nodes/api/graphql.py +6 -6
  47. kailash/nodes/api/http.py +10 -10
  48. kailash/nodes/api/rate_limiting.py +4 -4
  49. kailash/nodes/api/rest.py +15 -15
  50. kailash/nodes/auth/mfa.py +3 -3
  51. kailash/nodes/auth/risk_assessment.py +2 -2
  52. kailash/nodes/auth/session_management.py +5 -5
  53. kailash/nodes/auth/sso.py +143 -0
  54. kailash/nodes/base.py +8 -2
  55. kailash/nodes/base_async.py +16 -2
  56. kailash/nodes/base_with_acl.py +2 -2
  57. kailash/nodes/cache/__init__.py +9 -0
  58. kailash/nodes/cache/cache.py +1172 -0
  59. kailash/nodes/cache/cache_invalidation.py +874 -0
  60. kailash/nodes/cache/redis_pool_manager.py +595 -0
  61. kailash/nodes/code/async_python.py +2 -1
  62. kailash/nodes/code/python.py +194 -30
  63. kailash/nodes/compliance/data_retention.py +6 -6
  64. kailash/nodes/compliance/gdpr.py +5 -5
  65. kailash/nodes/data/__init__.py +10 -0
  66. kailash/nodes/data/async_sql.py +1956 -129
  67. kailash/nodes/data/optimistic_locking.py +906 -0
  68. kailash/nodes/data/readers.py +8 -8
  69. kailash/nodes/data/redis.py +378 -0
  70. kailash/nodes/data/sql.py +314 -3
  71. kailash/nodes/data/streaming.py +21 -0
  72. kailash/nodes/enterprise/__init__.py +8 -0
  73. kailash/nodes/enterprise/audit_logger.py +285 -0
  74. kailash/nodes/enterprise/batch_processor.py +22 -3
  75. kailash/nodes/enterprise/data_lineage.py +1 -1
  76. kailash/nodes/enterprise/mcp_executor.py +205 -0
  77. kailash/nodes/enterprise/service_discovery.py +150 -0
  78. kailash/nodes/enterprise/tenant_assignment.py +108 -0
  79. kailash/nodes/logic/async_operations.py +2 -2
  80. kailash/nodes/logic/convergence.py +1 -1
  81. kailash/nodes/logic/operations.py +1 -1
  82. kailash/nodes/monitoring/__init__.py +11 -1
  83. kailash/nodes/monitoring/health_check.py +456 -0
  84. kailash/nodes/monitoring/log_processor.py +817 -0
  85. kailash/nodes/monitoring/metrics_collector.py +627 -0
  86. kailash/nodes/monitoring/performance_benchmark.py +137 -11
  87. kailash/nodes/rag/advanced.py +7 -7
  88. kailash/nodes/rag/agentic.py +49 -2
  89. kailash/nodes/rag/conversational.py +3 -3
  90. kailash/nodes/rag/evaluation.py +3 -3
  91. kailash/nodes/rag/federated.py +3 -3
  92. kailash/nodes/rag/graph.py +3 -3
  93. kailash/nodes/rag/multimodal.py +3 -3
  94. kailash/nodes/rag/optimized.py +5 -5
  95. kailash/nodes/rag/privacy.py +3 -3
  96. kailash/nodes/rag/query_processing.py +6 -6
  97. kailash/nodes/rag/realtime.py +1 -1
  98. kailash/nodes/rag/registry.py +1 -1
  99. kailash/nodes/rag/router.py +1 -1
  100. kailash/nodes/rag/similarity.py +7 -7
  101. kailash/nodes/rag/strategies.py +4 -4
  102. kailash/nodes/security/abac_evaluator.py +6 -6
  103. kailash/nodes/security/behavior_analysis.py +5 -5
  104. kailash/nodes/security/credential_manager.py +1 -1
  105. kailash/nodes/security/rotating_credentials.py +11 -11
  106. kailash/nodes/security/threat_detection.py +8 -8
  107. kailash/nodes/testing/credential_testing.py +2 -2
  108. kailash/nodes/transform/processors.py +5 -5
  109. kailash/runtime/local.py +163 -9
  110. kailash/runtime/parameter_injection.py +425 -0
  111. kailash/runtime/parameter_injector.py +657 -0
  112. kailash/runtime/testing.py +2 -2
  113. kailash/testing/fixtures.py +2 -2
  114. kailash/workflow/builder.py +99 -14
  115. kailash/workflow/builder_improvements.py +207 -0
  116. kailash/workflow/input_handling.py +170 -0
  117. {kailash-0.6.3.dist-info → kailash-0.6.5.dist-info}/METADATA +22 -9
  118. {kailash-0.6.3.dist-info → kailash-0.6.5.dist-info}/RECORD +122 -95
  119. {kailash-0.6.3.dist-info → kailash-0.6.5.dist-info}/WHEEL +0 -0
  120. {kailash-0.6.3.dist-info → kailash-0.6.5.dist-info}/entry_points.txt +0 -0
  121. {kailash-0.6.3.dist-info → kailash-0.6.5.dist-info}/licenses/LICENSE +0 -0
  122. {kailash-0.6.3.dist-info → kailash-0.6.5.dist-info}/top_level.txt +0 -0
@@ -1,58 +1,334 @@
1
- """Model Context Protocol (MCP) Service Layer.
1
+ """Enhanced Model Context Protocol (MCP) Service Layer with Service Discovery.
2
2
 
3
- This module provides MCP client and server functionality as services for the
4
- Kailash SDK. MCP capabilities are integrated into LLM agents as built-in
5
- features rather than standalone nodes, enabling seamless tool discovery,
6
- resource access, and prompt templating.
3
+ This module provides production-ready MCP client and server functionality with
4
+ comprehensive service discovery, authentication, monitoring, and resilience
5
+ features. Built on top of the official Anthropic MCP Python SDK.
6
+
7
+ Enhanced Features:
8
+ - Service Discovery: Automatic server registration and discovery
9
+ - Authentication: Multiple auth providers (API Key, JWT, OAuth)
10
+ - Load Balancing: Intelligent server selection and failover
11
+ - Health Monitoring: Automatic health checking and status tracking
12
+ - Circuit Breaker: Failure detection and recovery patterns
13
+ - Metrics Collection: Comprehensive performance monitoring
14
+ - Network Discovery: UDP broadcast/multicast server discovery
15
+ - Error Handling: Structured error codes and retry strategies
7
16
 
8
17
  Design Philosophy:
9
- Provides non-intrusive MCP integration that enhances node capabilities
10
- without changing the core workflow execution model. MCP services operate
11
- as background capabilities that nodes can leverage transparently.
18
+ Provides production-ready distributed systems infrastructure for MCP
19
+ while maintaining compatibility with the official SDK. Enhances the
20
+ basic protocol implementation with enterprise-grade features.
12
21
 
13
22
  Key Components:
14
- - MCPClient: Connects to MCP servers for tool and resource access
15
- - MCPServer: Main production-ready server with all features
16
- - MCPServerBase: Abstract base class for custom server implementations
17
-
18
- Upstream Dependencies:
19
- - Official Anthropic MCP Python SDK for protocol implementation
20
- - FastMCP framework for server creation and management
21
- - AsyncIO for asynchronous server/client communication
23
+ - MCPClient: Enhanced client with auth, retry, and multi-transport support
24
+ - MCPServer: Production-ready server with all enterprise features
25
+ - ServiceRegistry: Central registry for server discovery and management
26
+ - ServiceMesh: Intelligent routing and load balancing
27
+ - ServerRegistrar: Automatic server registration and lifecycle management
22
28
 
23
- Downstream Consumers:
24
- - LLMAgentNode for AI model tool integration
25
- - Workflow nodes requiring external tool access
26
- - Custom nodes needing MCP server capabilities
29
+ Service Discovery Features:
30
+ - File-based registry with JSON storage
31
+ - Network discovery via UDP broadcast/multicast
32
+ - Health checking and automatic status updates
33
+ - Capability-based server filtering
34
+ - Load balancing with priority scoring
35
+ - Automatic failover and circuit breaker patterns
27
36
 
28
37
  Examples:
29
- Basic MCP client usage:
38
+ Enhanced MCP client with discovery:
30
39
 
31
- >>> from kailash.mcp_server import MCPClient
32
- >>> client = MCPClient()
33
- >>> tools = await client.discover_tools(server_config)
40
+ >>> from kailash.mcp_server import get_mcp_client, discover_mcp_servers
41
+ >>> # Discover servers with specific capability
42
+ >>> servers = await discover_mcp_servers(capability="search")
43
+ >>> # Get best client for capability
44
+ >>> client = await get_mcp_client("search")
34
45
  >>> result = await client.call_tool(server_config, "search", {"query": "AI"})
35
46
 
36
- Simple MCP server creation:
47
+ Production MCP server with auto-discovery:
37
48
 
38
- >>> from kailash.mcp_server import MCPServer
39
- >>> server = MCPServer("my-tools")
40
- >>> @server.tool()
49
+ >>> from kailash.mcp_server import MCPServer, enable_auto_discovery
50
+ >>> from kailash.mcp_server.auth import APIKeyAuth
51
+ >>>
52
+ >>> # Create server with authentication
53
+ >>> auth = APIKeyAuth({"user1": "secret-key"})
54
+ >>> server = MCPServer(
55
+ ... "my-tools",
56
+ ... auth_provider=auth,
57
+ ... enable_metrics=True,
58
+ ... circuit_breaker_config={"failure_threshold": 5}
59
+ ... )
60
+ >>>
61
+ >>> @server.tool(required_permission="tools.calculate")
41
62
  ... def calculate(a: int, b: int) -> int:
42
63
  ... return a + b
43
- >>> server.run()
64
+ >>>
65
+ >>> # Enable auto-discovery and start
66
+ >>> registrar = enable_auto_discovery(server, enable_network_discovery=True)
67
+ >>> registrar.start_with_registration()
68
+
69
+ Service mesh with failover:
70
+
71
+ >>> from kailash.mcp_server import ServiceRegistry, ServiceMesh
72
+ >>> registry = ServiceRegistry()
73
+ >>> mesh = ServiceMesh(registry)
74
+ >>>
75
+ >>> # Call with automatic failover
76
+ >>> result = await mesh.call_with_failover(
77
+ ... "search", "web_search", {"query": "Python"}, max_retries=3
78
+ ... )
44
79
  """
45
80
 
81
+ # Advanced Features
82
+ from .advanced_features import (
83
+ BinaryResourceHandler,
84
+ CancellationContext,
85
+ ChangeType,
86
+ Content,
87
+ ContentType,
88
+ ElicitationSystem,
89
+ MultiModalContent,
90
+ ProgressReporter,
91
+ ResourceChange,
92
+ )
93
+ from .advanced_features import ResourceTemplate as AdvancedResourceTemplate
94
+ from .advanced_features import (
95
+ SchemaValidator,
96
+ StreamingHandler,
97
+ StructuredTool,
98
+ ToolAnnotation,
99
+ create_cancellation_context,
100
+ create_progress_reporter,
101
+ structured_tool,
102
+ )
103
+
104
+ # Authentication framework
105
+ from .auth import (
106
+ APIKeyAuth,
107
+ AuthManager,
108
+ AuthProvider,
109
+ BasicAuth,
110
+ BearerTokenAuth,
111
+ JWTAuth,
112
+ PermissionManager,
113
+ RateLimiter,
114
+ )
46
115
  from .client import MCPClient
47
116
 
48
- # For backward compatibility
49
- from .server import EnhancedMCPServer, MCPServer, MCPServerBase, SimpleMCPServer
117
+ # Service Discovery System
118
+ from .discovery import (
119
+ DiscoveryBackend,
120
+ FileBasedDiscovery,
121
+ HealthChecker,
122
+ LoadBalancer,
123
+ NetworkDiscovery,
124
+ ServerInfo,
125
+ ServiceMesh,
126
+ ServiceRegistry,
127
+ create_default_registry,
128
+ discover_mcp_servers,
129
+ get_mcp_client,
130
+ )
131
+
132
+ # Enhanced error handling
133
+ from .errors import (
134
+ AuthenticationError,
135
+ AuthorizationError,
136
+ CircuitBreakerRetry,
137
+ ErrorAggregator,
138
+ ExponentialBackoffRetry,
139
+ MCPError,
140
+ MCPErrorCode,
141
+ RateLimitError,
142
+ ResourceError,
143
+ RetryableOperation,
144
+ RetryStrategy,
145
+ ServiceDiscoveryError,
146
+ ToolError,
147
+ TransportError,
148
+ ValidationError,
149
+ )
150
+
151
+ # OAuth 2.1 Authentication
152
+ from .oauth import (
153
+ AccessToken,
154
+ AuthorizationCode,
155
+ AuthorizationServer,
156
+ ClientStore,
157
+ ClientType,
158
+ GrantType,
159
+ InMemoryClientStore,
160
+ InMemoryTokenStore,
161
+ JWTManager,
162
+ OAuth2Client,
163
+ OAuthClient,
164
+ RefreshToken,
165
+ ResourceServer,
166
+ TokenStore,
167
+ TokenType,
168
+ )
169
+
170
+ # Complete Protocol Implementation
171
+ from .protocol import (
172
+ CancellationManager,
173
+ CancelledNotification,
174
+ CompletionManager,
175
+ CompletionRequest,
176
+ CompletionResult,
177
+ MessageType,
178
+ MetaData,
179
+ ProgressManager,
180
+ ProgressNotification,
181
+ ProgressToken,
182
+ ProtocolManager,
183
+ ResourceTemplate,
184
+ RootsManager,
185
+ SamplingManager,
186
+ SamplingRequest,
187
+ ToolResult,
188
+ cancel_request,
189
+ complete_progress,
190
+ get_protocol_manager,
191
+ is_cancelled,
192
+ start_progress,
193
+ update_progress,
194
+ )
195
+
196
+ # Registry Integration
197
+ from .registry_integration import (
198
+ NetworkAnnouncer,
199
+ ServerRegistrar,
200
+ enable_auto_discovery,
201
+ register_server_manually,
202
+ )
203
+
204
+ # Enhanced server with production features
205
+ from .server import MCPServer, MCPServerBase, SimpleMCPServer
206
+
207
+ # Enhanced Transport Layer
208
+ from .transports import (
209
+ BaseTransport,
210
+ EnhancedStdioTransport,
211
+ SSETransport,
212
+ StreamableHTTPTransport,
213
+ TransportManager,
214
+ TransportSecurity,
215
+ WebSocketTransport,
216
+ get_transport_manager,
217
+ )
50
218
 
51
219
  __all__ = [
220
+ # Core MCP Components
52
221
  "MCPClient",
53
222
  "MCPServer",
54
223
  "MCPServerBase",
55
- # Backward compatibility
224
+ # Prototyping server
56
225
  "SimpleMCPServer",
57
- "EnhancedMCPServer",
226
+ # Service Discovery System
227
+ "ServiceRegistry",
228
+ "ServerInfo",
229
+ "DiscoveryBackend",
230
+ "FileBasedDiscovery",
231
+ "NetworkDiscovery",
232
+ "HealthChecker",
233
+ "LoadBalancer",
234
+ "ServiceMesh",
235
+ "create_default_registry",
236
+ "discover_mcp_servers",
237
+ "get_mcp_client",
238
+ # Registry Integration
239
+ "ServerRegistrar",
240
+ "NetworkAnnouncer",
241
+ "enable_auto_discovery",
242
+ "register_server_manually",
243
+ # Authentication
244
+ "AuthProvider",
245
+ "APIKeyAuth",
246
+ "BearerTokenAuth",
247
+ "JWTAuth",
248
+ "BasicAuth",
249
+ "AuthManager",
250
+ "PermissionManager",
251
+ "RateLimiter",
252
+ # Enhanced Error Handling
253
+ "MCPError",
254
+ "MCPErrorCode",
255
+ "AuthenticationError",
256
+ "AuthorizationError",
257
+ "RateLimitError",
258
+ "ToolError",
259
+ "ResourceError",
260
+ "TransportError",
261
+ "ServiceDiscoveryError",
262
+ "ValidationError",
263
+ "RetryStrategy",
264
+ "RetryableOperation",
265
+ "ExponentialBackoffRetry",
266
+ "CircuitBreakerRetry",
267
+ "ErrorAggregator",
268
+ # Complete Protocol Implementation
269
+ "MessageType",
270
+ "ProgressToken",
271
+ "MetaData",
272
+ "ProgressNotification",
273
+ "CancelledNotification",
274
+ "CompletionRequest",
275
+ "CompletionResult",
276
+ "SamplingRequest",
277
+ "ResourceTemplate",
278
+ "ToolResult",
279
+ "ProgressManager",
280
+ "CancellationManager",
281
+ "CompletionManager",
282
+ "SamplingManager",
283
+ "RootsManager",
284
+ "ProtocolManager",
285
+ "get_protocol_manager",
286
+ "start_progress",
287
+ "update_progress",
288
+ "complete_progress",
289
+ "is_cancelled",
290
+ "cancel_request",
291
+ # Enhanced Transport Layer
292
+ "BaseTransport",
293
+ "EnhancedStdioTransport",
294
+ "SSETransport",
295
+ "StreamableHTTPTransport",
296
+ "WebSocketTransport",
297
+ "TransportSecurity",
298
+ "TransportManager",
299
+ "get_transport_manager",
300
+ # OAuth 2.1 Authentication
301
+ "GrantType",
302
+ "TokenType",
303
+ "ClientType",
304
+ "OAuthClient",
305
+ "AccessToken",
306
+ "RefreshToken",
307
+ "AuthorizationCode",
308
+ "ClientStore",
309
+ "InMemoryClientStore",
310
+ "TokenStore",
311
+ "InMemoryTokenStore",
312
+ "JWTManager",
313
+ "AuthorizationServer",
314
+ "ResourceServer",
315
+ "OAuth2Client",
316
+ # Advanced Features
317
+ "ContentType",
318
+ "ChangeType",
319
+ "Content",
320
+ "ResourceChange",
321
+ "ToolAnnotation",
322
+ "MultiModalContent",
323
+ "SchemaValidator",
324
+ "StructuredTool",
325
+ "AdvancedResourceTemplate",
326
+ "BinaryResourceHandler",
327
+ "StreamingHandler",
328
+ "ElicitationSystem",
329
+ "ProgressReporter",
330
+ "CancellationContext",
331
+ "structured_tool",
332
+ "create_progress_reporter",
333
+ "create_cancellation_context",
58
334
  ]