Skip to content

API Reference

Auto-generated from Google-style docstrings. For HTTP endpoints, see LIME platform documentation.

LimeAgent

lime_agents.LimeAgent

Async client for LIME agent workers.

Wraps site-login approve (PoW + X-Agent-Token) and MCP OAuth client calls to external resource servers. MCP JWTs are issued and cached automatically on list_tools / call_tool — use get_mcp_access_token() only when you need the raw JWT string.

See LIME platform docs <https://lime.pics/docs#guide-agentSdk>_ for HTTP details.

__init__

__init__(*, agent_token=None, base_url=None, timeout=30.0, max_retries=3, pow_timeout=10.0, mcp_token_refresh_skew=30.0, mcp_read_timeout=300.0, serialize_mcp_per_url=True, http_client=None)

Create an agent client.

Parameters:

Name Type Description Default
agent_token str | None

Opaque agent secret (default from LIME_AGENT_TOKEN env).

None
base_url str | None

API root including /api/v1 (default LIME_API_BASE).

None
timeout float

HTTP timeout seconds for LIME platform calls.

30.0
max_retries int

Retries on transient 408/429/5xx responses.

3
pow_timeout float

Max seconds to solve PoW before PowTimeoutError.

10.0
mcp_token_refresh_skew float

Refresh MCP JWT this many seconds before expiry.

30.0
mcp_read_timeout float

MCP streamable HTTP read timeout seconds.

300.0
serialize_mcp_per_url bool

Serialize MCP calls per server URL when True.

True
http_client AsyncClient | None

Injectable httpx.AsyncClient for tests.

None

Raises:

Type Description
AuthenticationError

When no agent token is configured.

login async

login(request_id)

Complete site-login approve for one request_id.

Fetches PoW challenge, solves it, and posts approve with X-Agent-Token. The site backend receives the passport JWT separately via SSE.

Parameters:

Name Type Description Default
request_id str

Login request id from the site backend (login_request_id).

required

Returns:

Type Description
ApprovalResult

ApprovalResult with status and optional approved_agent_id.

Raises:

Type Description
ApiError

Invalid request id or approve rejected by API.

PowTimeoutError

PoW not solved within pow_timeout.

get_profile async

get_profile()

Return the authenticated agent's Core profile.

get_mcp_access_token async

get_mcp_access_token(*, force_refresh=False)

Return a cached MCP OAuth JWT (optional — MCP facade methods auto-issue).

Parameters:

Name Type Description Default
force_refresh bool

When True, bypass cache and request a new token.

False

Returns:

Type Description
McpAccessToken

McpAccessToken with access_token, expires_in, and issued_at.

Note

Prefer list_tools / call_tool for normal MCP usage. This method is for integrators who need the raw JWT (custom HTTP clients, debugging).

list_tools async

list_tools(server_url)

List tools on an external MCP resource server.

OAuth JWT is fetched and attached automatically on first call.

Parameters:

Name Type Description Default
server_url str

Full streamable HTTP MCP endpoint (e.g. https://host/mcp).

required

Returns:

Type Description
list[Tool]

List of Tool models (not a wrapper with .tools attribute).

call_tool async

call_tool(server_url, name, arguments=None)

Invoke a tool on an external MCP resource server.

Parameters:

Name Type Description Default
server_url str

Full streamable HTTP MCP endpoint.

required
name str

Tool name from list_tools.

required
arguments dict[str, Any] | None

JSON-serializable tool arguments.

None

Returns:

Type Description
CallToolResult

CallToolResult from the MCP protocol.

list_resources async

list_resources(server_url)

List resources exposed by an external MCP server.

read_resource async

read_resource(server_url, uri)

Read a resource URI from an external MCP server.

list_prompts async

list_prompts(server_url)

List prompts on an external MCP server.

get_prompt async

get_prompt(server_url, name, arguments=None)

Fetch a prompt template from an external MCP server.

mcp_session async

mcp_session(server_url)

Hold an MCP session lock for advanced low-level calls on one server URL.

aclose async

aclose()

Result types

Outcome of LimeAgent.login() approve step.

from_api classmethod

from_api(data)

Parse approve response envelope data object.

Authenticated agent profile from Core API.

from_api classmethod

from_api(data)

Parse profile JSON; accepts wire user_id / user_kyc_level aliases.

Short-lived MCP OAuth JWT and metadata from get_mcp_access_token().

Errors

Bases: Exception

Base class for SDK errors.

Bases: LimeError

Missing or invalid agent token.

Bases: LimeError

PoW was not solved within the allotted time.

Bases: LimeError

HTTP 429 — rate limit exceeded.

Bases: LimeError

General API error with code and message.

Bases: LimeError

MCP resource server rejected the access token.

Bases: ApiError

Agent authenticated but lacks oauth:issue capability.