Python SDK reference
Complete API reference for the Scalekit Python SDK: actions client, MCP server provisioning, framework adapters, tools client, and modifiers.
scalekit_client.actions is the primary interface for AgentKit. It handles connected account management, MCP server provisioning, tool execution, and framework integrations.
Install and initialize
Section titled “Install and initialize”pip install scalekit-sdk-pythonimport osfrom scalekit import ScalekitClient
scalekit_client = ScalekitClient( env_url=os.environ["SCALEKIT_ENV_URL"], client_id=os.environ["SCALEKIT_CLIENT_ID"], client_secret=os.environ["SCALEKIT_CLIENT_SECRET"],)
actions = scalekit_client.actionsActions client
Section titled “Actions client”Authentication
Section titled “Authentication”get_authorization_link
Section titled “get_authorization_link”Generates a time-limited OAuth magic link to authorize a user’s connection.
magic_link = actions.get_authorization_link( identifier="user@example.com", connection_name="gmail", user_verify_url="https://your-app.com/verify",)# Redirect the user to magic_link.linkverify_connected_account_user
Section titled “verify_connected_account_user”Verifies the user after OAuth callback. Call this from your redirect URL handler.
result = actions.verify_connected_account_user( auth_request_id=request.args["auth_request_id"], identifier="user@example.com",)# Redirect to result.post_user_verify_redirect_urlConnected accounts
Section titled “Connected accounts”get_or_create_connected_account
Section titled “get_or_create_connected_account”Fetches an existing connected account or creates one if none exists. Use this as the default when setting up a user.
account = actions.get_or_create_connected_account( connection_name="gmail", identifier="user@example.com",)print(account.connected_account.id)get_connected_account
Section titled “get_connected_account”Fetches auth details for a connected account. Returns sensitive credentials. Protect access to this method.
Use this when you know the connected account already exists and you need its credential payload. For first-time setup or general application flows, prefer get_or_create_connected_account so new users do not hit a not-found error.
Requires connected_account_id or connection_name + identifier.
list_connected_accounts
Section titled “list_connected_accounts”create_connected_account
Section titled “create_connected_account”Creates a connected account with explicit auth details.
Returns CreateConnectedAccountResponse. Same shape as get_or_create_connected_account.
update_connected_account
Section titled “update_connected_account”Requires connected_account_id or connection_name + identifier.
Returns UpdateConnectedAccountResponse.
delete_connected_account
Section titled “delete_connected_account”Deletes a connected account and revokes its credentials. Requires connected_account_id or connection_name + identifier.
Returns DeleteConnectedAccountResponse.
Tool execution
Section titled “Tool execution”execute_tool
Section titled “execute_tool”Executes a named tool via Scalekit. Pre- and post-modifiers run automatically if registered.
result = actions.execute_tool( tool_name="gmail_fetch_emails", tool_input={"max_results": 5, "label": "UNREAD"}, identifier="user@example.com",)emails = result.dataProxied API calls
Section titled “Proxied API calls”request
Section titled “request”Makes a REST API call on behalf of a connected account. Scalekit injects the user’s OAuth token automatically.
Returns requests.Response. Use .json(), .status_code, and standard response attributes.
response = actions.request( connection_name="gmail", identifier="user@example.com", path="/gmail/v1/users/me/messages", query_params={"maxResults": 5, "q": "is:unread"},)messages = response.json()["messages"]MCP server provisioning
Section titled “MCP server provisioning”actions.mcp manages Virtual MCP Servers. Any MCP-compatible agent framework (LangChain, Google ADK, Anthropic, OpenAI, and others) can connect to these servers directly.
Two-step model: Create a config once (defines which connectors and tools to expose) to get a static Virtual MCP Server URL. Before each agent run, mint a short-lived session token to authenticate the user.
Configs
Section titled “Configs”actions.mcp.create_config
Section titled “actions.mcp.create_config”from scalekit.actions.models.mcp_config import McpConfigConnectionToolMapping
config = actions.mcp.create_config( name="email-agent", connection_tool_mappings=[ McpConfigConnectionToolMapping( connection_name="gmail", tools=["gmail_fetch_emails", "gmail_send_email"], ) ],)actions.mcp.list_configs
Section titled “actions.mcp.list_configs”Returns ListMcpConfigsResponse.
actions.mcp.update_config
Section titled “actions.mcp.update_config”Returns UpdateMcpConfigResponse.
actions.mcp.delete_config
Section titled “actions.mcp.delete_config”Returns DeleteMcpConfigResponse.
Session tokens
Section titled “Session tokens”actions.mcp.list_mcp_connected_accounts
Section titled “actions.mcp.list_mcp_connected_accounts”Returns the connection status for each connector configured in a Virtual MCP Server, for a specific user. Call this before minting a session token to verify all connections are ACTIVE.
accounts_response = scalekit_client.actions.mcp.list_mcp_connected_accounts( config_id=mcp_id, identifier="user@example.com",)for account in accounts_response.connected_accounts: if account.connected_account_status != "ACTIVE": print(f"{account.connection_name} is not active — prompt user to authorize")actions.mcp.create_session_token
Section titled “actions.mcp.create_session_token”Mints a short-lived session token scoped to a user and a Virtual MCP Server config. Pass the token as a bearer auth header when connecting to the MCP server. Mint a fresh token before each agent run.
from datetime import timedelta
token_response = scalekit_client.actions.mcp.create_session_token( mcp_config_id=mcp_id, identifier="user@example.com", expiry=timedelta(hours=1),)token = token_response.token# Pass as: {"Authorization": f"Bearer {token}"}Framework adapters
Section titled “Framework adapters”Pre-built integrations for LangChain and Google ADK. Use these when your agent runs in one of these frameworks and you prefer native tool objects over an MCP URL.
LangChain
Section titled “LangChain”pip install langchainactions.langchain.get_tools
Section titled “actions.langchain.get_tools”from langchain.agents import create_react_agent
tools = actions.langchain.get_tools( identifier="user@example.com", page_size=100, # avoid missing tools when a connector has more than the default page)agent = create_react_agent(llm=llm, tools=tools, prompt=prompt)Google ADK
Section titled “Google ADK”pip install google-adkactions.google.get_tools
Section titled “actions.google.get_tools”Same parameters as actions.langchain.get_tools.
Returns List[ScalekitGoogleAdkTool]. Pass it directly to a Google ADK agent.
tools = actions.google.get_tools( identifier="user@example.com", page_size=100, # avoid missing tools when a connector has more than the default page)Tools client
Section titled “Tools client”scalekit_client.actions.tools gives access to raw tool schemas. Use this when building a custom adapter or passing schemas directly to an LLM API (e.g. Anthropic, OpenAI).
actions.tools.list_tools
Section titled “actions.tools.list_tools”actions.tools.list_scoped_tools
Section titled “actions.tools.list_scoped_tools”Lists tools scoped to a specific user. Use this method for tool discovery because it returns pagination metadata such as next_page_token and total_size; framework get_tools() helpers return framework-ready tool objects and do not expose that metadata.
tools_response = scalekit_client.actions.tools.list_scoped_tools( identifier="user@example.com", page_size=100,)# Pass tools_response.tools to your LLM's tool call APIactions.tools.execute_tool
Section titled “actions.tools.execute_tool”Low-level tool execution. Bypasses modifiers. Prefer actions.execute_tool in most cases.
Returns ExecuteToolResponse. Same shape as actions.execute_tool.
Modifiers
Section titled “Modifiers”Modifiers intercept tool calls to transform inputs or outputs, useful for validation, enrichment, or logging.
@actions.pre_modifier(tool_names=["gmail_fetch_emails"])def add_default_label(tool_input): tool_input.setdefault("label", "UNREAD") return tool_input
@actions.post_modifier(tool_names=["gmail_fetch_emails"])def filter_attachments(tool_output): tool_output["emails"] = [e for e in tool_output["emails"] if not e.get("has_attachment")] return tool_output| Decorator | Receives | Returns |
|---|---|---|
@actions.pre_modifier(tool_names) | dict | Modified dict |
@actions.post_modifier(tool_names) | dict | Modified dict |
tool_names accepts a string or a list of strings. Multiple modifiers for the same tool chain in registration order.
Error handling
Section titled “Error handling”from scalekit.common.exceptions import ScalekitNotFoundException, ScalekitServerException
try: account = actions.get_connected_account( connection_name="gmail", identifier="user@example.com", )except ScalekitNotFoundException: # Account does not exist: create it or redirect to auth passexcept ScalekitServerException as e: print(e.error_code, e.http_status)| Exception | When raised |
|---|---|
ScalekitNotFoundException | Resource not found |
ScalekitUnauthorizedException | Invalid credentials |
ScalekitForbiddenException | Insufficient permissions |
ScalekitServerException | Base class for all server errors |