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

# function_tool

# `fastmcp.tools.function_tool`

Standalone @tool decorator for FastMCP.

## Functions

### `tool` <sup>[https://github.com/PrefectHQ/fastmcp/blob/main/fastmcp\_slim/fastmcp/tools/function\_tool.py#L592](https://github.com/PrefectHQ/fastmcp/blob/main/fastmcp_slim/fastmcp/tools/function_tool.py#L592)</sup>

```python theme={"theme":{"light":"snazzy-light","dark":"dark-plus"}}
tool(name_or_fn: str | Callable[..., Any] | None = None) -> Any
```

Standalone decorator to mark a function as an MCP tool.

Returns the original function with metadata attached. Register with a server
using mcp.add\_tool().

**Args:**

* `run_in_thread`: Applies to sync tool functions only. When True (default),
  the sync function is dispatched to a worker thread so it does not
  block the event loop. Set to False to run the function inline on the
  event loop thread — useful for libraries with thread affinity
  (e.g. Windows COM via `uiautomation`/`comtypes`/`pywin32`, `tkinter`,
  some GPU/driver bindings). Ignored for async functions. Cannot be
  combined with `timeout` on a sync function: inline calls have no
  cancellation checkpoints, so the timeout would be a silent no-op.

## Classes

### `DecoratedTool` <sup>[https://github.com/PrefectHQ/fastmcp/blob/main/fastmcp\_slim/fastmcp/tools/function\_tool.py#L187](https://github.com/PrefectHQ/fastmcp/blob/main/fastmcp_slim/fastmcp/tools/function_tool.py#L187)</sup>

Protocol for functions decorated with @tool.

### `ToolMeta` <sup>[https://github.com/PrefectHQ/fastmcp/blob/main/fastmcp\_slim/fastmcp/tools/function\_tool.py#L196](https://github.com/PrefectHQ/fastmcp/blob/main/fastmcp_slim/fastmcp/tools/function_tool.py#L196)</sup>

Metadata attached to functions by the @tool decorator.

### `FunctionTool` <sup>[https://github.com/PrefectHQ/fastmcp/blob/main/fastmcp\_slim/fastmcp/tools/function\_tool.py#L242](https://github.com/PrefectHQ/fastmcp/blob/main/fastmcp_slim/fastmcp/tools/function_tool.py#L242)</sup>

**Methods:**

#### `from_function` <sup>[https://github.com/PrefectHQ/fastmcp/blob/main/fastmcp\_slim/fastmcp/tools/function\_tool.py#L261](https://github.com/PrefectHQ/fastmcp/blob/main/fastmcp_slim/fastmcp/tools/function_tool.py#L261)</sup>

```python theme={"theme":{"light":"snazzy-light","dark":"dark-plus"}}
from_function(cls, fn: Callable[..., Any]) -> FunctionTool
```

Create a FunctionTool from a function.

**Args:**

* `fn`: The function to wrap
* `metadata`: ToolMeta object with all configuration. If provided,
  individual parameters must not be passed.
* `name, title, etc.`: Individual parameters for backwards compatibility.
  Cannot be used together with metadata parameter.

#### `run` <sup>[https://github.com/PrefectHQ/fastmcp/blob/main/fastmcp\_slim/fastmcp/tools/function\_tool.py#L411](https://github.com/PrefectHQ/fastmcp/blob/main/fastmcp_slim/fastmcp/tools/function_tool.py#L411)</sup>

```python theme={"theme":{"light":"snazzy-light","dark":"dark-plus"}}
run(self, arguments: dict[str, Any]) -> ToolResult
```

Run the tool with arguments.

A tool body may return an `InputRequiredResult` (SEP-2322) to ask the
client for input. Under the stateless multi-round-trip protocol that ask
is the full result of this leg, so it is wrapped in an
`InputRequiredToolResult` (a `ToolResult` subclass) rather than
serialized as content; the ask flows through the middleware chain as an
ordinary result and the wire handler returns it to the client unmodified.


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