# tinker_cookbook.tool_use.tools.tool ### [**tinker_cookbook.tool_use.tools.tool**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/tool_use/tools.py#L280)(*fn*) Decorator to create a tool from a function or method. The decorated function must return a ToolResult. Use simple_tool_result() helper for basic cases, or construct ToolResult directly for metrics/metadata. **Usage:** @tool async def search(query: Annotated[str, "The search query"]) -> ToolResult: '''Search for information.''' results = await do_search(query) return simple_tool_result( json.dumps({"results": results}), metrics={"result_count": len(results)} ) # As class method with shared state: **class MySharedStateTools:** **def **init**(self, api_key: str):** self.api_key = api_key @tool async def search(self, query: Annotated[str, "Query"]) -> ToolResult: '''Search for information.''' results = await do_search(query, api_key=self.api_key) return simple_tool_result(json.dumps(results)) **Parameters:** - [**fn**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/tool_use/tools.py#L280) (*Callable[..., Any]*) **Returns:** *[FunctionTool](https://tinker-docs.thinkingmachines.ai/cookbook/api-reference/tool_use/functiontool/index.md)*