Installation
Install the ATP SDK using pip:
pip install AgentToolProtocol
The ToolKitClient lets you register Python functions as tools and serve them via WebSocket.
from atp_sdk.clients import ToolKitClient
# Initialize the client
client = ToolKitClient(
api_key="YOUR_ATP_TOOLKIT_API_KEY",
app_name="my_app"
)
Use the @register_tool decorator to expose a Python function as a tool:
@client.register_tool(
function_name="hello_world",
params=['name'],
required_params=['name'],
description="Returns a greeting.",
auth_provider=None,
auth_type=None,
auth_with=None
)
def hello_world(**kwargs):
name = kwargs.get('name', 'World')
return {"message": f"Hello, {name}!"}
Step 3: Start the Client
Start the WebSocket client to begin listening for tool requests:
The client will automatically reconnect if the connection is lost.
Complete Example
Here’s a complete example that registers a simple tool:
from atp_sdk.clients import ToolKitClient
# Initialize the client
client = ToolKitClient(
api_key="YOUR_ATP_TOOLKIT_API_KEY",
app_name="my_app"
)
# Register a tool
@client.register_tool(
function_name="hello_world",
params=['name'],
required_params=['name'],
description="Returns a greeting.",
auth_provider=None,
auth_type=None,
auth_with=None
)
def hello_world(**kwargs):
name = kwargs.get('name', 'World')
return {"message": f"Hello, {name}!"}
# Start the client
client.start()
Here’s an example of a tool that requires OAuth2 authentication (e.g., HubSpot):
import requests
@client.register_tool(
function_name="get_contacts",
params=[],
required_params=[],
description="Fetches contacts from HubSpot.",
auth_provider="hubspot",
auth_type="OAuth2",
auth_with="access_token"
)
def get_contacts(**kwargs):
access_token = kwargs.get('auth_token')
url = "https://api.hubapi.com/crm/v3/objects/contacts"
headers = {"Authorization": f"Bearer {access_token}"}
response = requests.get(url, headers=headers)
return response.json()
The ATP platform will automatically inject the auth_token into your function when a user has authenticated.
Next Steps
ToolKitClient Reference
Learn about all ToolKitClient methods and options
LLMClient Integration
Connect LLMs to your toolkits
OAuth2 Guide
Set up OAuth2 authentication for your tools
Examples
Explore more examples and use cases