Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion stackone_ai/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ class ExecuteConfig(BaseModel):
parameter_locations: dict[str, ParameterLocation] = Field(
default_factory=dict, description="Maps parameter names to their location in the request"
)
timeout: float = Field(default=30.0, description="HTTP request timeout in seconds")


class ToolParameters(BaseModel):
Expand Down Expand Up @@ -249,7 +250,7 @@ def execute(
if query_params:
request_kwargs["params"] = query_params

response = httpx.request(**request_kwargs)
response = httpx.request(**request_kwargs, timeout=self._execute_config.timeout)
response_status = response.status_code
response.raise_for_status()

Expand Down
9 changes: 9 additions & 0 deletions stackone_ai/toolset.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ class ExecuteToolsConfig(TypedDict, total=False):
account_ids: list[str]
"""Account IDs to scope tool discovery and execution."""

timeout: float
"""HTTP request timeout in seconds for tool execution. Defaults to 30."""


_SEARCH_DEFAULT: SearchConfig = {"method": "auto"}

Expand Down Expand Up @@ -415,6 +418,7 @@ def __init__(
api_key: str,
base_url: str,
account_id: str | None,
timeout: float = 30.0,
) -> None:
execute_config = ExecuteConfig(
method="POST",
Expand All @@ -423,6 +427,7 @@ def __init__(
headers={},
body_type="json",
parameter_locations=dict(_RPC_PARAMETER_LOCATIONS),
timeout=timeout,
)
super().__init__(
description=description,
Expand Down Expand Up @@ -1185,13 +1190,17 @@ def _create_rpc_tool(self, tool_def: _McpToolDefinition, account_id: str | None)
type=str(schema.get("type") or "object"),
properties=self._normalize_schema_properties(schema),
)
timeout = (
self._execute_config.get("timeout", 30.0) if self._execute_config else 30.0
)
return _StackOneRpcTool(
name=tool_def.name,
description=tool_def.description or "",
parameters=parameters,
api_key=self.api_key,
base_url=self.base_url,
account_id=account_id,
timeout=timeout,
)

def _normalize_schema_properties(self, schema: dict[str, Any]) -> dict[str, Any]:
Expand Down
Loading