Camel.toolkits.klavis toolkit
KlavisToolkit
A class representing a toolkit for interacting with Klavis API.
This class provides methods for interacting with Klavis MCP server instances, retrieving server information, managing tools, and handling authentication.
Attributes:
api_key (str): The API key for authenticating with Klavis API.
base_url (str): The base URL for Klavis API endpoints.
timeout (Optional[float]): The timeout value for API requests
in seconds. If None, no timeout is applied.
(default: :obj:None
)
init
Initialize the KlavisToolkit with API client. The API key is retrieved from environment variables.
_request
Make an HTTP request to the Klavis API.
Parameters:
- method (str): HTTP method (e.g., ‘GET’, ‘POST’, ‘DELETE’).
- endpoint (str): API endpoint path.
- payload (Optional[Dict[str, Any]]): JSON payload for POST requests.
- additional_headers (Optional[Dict[str, str]]): Additional headers to include in the request.
Returns:
Dict[str, Any]: The JSON response from the API or an error dict.
create_server_instance
Create a Server-Sent Events (SSE) URL for a specified MCP server.
Parameters:
- server_name (str): The name of the target MCP server.
- user_id (str): The ID for the user requesting the server URL.
- platform_name (str): The name of the platform associated with the user.
Returns:
Dict[str, Any]: Response containing the server instance details.
get_server_instance
Get details of a specific server connection instance.
Parameters:
- instance_id (str): The ID of the connection instance whose status is being checked.
Returns:
Dict[str, Any]: Details about the server instance.
delete_auth_data
Delete authentication metadata for a specific server connection instance.
Parameters:
- instance_id (str): The ID of the connection instance to delete auth for.
Returns:
Dict[str, Any]: Status response for the operation.
delete_server_instance
Completely removes a server connection instance.
Parameters:
- instance_id (str): The ID of the connection instance to delete.
Returns:
Dict[str, Any]: Status response for the operation.
get_all_servers
Returns:
Dict[str, Any]: Information about all available MCP servers.
set_auth_token
Sets an authentication token for a specific instance.
Parameters:
- instance_id (str): The ID for the connection instance.
- auth_token (str): The authentication token to save.
Returns:
Dict[str, Any]: Status response for the operation.
list_tools
Lists all tools available for a specific remote MCP server.
Parameters:
- server_url (str): The full URL for connecting to the MCP server via Server-Sent Events (SSE).
Returns:
Dict[str, Any]: Response containing the list of tools or an error.
call_tool
Calls a remote MCP server tool directly using the provided server URL.
Parameters:
- server_url (str): The full URL for connecting to the MCP server via Server-Sent Events (SSE).
- tool_name (str): The name of the tool to call.
- tool_args (Optional[Dict[str, Any]]): The input parameters for the tool. Defaults to None, which might be treated as empty args by the server. (default: :obj:
None
)
Returns:
Dict[str, Any]: Response containing the result of the tool call or an error.
get_tools
Returns:
List[FunctionTool]: A list of FunctionTool objects representing the functions in the toolkit.