Overview
TheToolKitClient class allows you to register Python functions as tools and serve them via WebSocket. It handles:
- Tool registration with metadata
- WebSocket(WS(S))/Hyper Text Transfer Protocol(HTTP(S)) connection to the ATP server
- Tool invocation with parameter validation
- OAuth2 token injection for authenticated tools
- Automatic reconnection on connection loss
Constructor
Parameters
Your ATP Toolkit API key. Get it from the ATP Dashboard.
Name of your application/toolkit. This will be used to identify your toolkit on the ATP platform.
ATP Server backend URL. Use the default unless you’re running a custom ATP server.
Methods
register_tool
Registers a Python function as a tool with the ATP platform.Parameters
Unique name for the tool. This is how the LLM will reference the tool.
List of all parameter names the tool accepts.
List of required parameter names. The tool will fail if these are not provided.
Human-readable description of what the tool does. This helps the LLM understand when to use the tool.
Name of OAuth2 provider (e.g., “hubspot”, “google”, “salesforce”). Set to
None if no authentication is required.Authentication type (e.g., “OAuth2”, “apiKey”). Set to
None if no authentication is required.Name of the token parameter (e.g., “access_token”, “api_key”). Set to
None if no authentication is required.Returns
A decorator to wrap your function.start
Starts the WebSocket client and begins listening for tool requests.stop
Stops the WebSocket client and closes the connection.Tool Function Requirements
Your tool functions must follow these requirements:- Accept
**kwargs: All parameters must be passed as keyword arguments. - Return serializable data: Return a dict, str, list, or other JSON-serializable type.
- Handle
auth_token: If your tool requires authentication, expectauth_tokeninkwargs.
Example Tool Function
Examples
Minimal Tool (No Authentication)
Tool with OAuth2 Authentication
Multiple Tools
You can register multiple tools with the same client:Error Handling
The ATP SDK automatically handles errors and returns them in a standardized format:Missing Required Parameters
Missing Auth Token
Function Exception
WebSocket Events
Tool Registration
When you callclient.start(), all registered tools are announced to the ATP backend.
Tool Invocation
When a tool request is received, your function is called with the provided parameters and (if needed)auth_token.
Example incoming message:
Advanced Usage
Custom Backend
If you’re running a custom ATP server, you can specify the base URL:Next Steps
LLMClient
Connect LLMs to your toolkits
OAuth2 Guide
Set up OAuth2 authentication
Framework Integration
Use ATP with Django, FastAPI, or Flask
Examples
Explore more examples