kailash 0.6.2__py3-none-any.whl → 0.6.4__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.
- kailash/__init__.py +3 -3
- kailash/api/custom_nodes_secure.py +3 -3
- kailash/api/gateway.py +1 -1
- kailash/api/studio.py +2 -3
- kailash/api/workflow_api.py +3 -4
- kailash/core/resilience/bulkhead.py +460 -0
- kailash/core/resilience/circuit_breaker.py +92 -10
- kailash/edge/discovery.py +86 -0
- kailash/mcp_server/__init__.py +334 -0
- kailash/mcp_server/advanced_features.py +1022 -0
- kailash/{mcp → mcp_server}/ai_registry_server.py +29 -4
- kailash/mcp_server/auth.py +789 -0
- kailash/mcp_server/client.py +712 -0
- kailash/mcp_server/discovery.py +1593 -0
- kailash/mcp_server/errors.py +673 -0
- kailash/mcp_server/oauth.py +1727 -0
- kailash/mcp_server/protocol.py +1126 -0
- kailash/mcp_server/registry_integration.py +587 -0
- kailash/mcp_server/server.py +1747 -0
- kailash/{mcp → mcp_server}/servers/ai_registry.py +2 -2
- kailash/mcp_server/transports.py +1169 -0
- kailash/mcp_server/utils/cache.py +510 -0
- kailash/middleware/auth/auth_manager.py +3 -3
- kailash/middleware/communication/api_gateway.py +2 -9
- kailash/middleware/communication/realtime.py +1 -1
- kailash/middleware/mcp/client_integration.py +1 -1
- kailash/middleware/mcp/enhanced_server.py +2 -2
- kailash/nodes/__init__.py +2 -0
- kailash/nodes/admin/audit_log.py +6 -6
- kailash/nodes/admin/permission_check.py +8 -8
- kailash/nodes/admin/role_management.py +32 -28
- kailash/nodes/admin/schema.sql +6 -1
- kailash/nodes/admin/schema_manager.py +13 -13
- kailash/nodes/admin/security_event.py +16 -20
- kailash/nodes/admin/tenant_isolation.py +3 -3
- kailash/nodes/admin/transaction_utils.py +3 -3
- kailash/nodes/admin/user_management.py +21 -22
- kailash/nodes/ai/a2a.py +11 -11
- kailash/nodes/ai/ai_providers.py +9 -12
- kailash/nodes/ai/embedding_generator.py +13 -14
- kailash/nodes/ai/intelligent_agent_orchestrator.py +19 -19
- kailash/nodes/ai/iterative_llm_agent.py +3 -3
- kailash/nodes/ai/llm_agent.py +213 -36
- kailash/nodes/ai/self_organizing.py +2 -2
- kailash/nodes/alerts/discord.py +4 -4
- kailash/nodes/api/graphql.py +6 -6
- kailash/nodes/api/http.py +12 -17
- kailash/nodes/api/rate_limiting.py +4 -4
- kailash/nodes/api/rest.py +15 -15
- kailash/nodes/auth/mfa.py +3 -4
- kailash/nodes/auth/risk_assessment.py +2 -2
- kailash/nodes/auth/session_management.py +5 -5
- kailash/nodes/auth/sso.py +143 -0
- kailash/nodes/base.py +6 -2
- kailash/nodes/base_async.py +16 -2
- kailash/nodes/base_with_acl.py +2 -2
- kailash/nodes/cache/__init__.py +9 -0
- kailash/nodes/cache/cache.py +1172 -0
- kailash/nodes/cache/cache_invalidation.py +870 -0
- kailash/nodes/cache/redis_pool_manager.py +595 -0
- kailash/nodes/code/async_python.py +2 -1
- kailash/nodes/code/python.py +196 -35
- kailash/nodes/compliance/data_retention.py +6 -6
- kailash/nodes/compliance/gdpr.py +5 -5
- kailash/nodes/data/__init__.py +10 -0
- kailash/nodes/data/optimistic_locking.py +906 -0
- kailash/nodes/data/readers.py +8 -8
- kailash/nodes/data/redis.py +349 -0
- kailash/nodes/data/sql.py +314 -3
- kailash/nodes/data/streaming.py +21 -0
- kailash/nodes/enterprise/__init__.py +8 -0
- kailash/nodes/enterprise/audit_logger.py +285 -0
- kailash/nodes/enterprise/batch_processor.py +22 -3
- kailash/nodes/enterprise/data_lineage.py +1 -1
- kailash/nodes/enterprise/mcp_executor.py +205 -0
- kailash/nodes/enterprise/service_discovery.py +150 -0
- kailash/nodes/enterprise/tenant_assignment.py +108 -0
- kailash/nodes/logic/async_operations.py +2 -2
- kailash/nodes/logic/convergence.py +1 -1
- kailash/nodes/logic/operations.py +1 -1
- kailash/nodes/monitoring/__init__.py +11 -1
- kailash/nodes/monitoring/health_check.py +456 -0
- kailash/nodes/monitoring/log_processor.py +817 -0
- kailash/nodes/monitoring/metrics_collector.py +627 -0
- kailash/nodes/monitoring/performance_benchmark.py +137 -11
- kailash/nodes/rag/advanced.py +7 -7
- kailash/nodes/rag/agentic.py +49 -2
- kailash/nodes/rag/conversational.py +3 -3
- kailash/nodes/rag/evaluation.py +3 -3
- kailash/nodes/rag/federated.py +3 -3
- kailash/nodes/rag/graph.py +3 -3
- kailash/nodes/rag/multimodal.py +3 -3
- kailash/nodes/rag/optimized.py +5 -5
- kailash/nodes/rag/privacy.py +3 -3
- kailash/nodes/rag/query_processing.py +6 -6
- kailash/nodes/rag/realtime.py +1 -1
- kailash/nodes/rag/registry.py +2 -6
- kailash/nodes/rag/router.py +1 -1
- kailash/nodes/rag/similarity.py +7 -7
- kailash/nodes/rag/strategies.py +4 -4
- kailash/nodes/security/abac_evaluator.py +6 -6
- kailash/nodes/security/behavior_analysis.py +5 -6
- kailash/nodes/security/credential_manager.py +1 -1
- kailash/nodes/security/rotating_credentials.py +11 -11
- kailash/nodes/security/threat_detection.py +8 -8
- kailash/nodes/testing/credential_testing.py +2 -2
- kailash/nodes/transform/processors.py +5 -5
- kailash/runtime/local.py +162 -14
- kailash/runtime/parameter_injection.py +425 -0
- kailash/runtime/parameter_injector.py +657 -0
- kailash/runtime/testing.py +2 -2
- kailash/testing/fixtures.py +2 -2
- kailash/workflow/builder.py +99 -18
- kailash/workflow/builder_improvements.py +207 -0
- kailash/workflow/input_handling.py +170 -0
- {kailash-0.6.2.dist-info → kailash-0.6.4.dist-info}/METADATA +21 -8
- {kailash-0.6.2.dist-info → kailash-0.6.4.dist-info}/RECORD +126 -101
- kailash/mcp/__init__.py +0 -53
- kailash/mcp/client.py +0 -445
- kailash/mcp/server.py +0 -292
- kailash/mcp/server_enhanced.py +0 -449
- kailash/mcp/utils/cache.py +0 -267
- /kailash/{mcp → mcp_server}/client_new.py +0 -0
- /kailash/{mcp → mcp_server}/utils/__init__.py +0 -0
- /kailash/{mcp → mcp_server}/utils/config.py +0 -0
- /kailash/{mcp → mcp_server}/utils/formatters.py +0 -0
- /kailash/{mcp → mcp_server}/utils/metrics.py +0 -0
- {kailash-0.6.2.dist-info → kailash-0.6.4.dist-info}/WHEEL +0 -0
- {kailash-0.6.2.dist-info → kailash-0.6.4.dist-info}/entry_points.txt +0 -0
- {kailash-0.6.2.dist-info → kailash-0.6.4.dist-info}/licenses/LICENSE +0 -0
- {kailash-0.6.2.dist-info → kailash-0.6.4.dist-info}/top_level.txt +0 -0
kailash/mcp/server.py
DELETED
@@ -1,292 +0,0 @@
|
|
1
|
-
"""MCP Server Framework using official Anthropic SDK.
|
2
|
-
|
3
|
-
This module provides a comprehensive framework for creating MCP servers using
|
4
|
-
the official FastMCP framework from Anthropic. Servers run as long-lived
|
5
|
-
services that expose tools, resources, and prompts to MCP clients, enabling
|
6
|
-
dynamic capability extension for AI workflows.
|
7
|
-
|
8
|
-
Note:
|
9
|
-
This module requires the FastMCP framework to be installed.
|
10
|
-
Install with: pip install 'mcp[server]'
|
11
|
-
|
12
|
-
Examples:
|
13
|
-
Basic server with tools:
|
14
|
-
|
15
|
-
>>> from kailash.mcp.server import MCPServer
|
16
|
-
>>> class MyServer(MCPServer):
|
17
|
-
... def setup(self):
|
18
|
-
... @self.add_tool()
|
19
|
-
... def calculate(a: int, b: int) -> int:
|
20
|
-
... return a + b
|
21
|
-
>>> server = MyServer("calculator", port=8080)
|
22
|
-
>>> server.start()
|
23
|
-
|
24
|
-
Quick server creation:
|
25
|
-
|
26
|
-
>>> from kailash.mcp.server import SimpleMCPServer
|
27
|
-
>>> server = SimpleMCPServer("my-tools")
|
28
|
-
>>> @server.tool()
|
29
|
-
... def search(query: str) -> list:
|
30
|
-
... return [f"Result for {query}"]
|
31
|
-
>>> server.start()
|
32
|
-
"""
|
33
|
-
|
34
|
-
import logging
|
35
|
-
from abc import ABC, abstractmethod
|
36
|
-
from collections.abc import Callable
|
37
|
-
|
38
|
-
logger = logging.getLogger(__name__)
|
39
|
-
|
40
|
-
|
41
|
-
class MCPServer(ABC):
|
42
|
-
"""Base class for MCP servers using FastMCP.
|
43
|
-
|
44
|
-
This provides a framework for creating MCP servers that expose
|
45
|
-
tools, resources, and prompts via the Model Context Protocol.
|
46
|
-
|
47
|
-
Examples:
|
48
|
-
Creating a custom server:
|
49
|
-
|
50
|
-
>>> class MyServer(MCPServer):
|
51
|
-
... def setup(self):
|
52
|
-
... @self.add_tool()
|
53
|
-
... def search(query: str) -> str:
|
54
|
-
... return f"Results for: {query}"
|
55
|
-
... @self.add_resource("data://example")
|
56
|
-
... def get_example():
|
57
|
-
... return "Example data"
|
58
|
-
>>> server = MyServer("my-server", port=8080)
|
59
|
-
>>> server.start() # Runs until stopped
|
60
|
-
"""
|
61
|
-
|
62
|
-
def __init__(self, name: str, port: int = 8080, host: str = "localhost"):
|
63
|
-
"""Initialize the MCP server.
|
64
|
-
|
65
|
-
Args:
|
66
|
-
name: Name of the server.
|
67
|
-
port: Port to listen on (default: 8080).
|
68
|
-
host: Host to bind to (default: "localhost").
|
69
|
-
"""
|
70
|
-
self.name = name
|
71
|
-
self.port = port
|
72
|
-
self.host = host
|
73
|
-
self._mcp = None
|
74
|
-
self._running = False
|
75
|
-
|
76
|
-
@abstractmethod
|
77
|
-
def setup(self):
|
78
|
-
"""Setup server tools, resources, and prompts.
|
79
|
-
|
80
|
-
This method should be implemented by subclasses to define
|
81
|
-
the server's capabilities using decorators.
|
82
|
-
|
83
|
-
Note:
|
84
|
-
Use @self.add_tool(), @self.add_resource(uri), and
|
85
|
-
@self.add_prompt(name) decorators to register capabilities.
|
86
|
-
"""
|
87
|
-
|
88
|
-
def add_tool(self):
|
89
|
-
"""Decorator to add a tool to the server.
|
90
|
-
|
91
|
-
Returns:
|
92
|
-
Function decorator for registering tools.
|
93
|
-
|
94
|
-
Examples:
|
95
|
-
>>> @server.add_tool()
|
96
|
-
... def calculate(a: int, b: int) -> int:
|
97
|
-
... '''Add two numbers'''
|
98
|
-
... return a + b
|
99
|
-
"""
|
100
|
-
|
101
|
-
def decorator(func: Callable):
|
102
|
-
if self._mcp is None:
|
103
|
-
self._init_mcp()
|
104
|
-
|
105
|
-
# Use FastMCP's tool decorator
|
106
|
-
return self._mcp.tool()(func)
|
107
|
-
|
108
|
-
return decorator
|
109
|
-
|
110
|
-
def add_resource(self, uri: str):
|
111
|
-
"""Decorator to add a resource to the server.
|
112
|
-
|
113
|
-
Args:
|
114
|
-
uri: URI pattern for the resource (supports wildcards).
|
115
|
-
|
116
|
-
Returns:
|
117
|
-
Function decorator for registering resources.
|
118
|
-
|
119
|
-
Examples:
|
120
|
-
>>> @server.add_resource("file:///data/*")
|
121
|
-
... def get_file(path: str) -> str:
|
122
|
-
... return f"Content of {path}"
|
123
|
-
"""
|
124
|
-
|
125
|
-
def decorator(func: Callable):
|
126
|
-
if self._mcp is None:
|
127
|
-
self._init_mcp()
|
128
|
-
|
129
|
-
# Use FastMCP's resource decorator
|
130
|
-
return self._mcp.resource(uri)(func)
|
131
|
-
|
132
|
-
return decorator
|
133
|
-
|
134
|
-
def add_prompt(self, name: str):
|
135
|
-
"""Decorator to add a prompt template to the server.
|
136
|
-
|
137
|
-
Args:
|
138
|
-
name: Name of the prompt.
|
139
|
-
|
140
|
-
Returns:
|
141
|
-
Function decorator for registering prompts.
|
142
|
-
|
143
|
-
Examples:
|
144
|
-
>>> @server.add_prompt("analyze")
|
145
|
-
... def analyze_prompt(data: str) -> str:
|
146
|
-
... return f"Please analyze the following data: {data}"
|
147
|
-
"""
|
148
|
-
|
149
|
-
def decorator(func: Callable):
|
150
|
-
if self._mcp is None:
|
151
|
-
self._init_mcp()
|
152
|
-
|
153
|
-
# Use FastMCP's prompt decorator
|
154
|
-
return self._mcp.prompt(name)(func)
|
155
|
-
|
156
|
-
return decorator
|
157
|
-
|
158
|
-
def _init_mcp(self):
|
159
|
-
"""Initialize the FastMCP instance."""
|
160
|
-
try:
|
161
|
-
from mcp.server.fastmcp import FastMCP
|
162
|
-
|
163
|
-
self._mcp = FastMCP(self.name)
|
164
|
-
except ImportError:
|
165
|
-
logger.error(
|
166
|
-
"FastMCP not available. Install with: pip install 'mcp[server]'"
|
167
|
-
)
|
168
|
-
raise
|
169
|
-
|
170
|
-
def start(self):
|
171
|
-
"""Start the MCP server.
|
172
|
-
|
173
|
-
This runs the server as a long-lived process until stopped.
|
174
|
-
|
175
|
-
Raises:
|
176
|
-
ImportError: If FastMCP is not available.
|
177
|
-
Exception: If server fails to start.
|
178
|
-
"""
|
179
|
-
if self._mcp is None:
|
180
|
-
self._init_mcp()
|
181
|
-
|
182
|
-
# Run setup to register tools/resources
|
183
|
-
self.setup()
|
184
|
-
|
185
|
-
logger.info(f"Starting MCP server '{self.name}' on {self.host}:{self.port}")
|
186
|
-
self._running = True
|
187
|
-
|
188
|
-
try:
|
189
|
-
# Run the FastMCP server
|
190
|
-
logger.info("Running FastMCP server in stdio mode")
|
191
|
-
self._mcp.run()
|
192
|
-
except Exception as e:
|
193
|
-
logger.error(f"Failed to start server: {e}")
|
194
|
-
raise
|
195
|
-
finally:
|
196
|
-
self._running = False
|
197
|
-
|
198
|
-
def stop(self):
|
199
|
-
"""Stop the MCP server."""
|
200
|
-
logger.info(f"Stopping MCP server '{self.name}'")
|
201
|
-
self._running = False
|
202
|
-
# In a real implementation, we'd need to handle graceful shutdown
|
203
|
-
|
204
|
-
|
205
|
-
class SimpleMCPServer(MCPServer):
|
206
|
-
"""Simple MCP server for basic use cases.
|
207
|
-
|
208
|
-
This provides an easy way to create MCP servers without subclassing.
|
209
|
-
|
210
|
-
Examples:
|
211
|
-
>>> server = SimpleMCPServer("my-server")
|
212
|
-
>>> @server.tool()
|
213
|
-
... def add(a: int, b: int) -> int:
|
214
|
-
... return a + b
|
215
|
-
>>> server.start()
|
216
|
-
"""
|
217
|
-
|
218
|
-
def __init__(self, name: str, port: int = 8080, host: str = "localhost"):
|
219
|
-
"""Initialize the simple MCP server.
|
220
|
-
|
221
|
-
Args:
|
222
|
-
name: Name of the server.
|
223
|
-
port: Port to listen on (default: 8080).
|
224
|
-
host: Host to bind to (default: "localhost").
|
225
|
-
"""
|
226
|
-
super().__init__(name, port, host)
|
227
|
-
self._tools = []
|
228
|
-
self._resources = []
|
229
|
-
self._prompts = []
|
230
|
-
|
231
|
-
def tool(self):
|
232
|
-
"""Decorator to add a tool.
|
233
|
-
|
234
|
-
Returns:
|
235
|
-
Function decorator for registering tools.
|
236
|
-
"""
|
237
|
-
|
238
|
-
def decorator(func):
|
239
|
-
self._tools.append(func)
|
240
|
-
return func
|
241
|
-
|
242
|
-
return decorator
|
243
|
-
|
244
|
-
def resource(self, uri: str):
|
245
|
-
"""Decorator to add a resource.
|
246
|
-
|
247
|
-
Args:
|
248
|
-
uri: URI pattern for the resource.
|
249
|
-
|
250
|
-
Returns:
|
251
|
-
Function decorator for registering resources.
|
252
|
-
"""
|
253
|
-
|
254
|
-
def decorator(func):
|
255
|
-
self._resources.append((uri, func))
|
256
|
-
return func
|
257
|
-
|
258
|
-
return decorator
|
259
|
-
|
260
|
-
def prompt(self, name: str):
|
261
|
-
"""Decorator to add a prompt.
|
262
|
-
|
263
|
-
Args:
|
264
|
-
name: Name of the prompt.
|
265
|
-
|
266
|
-
Returns:
|
267
|
-
Function decorator for registering prompts.
|
268
|
-
"""
|
269
|
-
|
270
|
-
def decorator(func):
|
271
|
-
self._prompts.append((name, func))
|
272
|
-
return func
|
273
|
-
|
274
|
-
return decorator
|
275
|
-
|
276
|
-
def setup(self):
|
277
|
-
"""Setup the server with registered components.
|
278
|
-
|
279
|
-
Registers all tools, resources, and prompts that were decorated
|
280
|
-
before calling start().
|
281
|
-
"""
|
282
|
-
# Register all tools
|
283
|
-
for tool_func in self._tools:
|
284
|
-
self.add_tool()(tool_func)
|
285
|
-
|
286
|
-
# Register all resources
|
287
|
-
for uri, resource_func in self._resources:
|
288
|
-
self.add_resource(uri)(resource_func)
|
289
|
-
|
290
|
-
# Register all prompts
|
291
|
-
for name, prompt_func in self._prompts:
|
292
|
-
self.add_prompt(name)(prompt_func)
|