chuk-tool-processor 0.1.6__py3-none-any.whl → 0.1.7__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 chuk-tool-processor might be problematic. Click here for more details.
- chuk_tool_processor/core/processor.py +345 -132
- chuk_tool_processor/execution/strategies/inprocess_strategy.py +512 -68
- chuk_tool_processor/execution/strategies/subprocess_strategy.py +523 -63
- chuk_tool_processor/execution/tool_executor.py +282 -24
- chuk_tool_processor/execution/wrappers/caching.py +465 -123
- chuk_tool_processor/execution/wrappers/rate_limiting.py +199 -86
- chuk_tool_processor/execution/wrappers/retry.py +133 -23
- chuk_tool_processor/logging/__init__.py +83 -10
- chuk_tool_processor/logging/context.py +218 -22
- chuk_tool_processor/logging/formatter.py +56 -13
- chuk_tool_processor/logging/helpers.py +91 -16
- chuk_tool_processor/logging/metrics.py +75 -6
- chuk_tool_processor/mcp/mcp_tool.py +80 -35
- chuk_tool_processor/mcp/register_mcp_tools.py +74 -56
- chuk_tool_processor/mcp/setup_mcp_sse.py +41 -36
- chuk_tool_processor/mcp/setup_mcp_stdio.py +39 -37
- chuk_tool_processor/models/execution_strategy.py +52 -3
- chuk_tool_processor/models/streaming_tool.py +110 -0
- chuk_tool_processor/models/tool_call.py +56 -4
- chuk_tool_processor/models/tool_result.py +115 -9
- chuk_tool_processor/models/validated_tool.py +15 -13
- chuk_tool_processor/plugins/discovery.py +115 -70
- chuk_tool_processor/plugins/parsers/base.py +13 -5
- chuk_tool_processor/plugins/parsers/{function_call_tool_plugin.py → function_call_tool.py} +39 -20
- chuk_tool_processor/plugins/parsers/json_tool.py +50 -0
- chuk_tool_processor/plugins/parsers/openai_tool.py +88 -0
- chuk_tool_processor/plugins/parsers/xml_tool.py +74 -20
- chuk_tool_processor/registry/__init__.py +46 -7
- chuk_tool_processor/registry/auto_register.py +92 -28
- chuk_tool_processor/registry/decorators.py +134 -11
- chuk_tool_processor/registry/interface.py +48 -14
- chuk_tool_processor/registry/metadata.py +52 -6
- chuk_tool_processor/registry/provider.py +75 -36
- chuk_tool_processor/registry/providers/__init__.py +49 -10
- chuk_tool_processor/registry/providers/memory.py +59 -48
- chuk_tool_processor/registry/tool_export.py +208 -39
- chuk_tool_processor/utils/validation.py +18 -13
- chuk_tool_processor-0.1.7.dist-info/METADATA +401 -0
- chuk_tool_processor-0.1.7.dist-info/RECORD +58 -0
- {chuk_tool_processor-0.1.6.dist-info → chuk_tool_processor-0.1.7.dist-info}/WHEEL +1 -1
- chuk_tool_processor/plugins/parsers/json_tool_plugin.py +0 -38
- chuk_tool_processor/plugins/parsers/openai_tool_plugin.py +0 -76
- chuk_tool_processor-0.1.6.dist-info/METADATA +0 -462
- chuk_tool_processor-0.1.6.dist-info/RECORD +0 -57
- {chuk_tool_processor-0.1.6.dist-info → chuk_tool_processor-0.1.7.dist-info}/top_level.txt +0 -0
|
@@ -1,462 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: chuk-tool-processor
|
|
3
|
-
Version: 0.1.6
|
|
4
|
-
Summary: Add your description here
|
|
5
|
-
Requires-Python: >=3.11
|
|
6
|
-
Description-Content-Type: text/markdown
|
|
7
|
-
Requires-Dist: chuk-mcp>=0.1.12
|
|
8
|
-
Requires-Dist: dotenv>=0.9.9
|
|
9
|
-
Requires-Dist: openai>=1.76.0
|
|
10
|
-
Requires-Dist: pydantic>=2.11.3
|
|
11
|
-
Requires-Dist: uuid>=1.30
|
|
12
|
-
|
|
13
|
-
# CHUK Tool Processor
|
|
14
|
-
|
|
15
|
-
A robust framework for detecting, executing, and managing tool calls in LLM responses.
|
|
16
|
-
|
|
17
|
-
## Overview
|
|
18
|
-
|
|
19
|
-
The CHUK Tool Processor is a Python library designed to handle the execution of tools referenced in the output of Large Language Models (LLMs). It provides a flexible and extensible architecture for:
|
|
20
|
-
|
|
21
|
-
1. **Parsing tool calls** from different formats (JSON, XML, function calls)
|
|
22
|
-
2. **Executing tools** with proper isolation and error handling
|
|
23
|
-
3. **Managing tool executions** with retry logic, caching, and rate limiting
|
|
24
|
-
4. **Monitoring tool usage** with comprehensive logging
|
|
25
|
-
5. **MCP (Model Context Protocol) Integration** for remote tool execution
|
|
26
|
-
|
|
27
|
-
## Features
|
|
28
|
-
|
|
29
|
-
- **Multiple Parser Support**: Extract tool calls from JSON, XML, or OpenAI-style function call formats
|
|
30
|
-
- **Flexible Execution Strategies**: Choose between in-process or subprocess execution for different isolation needs
|
|
31
|
-
- **Namespace Support**: Organize tools in logical namespaces
|
|
32
|
-
- **Concurrency Control**: Set limits on parallel tool executions
|
|
33
|
-
- **Validation**: Type validation for tool arguments and results
|
|
34
|
-
- **Caching**: Cache tool results to improve performance for repeated calls
|
|
35
|
-
- **Rate Limiting**: Prevent overloading external services with configurable rate limits
|
|
36
|
-
- **Retry Logic**: Automatically retry transient failures with exponential backoff
|
|
37
|
-
- **Structured Logging**: Comprehensive logging system for debugging and monitoring
|
|
38
|
-
- **Plugin Discovery**: Dynamically discover and load plugins from packages
|
|
39
|
-
- **MCP Integration**: Connect to and execute remote tools via Model Context Protocol
|
|
40
|
-
|
|
41
|
-
## Installation
|
|
42
|
-
|
|
43
|
-
```bash
|
|
44
|
-
# Clone the repository
|
|
45
|
-
git clone https://github.com/your-org/chuk-tool-processor.git
|
|
46
|
-
cd chuk-tool-processor
|
|
47
|
-
|
|
48
|
-
# Install with pip
|
|
49
|
-
pip install -e .
|
|
50
|
-
|
|
51
|
-
# Or with uv
|
|
52
|
-
uv pip install -e .
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
## Quick Start
|
|
56
|
-
|
|
57
|
-
### Registering Tools
|
|
58
|
-
|
|
59
|
-
```python
|
|
60
|
-
from chuk_tool_processor.registry import register_tool
|
|
61
|
-
|
|
62
|
-
@register_tool(name="calculator", namespace="math")
|
|
63
|
-
class CalculatorTool:
|
|
64
|
-
def execute(self, operation: str, a: float, b: float):
|
|
65
|
-
if operation == "add":
|
|
66
|
-
return a + b
|
|
67
|
-
elif operation == "multiply":
|
|
68
|
-
return a * b
|
|
69
|
-
# ... other operations
|
|
70
|
-
```
|
|
71
|
-
|
|
72
|
-
### Processing Tool Calls
|
|
73
|
-
|
|
74
|
-
```python
|
|
75
|
-
import asyncio
|
|
76
|
-
from chuk_tool_processor.core.processor import ToolProcessor
|
|
77
|
-
|
|
78
|
-
async def main():
|
|
79
|
-
# Create a processor with default settings
|
|
80
|
-
processor = ToolProcessor()
|
|
81
|
-
|
|
82
|
-
# Process text with potential tool calls
|
|
83
|
-
llm_response = """
|
|
84
|
-
To calculate that, I'll use the calculator tool.
|
|
85
|
-
|
|
86
|
-
{
|
|
87
|
-
"function_call": {
|
|
88
|
-
"name": "calculator",
|
|
89
|
-
"arguments": {"operation": "multiply", "a": 123.45, "b": 67.89}
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
"""
|
|
93
|
-
|
|
94
|
-
results = await processor.process_text(llm_response)
|
|
95
|
-
|
|
96
|
-
# Handle results
|
|
97
|
-
for result in results:
|
|
98
|
-
print(f"Tool: {result.tool}")
|
|
99
|
-
print(f"Result: {result.result}")
|
|
100
|
-
print(f"Error: {result.error}")
|
|
101
|
-
print(f"Duration: {(result.end_time - result.start_time).total_seconds()}s")
|
|
102
|
-
|
|
103
|
-
if __name__ == "__main__":
|
|
104
|
-
asyncio.run(main())
|
|
105
|
-
```
|
|
106
|
-
|
|
107
|
-
## MCP Integration
|
|
108
|
-
|
|
109
|
-
The CHUK Tool Processor supports Model Context Protocol (MCP) for connecting to remote tool servers. This enables distributed tool execution and integration with third-party services.
|
|
110
|
-
|
|
111
|
-
### MCP with Stdio Transport
|
|
112
|
-
|
|
113
|
-
```python
|
|
114
|
-
import asyncio
|
|
115
|
-
from chuk_tool_processor.mcp import setup_mcp_stdio
|
|
116
|
-
|
|
117
|
-
async def main():
|
|
118
|
-
# Configure MCP server
|
|
119
|
-
config_file = "server_config.json"
|
|
120
|
-
servers = ["echo", "calculator", "search"]
|
|
121
|
-
server_names = {0: "echo", 1: "calculator", 2: "search"}
|
|
122
|
-
|
|
123
|
-
# Setup MCP with stdio transport
|
|
124
|
-
processor, stream_manager = await setup_mcp_stdio(
|
|
125
|
-
config_file=config_file,
|
|
126
|
-
servers=servers,
|
|
127
|
-
server_names=server_names,
|
|
128
|
-
namespace="mcp", # All tools will be registered under this namespace
|
|
129
|
-
enable_caching=True,
|
|
130
|
-
enable_retries=True
|
|
131
|
-
)
|
|
132
|
-
|
|
133
|
-
# Process text with MCP tool calls
|
|
134
|
-
llm_text = """
|
|
135
|
-
Let me echo your message using the MCP server.
|
|
136
|
-
|
|
137
|
-
<tool name="mcp.echo" args='{"message": "Hello from MCP!"}'/>
|
|
138
|
-
"""
|
|
139
|
-
|
|
140
|
-
results = await processor.process_text(llm_text)
|
|
141
|
-
|
|
142
|
-
for result in results:
|
|
143
|
-
print(f"Tool: {result.tool}")
|
|
144
|
-
print(f"Result: {result.result}")
|
|
145
|
-
|
|
146
|
-
# Clean up
|
|
147
|
-
await stream_manager.close()
|
|
148
|
-
|
|
149
|
-
if __name__ == "__main__":
|
|
150
|
-
asyncio.run(main())
|
|
151
|
-
```
|
|
152
|
-
|
|
153
|
-
### MCP Server Configuration
|
|
154
|
-
|
|
155
|
-
Create a server configuration file (`server_config.json`):
|
|
156
|
-
|
|
157
|
-
```json
|
|
158
|
-
{
|
|
159
|
-
"mcpServers": {
|
|
160
|
-
"echo": {
|
|
161
|
-
"command": "uv",
|
|
162
|
-
"args": ["--directory", "/path/to/echo-server", "run", "src/echo_server/main.py"]
|
|
163
|
-
},
|
|
164
|
-
"calculator": {
|
|
165
|
-
"command": "node",
|
|
166
|
-
"args": ["/path/to/calculator-server/index.js"]
|
|
167
|
-
},
|
|
168
|
-
"search": {
|
|
169
|
-
"command": "python",
|
|
170
|
-
"args": ["/path/to/search-server/main.py"]
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
```
|
|
175
|
-
|
|
176
|
-
### Namespaced Tool Access
|
|
177
|
-
|
|
178
|
-
MCP tools are automatically registered in both their namespace and the default namespace:
|
|
179
|
-
|
|
180
|
-
```python
|
|
181
|
-
# These are equivalent:
|
|
182
|
-
<tool name="echo" args='{"message": "Hello"}'/>
|
|
183
|
-
<tool name="mcp.echo" args='{"message": "Hello"}'/>
|
|
184
|
-
```
|
|
185
|
-
|
|
186
|
-
### MCP with SSE Transport
|
|
187
|
-
|
|
188
|
-
```python
|
|
189
|
-
import asyncio
|
|
190
|
-
from chuk_tool_processor.mcp import setup_mcp_sse
|
|
191
|
-
|
|
192
|
-
async def main():
|
|
193
|
-
# Configure SSE servers
|
|
194
|
-
sse_servers = [
|
|
195
|
-
{
|
|
196
|
-
"name": "weather",
|
|
197
|
-
"url": "https://api.example.com/sse/weather",
|
|
198
|
-
"api_key": "your_api_key"
|
|
199
|
-
},
|
|
200
|
-
{
|
|
201
|
-
"name": "geocoding",
|
|
202
|
-
"url": "https://api.example.com/sse/geocoding"
|
|
203
|
-
}
|
|
204
|
-
]
|
|
205
|
-
|
|
206
|
-
# Setup MCP with SSE transport
|
|
207
|
-
processor, stream_manager = await setup_mcp_sse(
|
|
208
|
-
servers=sse_servers,
|
|
209
|
-
server_names={0: "weather", 1: "geocoding"},
|
|
210
|
-
namespace="remote",
|
|
211
|
-
enable_caching=True
|
|
212
|
-
)
|
|
213
|
-
|
|
214
|
-
# Process tool calls
|
|
215
|
-
llm_text = """
|
|
216
|
-
Get the weather for New York.
|
|
217
|
-
|
|
218
|
-
<tool name="remote.weather" args='{"location": "New York", "units": "imperial"}'/>
|
|
219
|
-
"""
|
|
220
|
-
|
|
221
|
-
results = await processor.process_text(llm_text)
|
|
222
|
-
|
|
223
|
-
await stream_manager.close()
|
|
224
|
-
```
|
|
225
|
-
|
|
226
|
-
### MCP Stream Manager
|
|
227
|
-
|
|
228
|
-
The `StreamManager` class handles all MCP communication:
|
|
229
|
-
|
|
230
|
-
```python
|
|
231
|
-
from chuk_tool_processor.mcp.stream_manager import StreamManager
|
|
232
|
-
|
|
233
|
-
# Create and initialize
|
|
234
|
-
stream_manager = await StreamManager.create(
|
|
235
|
-
config_file="config.json",
|
|
236
|
-
servers=["echo", "search"],
|
|
237
|
-
transport_type="stdio"
|
|
238
|
-
)
|
|
239
|
-
|
|
240
|
-
# Get available tools
|
|
241
|
-
tools = stream_manager.get_all_tools()
|
|
242
|
-
for tool in tools:
|
|
243
|
-
print(f"Tool: {tool['name']}")
|
|
244
|
-
|
|
245
|
-
# Get server information
|
|
246
|
-
server_info = stream_manager.get_server_info()
|
|
247
|
-
for server in server_info:
|
|
248
|
-
print(f"Server: {server['name']}, Status: {server['status']}")
|
|
249
|
-
|
|
250
|
-
# Call a tool directly
|
|
251
|
-
result = await stream_manager.call_tool(
|
|
252
|
-
tool_name="echo",
|
|
253
|
-
arguments={"message": "Hello"}
|
|
254
|
-
)
|
|
255
|
-
|
|
256
|
-
# Clean up
|
|
257
|
-
await stream_manager.close()
|
|
258
|
-
```
|
|
259
|
-
|
|
260
|
-
## Advanced Usage
|
|
261
|
-
|
|
262
|
-
### Using Decorators for Tool Configuration
|
|
263
|
-
|
|
264
|
-
```python
|
|
265
|
-
from chuk_tool_processor.registry import register_tool
|
|
266
|
-
from chuk_tool_processor.utils.validation import with_validation
|
|
267
|
-
from chuk_tool_processor.execution.wrappers.retry import retryable
|
|
268
|
-
from chuk_tool_processor.execution.wrappers.caching import cacheable
|
|
269
|
-
from chuk_tool_processor.execution.wrappers.rate_limiting import rate_limited
|
|
270
|
-
from typing import Dict, Any, Optional
|
|
271
|
-
|
|
272
|
-
@register_tool(name="weather", namespace="data")
|
|
273
|
-
@retryable(max_retries=3)
|
|
274
|
-
@cacheable(ttl=3600) # Cache for 1 hour
|
|
275
|
-
@rate_limited(limit=100, period=60.0) # 100 requests per minute
|
|
276
|
-
@with_validation
|
|
277
|
-
class WeatherTool:
|
|
278
|
-
def execute(self, location: str, units: str = "metric") -> Dict[str, Any]:
|
|
279
|
-
# Implementation that calls a weather API
|
|
280
|
-
return {
|
|
281
|
-
"temperature": 22.5,
|
|
282
|
-
"conditions": "Partly Cloudy",
|
|
283
|
-
"humidity": 65
|
|
284
|
-
}
|
|
285
|
-
```
|
|
286
|
-
|
|
287
|
-
### Using Validated Tool Base Class
|
|
288
|
-
|
|
289
|
-
```python
|
|
290
|
-
from chuk_tool_processor.utils.validation import ValidatedTool
|
|
291
|
-
from chuk_tool_processor.registry import register_tool
|
|
292
|
-
from pydantic import BaseModel
|
|
293
|
-
from typing import Optional
|
|
294
|
-
|
|
295
|
-
@register_tool(namespace="data")
|
|
296
|
-
class WeatherTool(ValidatedTool):
|
|
297
|
-
class Arguments(BaseModel):
|
|
298
|
-
location: str
|
|
299
|
-
units: str = "metric" # Default to metric
|
|
300
|
-
|
|
301
|
-
class Result(BaseModel):
|
|
302
|
-
temperature: float
|
|
303
|
-
conditions: str
|
|
304
|
-
humidity: Optional[int] = None
|
|
305
|
-
|
|
306
|
-
def _execute(self, location: str, units: str = "metric"):
|
|
307
|
-
# Implementation
|
|
308
|
-
return {
|
|
309
|
-
"temperature": 22.5,
|
|
310
|
-
"conditions": "Sunny",
|
|
311
|
-
"humidity": 65
|
|
312
|
-
}
|
|
313
|
-
```
|
|
314
|
-
|
|
315
|
-
### Custom Execution Strategy
|
|
316
|
-
|
|
317
|
-
```python
|
|
318
|
-
from chuk_tool_processor.registry.providers.memory import InMemoryToolRegistry
|
|
319
|
-
from chuk_tool_processor.execution.tool_executor import ToolExecutor
|
|
320
|
-
from chuk_tool_processor.execution.inprocess_strategy import InProcessStrategy
|
|
321
|
-
|
|
322
|
-
# Create registry and register tools
|
|
323
|
-
registry = InMemoryToolRegistry()
|
|
324
|
-
registry.register_tool(MyTool(), name="my_tool")
|
|
325
|
-
|
|
326
|
-
# Create executor with custom strategy
|
|
327
|
-
executor = ToolExecutor(
|
|
328
|
-
registry,
|
|
329
|
-
strategy=InProcessStrategy(
|
|
330
|
-
registry,
|
|
331
|
-
default_timeout=5.0,
|
|
332
|
-
max_concurrency=10
|
|
333
|
-
)
|
|
334
|
-
)
|
|
335
|
-
|
|
336
|
-
# Execute tool calls
|
|
337
|
-
results = await executor.execute([call1, call2])
|
|
338
|
-
```
|
|
339
|
-
|
|
340
|
-
### Custom Parser Plugins
|
|
341
|
-
|
|
342
|
-
```python
|
|
343
|
-
from chuk_tool_processor.models.tool_call import ToolCall
|
|
344
|
-
from chuk_tool_processor.plugins.discovery import plugin_registry
|
|
345
|
-
import re
|
|
346
|
-
from typing import List
|
|
347
|
-
|
|
348
|
-
# Create a custom parser for a bracket syntax
|
|
349
|
-
class BracketToolParser:
|
|
350
|
-
"""Parser for [tool:name arg1=val1 arg2="val2"] syntax"""
|
|
351
|
-
|
|
352
|
-
def try_parse(self, raw: str) -> List[ToolCall]:
|
|
353
|
-
calls = []
|
|
354
|
-
# Regex to match [tool:name arg1=val1 arg2="val2"]
|
|
355
|
-
pattern = r"\[tool:([^\s\]]+)([^\]]*)\]"
|
|
356
|
-
matches = re.finditer(pattern, raw)
|
|
357
|
-
|
|
358
|
-
for match in matches:
|
|
359
|
-
tool_name = match.group(1)
|
|
360
|
-
args_str = match.group(2).strip()
|
|
361
|
-
|
|
362
|
-
# Parse arguments
|
|
363
|
-
args = {}
|
|
364
|
-
if args_str:
|
|
365
|
-
# Match key=value pairs, handling quoted values
|
|
366
|
-
args_pattern = r'([^\s=]+)=(?:([^\s"]+)|"([^"]*)")'
|
|
367
|
-
for arg_match in re.finditer(args_pattern, args_str):
|
|
368
|
-
key = arg_match.group(1)
|
|
369
|
-
# Either group 2 (unquoted) or group 3 (quoted)
|
|
370
|
-
value = arg_match.group(2) if arg_match.group(2) else arg_match.group(3)
|
|
371
|
-
args[key] = value
|
|
372
|
-
|
|
373
|
-
calls.append(ToolCall(tool=tool_name, arguments=args))
|
|
374
|
-
|
|
375
|
-
return calls
|
|
376
|
-
|
|
377
|
-
# Register plugin manually
|
|
378
|
-
plugin_registry.register_plugin("parser", "BracketToolParser", BracketToolParser())
|
|
379
|
-
```
|
|
380
|
-
|
|
381
|
-
### Structured Logging
|
|
382
|
-
|
|
383
|
-
```python
|
|
384
|
-
from chuk_tool_processor.logging import get_logger, log_context_span
|
|
385
|
-
|
|
386
|
-
logger = get_logger("my_module")
|
|
387
|
-
|
|
388
|
-
# Create a context span for timing operations
|
|
389
|
-
with log_context_span("operation_name", {"extra": "context"}):
|
|
390
|
-
logger.info("Starting operation")
|
|
391
|
-
# Do something
|
|
392
|
-
logger.info("Operation completed")
|
|
393
|
-
```
|
|
394
|
-
|
|
395
|
-
## Architecture
|
|
396
|
-
|
|
397
|
-
The tool processor has several key components organized into a modular structure:
|
|
398
|
-
|
|
399
|
-
1. **Registry**: Stores tool implementations and metadata
|
|
400
|
-
- `registry/interface.py`: Defines the registry interface
|
|
401
|
-
- `registry/providers/memory.py`: In-memory implementation
|
|
402
|
-
- `registry/providers/redis.py`: Redis-backed implementation
|
|
403
|
-
|
|
404
|
-
2. **Models**: Core data structures
|
|
405
|
-
- `models/tool_call.py`: Represents a tool call from an LLM
|
|
406
|
-
- `models/tool_result.py`: Represents the result of a tool execution
|
|
407
|
-
|
|
408
|
-
3. **Execution**: Tool execution strategies and wrappers
|
|
409
|
-
- `execution/tool_executor.py`: Main executor interface
|
|
410
|
-
- `execution/inprocess_strategy.py`: Same-process execution
|
|
411
|
-
- `execution/subprocess_strategy.py`: Isolated process execution
|
|
412
|
-
- `execution/wrappers/`: Enhanced executors (caching, retries, etc.)
|
|
413
|
-
|
|
414
|
-
4. **Plugins**: Extensible plugin system
|
|
415
|
-
- `plugins/discovery.py`: Plugin discovery mechanism
|
|
416
|
-
- `plugins/parsers/`: Parser plugins for different formats
|
|
417
|
-
|
|
418
|
-
5. **MCP Integration**: Model Context Protocol support
|
|
419
|
-
- `mcp/stream_manager.py`: Manages MCP server connections
|
|
420
|
-
- `mcp/transport/`: Transport implementations (stdio, SSE)
|
|
421
|
-
- `mcp/setup_mcp_*.py`: Easy setup functions for MCP integration
|
|
422
|
-
|
|
423
|
-
6. **Utils**: Shared utilities
|
|
424
|
-
- `utils/logging.py`: Structured logging system
|
|
425
|
-
- `utils/validation.py`: Argument and result validation
|
|
426
|
-
|
|
427
|
-
7. **Core**: Central components
|
|
428
|
-
- `core/processor.py`: Main processor for handling tool calls
|
|
429
|
-
- `core/exceptions.py`: Exception hierarchy
|
|
430
|
-
|
|
431
|
-
## Examples
|
|
432
|
-
|
|
433
|
-
The repository includes several example scripts:
|
|
434
|
-
|
|
435
|
-
- `examples/tool_registry_example.py`: Demonstrates tool registration and usage
|
|
436
|
-
- `examples/plugin_example.py`: Shows how to create and use custom plugins
|
|
437
|
-
- `examples/tool_calling_example_usage.py`: Basic example demonstrating tool execution
|
|
438
|
-
- `examples/mcp_stdio_example.py`: MCP stdio transport demonstration
|
|
439
|
-
- `examples/mcp_stdio_example_calling_usage.py`: Complete MCP integration example
|
|
440
|
-
|
|
441
|
-
Run examples with:
|
|
442
|
-
|
|
443
|
-
```bash
|
|
444
|
-
# Registry example
|
|
445
|
-
uv run examples/tool_registry_example.py
|
|
446
|
-
|
|
447
|
-
# Plugin example
|
|
448
|
-
uv run examples/plugin_example.py
|
|
449
|
-
|
|
450
|
-
# Tool execution example
|
|
451
|
-
uv run examples/tool_calling_example_usage.py
|
|
452
|
-
|
|
453
|
-
# MCP example
|
|
454
|
-
uv run examples/mcp_stdio_example.py
|
|
455
|
-
|
|
456
|
-
# Enable debug logging
|
|
457
|
-
LOGLEVEL=DEBUG uv run examples/tool_calling_example_usage.py
|
|
458
|
-
```
|
|
459
|
-
|
|
460
|
-
## License
|
|
461
|
-
|
|
462
|
-
This project is licensed under the MIT License - see the LICENSE file for details.
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
chuk_tool_processor/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
-
chuk_tool_processor/core/__init__.py,sha256=slM7pZna88tyZrF3KtN22ApYyCqGNt5Yscv-knsLOOA,38
|
|
3
|
-
chuk_tool_processor/core/exceptions.py,sha256=h4zL1jpCY1Ud1wT8xDeMxZ8GR8ttmkObcv36peUHJEA,1571
|
|
4
|
-
chuk_tool_processor/core/processor.py,sha256=fT3Qj8vmeUWoqOqHmWroi7lfJsMl52DpFQz8LT9UQME,10280
|
|
5
|
-
chuk_tool_processor/execution/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
6
|
-
chuk_tool_processor/execution/tool_executor.py,sha256=e1EHE-744uJuB1XeZZF_6VT25Yg1RCd8XI3v8uOrOSo,1794
|
|
7
|
-
chuk_tool_processor/execution/strategies/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
8
|
-
chuk_tool_processor/execution/strategies/inprocess_strategy.py,sha256=zybG8PzIf7VbDfQfMg2TJ67-zxbArt1eEjczRLzZfrQ,5957
|
|
9
|
-
chuk_tool_processor/execution/strategies/subprocess_strategy.py,sha256=Er8z7x94E7HmhFr9LtOvSBifL1eJ4l-12XampzkjBjU,3786
|
|
10
|
-
chuk_tool_processor/execution/wrappers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
11
|
-
chuk_tool_processor/execution/wrappers/caching.py,sha256=dA2OULPQ9xCZj-r3ev5LtsCDFDPgoz8tr70YCX5A4Wg,7714
|
|
12
|
-
chuk_tool_processor/execution/wrappers/rate_limiting.py,sha256=pFqD1vLzOtJzsWzpEI7J786gOAbdFY0gVeiO7ElBXbA,4991
|
|
13
|
-
chuk_tool_processor/execution/wrappers/retry.py,sha256=L3lebFWf_IL7DaAhTR541BVIxns7amm5msqYjJcQtnk,6387
|
|
14
|
-
chuk_tool_processor/logging/__init__.py,sha256=kow8qhzuCShXQSpQ4c6OZ0dEok18iMikcYLJTXEluoA,1124
|
|
15
|
-
chuk_tool_processor/logging/context.py,sha256=hQFWGeraHX3DM28JDSiIuhQqep6TBfo1uaLlRRlGMVU,1521
|
|
16
|
-
chuk_tool_processor/logging/formatter.py,sha256=4pO-fLULkD3JPLjZOSiOZPGsjV3c4Ztr5ySda1RAvi4,1754
|
|
17
|
-
chuk_tool_processor/logging/helpers.py,sha256=Fk32BuecWZdyrmv8U0lh4W0AdNx4-gKcCaWBdId_rlI,3569
|
|
18
|
-
chuk_tool_processor/logging/metrics.py,sha256=ti_owuslT-x9cjcbP-_j7jivrlyY-Vb41mVhU-6W-2M,1537
|
|
19
|
-
chuk_tool_processor/mcp/__init__.py,sha256=vR9HHxLpXlKTIIwJJRr3QTmZegcdedR1YKyb46j6FIM,689
|
|
20
|
-
chuk_tool_processor/mcp/mcp_tool.py,sha256=TvZEudgQvaev2jaPw6OGsqAR5GNu6_cPaUCgqiT5ogU,1504
|
|
21
|
-
chuk_tool_processor/mcp/register_mcp_tools.py,sha256=ofE7pEn6sKDH8HWvNamVOaXsitLOaG48M5GhcpqCBbs,2801
|
|
22
|
-
chuk_tool_processor/mcp/setup_mcp_sse.py,sha256=Ep2IKRdH1Y299bCxt9G0NtwnsvguYP6mpraZyUJ8OKU,2643
|
|
23
|
-
chuk_tool_processor/mcp/setup_mcp_stdio.py,sha256=NjTvAFqQHxxN3XubsTgYY3lTrvPVWlnwCzkzbz7WE_M,2747
|
|
24
|
-
chuk_tool_processor/mcp/stream_manager.py,sha256=mrmlG54P_xLbDYz_rBjdu-OPMnbi916dgyJg7BrIbjM,12798
|
|
25
|
-
chuk_tool_processor/mcp/transport/__init__.py,sha256=7QQqeSKVKv0N9GcyJuYF0R4FDZeooii5RjggvFFg5GY,296
|
|
26
|
-
chuk_tool_processor/mcp/transport/base_transport.py,sha256=1E29LjWw5vLQrPUDF_9TJt63P5dxAAN7n6E_KiZbGUY,3427
|
|
27
|
-
chuk_tool_processor/mcp/transport/sse_transport.py,sha256=bryH9DOWOn5qr6LsimTriukDC4ix2kuRq6bUv9qOV20,7645
|
|
28
|
-
chuk_tool_processor/mcp/transport/stdio_transport.py,sha256=lFXL7p8ca4z_J0RBL8UCHrQ1UH7C2-LbC0tZhpya4V4,7763
|
|
29
|
-
chuk_tool_processor/models/__init__.py,sha256=TC__rdVa0lQsmJHM_hbLDPRgToa_pQT_UxRcPZk6iVw,40
|
|
30
|
-
chuk_tool_processor/models/execution_strategy.py,sha256=ZPHysmKNHqJmahTtUXAbt1ke09vxy7EhZcsrwTdla8o,508
|
|
31
|
-
chuk_tool_processor/models/tool_call.py,sha256=RZOnx2YczkJN6ym2PLiI4CRzP2qU_5hpMtHxMcFOxY4,298
|
|
32
|
-
chuk_tool_processor/models/tool_export_mixin.py,sha256=U9NJvn9fqH3pW50ozdDAHlA0fQSnjUt-lYhEoW_leZU,998
|
|
33
|
-
chuk_tool_processor/models/tool_result.py,sha256=fqHuRC8bLek1PAwyhLOoKjRCLhpSm-mhDgLpsItjZ60,1532
|
|
34
|
-
chuk_tool_processor/models/validated_tool.py,sha256=REXLfKYNpdvm7hH4tYUZq1-TxiD0784iZUffrucGN_o,5714
|
|
35
|
-
chuk_tool_processor/plugins/__init__.py,sha256=QO_ipvlsWG-rbaqGzj6-YtD7zi7Lx26hw-Cqha4MuWc,48
|
|
36
|
-
chuk_tool_processor/plugins/discovery.py,sha256=pyUQk18c9mNoruoa2eY8T-FhkpomPllnWiyRDVCaJNM,5299
|
|
37
|
-
chuk_tool_processor/plugins/parsers/__init__.py,sha256=07waNfAGuytn-Dntx2IxjhgSkM9F40TBYNUXC8G4VVo,49
|
|
38
|
-
chuk_tool_processor/plugins/parsers/base.py,sha256=VwN1sT03L5Ar37koDgT9El0MRdIJCwwNJMbN76GKB5E,564
|
|
39
|
-
chuk_tool_processor/plugins/parsers/function_call_tool_plugin.py,sha256=rZt-fJ_dhVkRFR1OU86yZNq1R9AFvAiwjk6I3Hktc-A,2706
|
|
40
|
-
chuk_tool_processor/plugins/parsers/json_tool_plugin.py,sha256=wllYEqCzgxmCYdcugelWYFNHTjMYgDsghI-cbh8Qudk,1050
|
|
41
|
-
chuk_tool_processor/plugins/parsers/openai_tool_plugin.py,sha256=IyL6ZE03disNqkRYiyQZqJRV-vk99mLCZoKeLTwNYjQ,2347
|
|
42
|
-
chuk_tool_processor/plugins/parsers/xml_tool.py,sha256=rWdm25TwuT8S7l7GrYOvd-gFiVr6oss5ncjhQZGQxqA,1304
|
|
43
|
-
chuk_tool_processor/registry/__init__.py,sha256=kjNEM5dM7kEucfDjvgnww-QLrBrCzuDAuj9OBTizm5I,782
|
|
44
|
-
chuk_tool_processor/registry/auto_register.py,sha256=moHYkfWsSUOs7uu7MbZj2v-ujUHPbGD4nXsQZ5Dk1hM,5119
|
|
45
|
-
chuk_tool_processor/registry/decorators.py,sha256=WecmzWK2RliMO0xmWEifj7xBqACoGfm2rz1hxcgtkrI,1346
|
|
46
|
-
chuk_tool_processor/registry/interface.py,sha256=40KFbMKzjnwf6iki9aeWBx5c3Dq3Tadr78y-Ko-IYsM,2299
|
|
47
|
-
chuk_tool_processor/registry/metadata.py,sha256=zoSv8QnncqMtvEo7nj_pGKKQohw6maBVDiInXBoNaxY,1744
|
|
48
|
-
chuk_tool_processor/registry/provider.py,sha256=EG1K28nfRddq18UDrymKse_bMt3PAhLcQ3TRaG89Tq8,3869
|
|
49
|
-
chuk_tool_processor/registry/tool_export.py,sha256=msGOszF9NtJEb4u0XhA0tz6EwkL3Uv_R7QAz0p2eJM8,2543
|
|
50
|
-
chuk_tool_processor/registry/providers/__init__.py,sha256=_0dg4YhyfAV0TXuR_i4ewXPU8fY7odFd1RJWCmHIXmk,1326
|
|
51
|
-
chuk_tool_processor/registry/providers/memory.py,sha256=29aI5uvykjDmn9ymIukEdUtmTC9SXOAsDu9hw36XF44,4474
|
|
52
|
-
chuk_tool_processor/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
53
|
-
chuk_tool_processor/utils/validation.py,sha256=7ezn_o-3IHDrzOD3j6ttsAn2s3zS-jIjeBTuqicrs6A,3775
|
|
54
|
-
chuk_tool_processor-0.1.6.dist-info/METADATA,sha256=XsvUbxDUKZHtefun8o-xsg6HvAm5hxqrEhkTFrhkjLI,13703
|
|
55
|
-
chuk_tool_processor-0.1.6.dist-info/WHEEL,sha256=0CuiUZ_p9E4cD6NyLD6UG80LBXYyiSYZOKDm5lp32xk,91
|
|
56
|
-
chuk_tool_processor-0.1.6.dist-info/top_level.txt,sha256=7lTsnuRx4cOW4U2sNJWNxl4ZTt_J1ndkjTbj3pHPY5M,20
|
|
57
|
-
chuk_tool_processor-0.1.6.dist-info/RECORD,,
|
|
File without changes
|