> ## Documentation Index
> Fetch the complete documentation index at: https://praison.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# tool • AI Agent SDK

> tool: Decorator to convert a function into a tool.

# tool

Function

> This function is defined in the [**decorator**](https://praison.ai/docs/sdk/reference/praisonaiagents/modules/decorator.md) module.

Decorator to convert a function into a tool.

Can be used with or without arguments:

@tool
def my\_func(x: str) -> str:
'''Does something.'''
return x

@tool(name="custom\_name", description="Custom description")
def my\_func(x: str) -> str:
return x

@tool(availability=lambda: (bool(os.getenv("API\_KEY")), "API\_KEY missing"))
def my\_func(x: str) -> str:
return x

@tool(retry\_policy=RetryPolicy(max\_attempts=5))
def my\_func(x: str) -> str:
return x

@tool(approval=True)
def delete\_account(user\_id: str) -> str:
return "deleted"

@tool(approval="critical")
def deploy(env: str) -> str:
return "deployed"

@tool(input\_guardrails=\[internal\_only], output\_guardrails=\[no\_secrets])
def send\_email(to: str, body: str) -> str:
return "sent"

```mermaid theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
%%{init: {'theme': 'base', 'themeVariables': { 'primaryColor': '#8B0000', 'primaryTextColor': '#fff', 'primaryBorderColor': '#710101', 'lineColor': '#189AB4', 'secondaryColor': '#189AB4', 'tertiaryColor': '#fff' }}}%%

graph LR
    agent["Agent"] -- "uses" --> tool["Tool: tool"]
    tool -- "returns" --> result["Result"]
    style tool fill:#189AB4,color:#fff
    style agent fill:#8B0000,color:#fff
    style result fill:#8B0000,color:#fff
```

## Signature

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
def tool(func: Optional[Callable]) -> Union[FunctionTool, Callable[[Callable], FunctionTool]]
```

## Parameters

**func** `Optional[Callable]`

The function to wrap (when used without parentheses)

### Returns

**Returns** `Union[FunctionTool, Callable[[Callable], FunctionTool]]`

FunctionTool instance that wraps the function

## Uses

* `FunctionTool`
* `add_approval_requirement`
* `RuntimeError`
* `tool_instance.validate`
* `tool_instance.validate_schema_roundtrip`
* `logging.warning`
* `logging.debug`
* `get_registry`
* `registry.register`
* `decorator`

## Source

> [card] [View on GitHub](https://github.com/MervinPraison/PraisonAI/blob/main/src/praisonai-agents/praisonaiagents/tools/decorator.py#L257)
>
> `praisonaiagents/tools/decorator.py` at line 257

***

## Related Documentation

> [card] [Tools Concept](https://praison.ai/docs/docs/concepts/tools)

> [card] [Create Custom Tools](https://praison.ai/docs/docs/guides/tools/create-custom-tools)

> [card] [Tool Development](https://praison.ai/docs/docs/tutorials/advanced-tool-development)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.