fastmcp/docs/python-sdk/fastmcp-server-providers-addressing.mdx
marvin-context-protocol[bot] 56456cb188
chore: Update SDK documentation (#3808)
Co-authored-by: marvin-context-protocol[bot] <225465937+marvin-context-protocol[bot]@users.noreply.github.com>
2026-04-12 13:53:38 -04:00

81 lines
2.8 KiB
Text

---
title: addressing
sidebarTitle: addressing
---
# `fastmcp.server.providers.addressing`
Deterministic tool hashing for backend-tool routing and per-tool resources.
Each FastMCPApp backend tool gets a deterministic hash computed from its
app name + tool name. The hash serves two purposes:
1. **Backend-tool routing.** Tools with ``"app"`` in their visibility are
callable via ``<hash>_<local_name>``. The dispatcher parses the prefix,
then walks providers recursively (same pattern as the old ``get_app_tool``)
to find a tool whose stored hash matches.
2. **Per-tool Prefab renderer URIs.** Each prefab tool gets a unique renderer
resource at ``ui://prefab/tool/<hash>/renderer.html``. ``list_resources``
and ``read_resource`` synthesize these on demand from the tool's meta.
The hash is computed at registration time from ``(app_name, tool_name)`` —
both known at that moment — and stored in ``meta["fastmcp"]["_tool_hash"]``.
Deterministic across replicas (same code → same hash), no registry walk
needed.
## Functions
### `hash_tool` <sup><a href="https://github.com/PrefectHQ/fastmcp/blob/main/src/fastmcp/server/providers/addressing.py#L29" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
```python
hash_tool(app_name: str, tool_name: str) -> str
```
Deterministic hex hash for a tool in an app.
Same inputs on every replica produce the same output.
### `hashed_backend_name` <sup><a href="https://github.com/PrefectHQ/fastmcp/blob/main/src/fastmcp/server/providers/addressing.py#L38" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
```python
hashed_backend_name(app_name: str, tool_name: str) -> str
```
Format the universal name for a backend tool: ``<hash>_<local_name>``.
### `parse_hashed_backend_name` <sup><a href="https://github.com/PrefectHQ/fastmcp/blob/main/src/fastmcp/server/providers/addressing.py#L43" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
```python
parse_hashed_backend_name(name: str) -> tuple[str, str] | None
```
Parse ``<HASH_LENGTH hex>_<rest>`` → ``(hash, local_tool_name)`` or None.
### `hashed_resource_uri` <sup><a href="https://github.com/PrefectHQ/fastmcp/blob/main/src/fastmcp/server/providers/addressing.py#L55" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
```python
hashed_resource_uri(app_name: str, tool_name: str) -> str
```
Per-tool Prefab renderer resource URI.
### `parse_hashed_resource_uri` <sup><a href="https://github.com/PrefectHQ/fastmcp/blob/main/src/fastmcp/server/providers/addressing.py#L60" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
```python
parse_hashed_resource_uri(uri: str) -> str | None
```
Extract the hash from a Prefab renderer URI, or None.