fastmcp/docs/python-sdk/fastmcp-server-transforms-namespace.mdx
marvin-context-protocol[bot] 1700bc360b
chore: Update SDK documentation (#2834)
Co-authored-by: marvin-context-protocol[bot] <225465937+marvin-context-protocol[bot]@users.noreply.github.com>
2026-01-16 21:28:11 -05:00

96 lines
3.3 KiB
Text

---
title: namespace
sidebarTitle: namespace
---
# `fastmcp.server.transforms.namespace`
Namespace transform for prefixing component names.
## Classes
### `Namespace` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/transforms/namespace.py#L32" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
Prefixes component names with a namespace.
- Tools: name → namespace_name
- Prompts: name → namespace_name
- Resources: protocol://path → protocol://namespace/path
- Resource Templates: same as resources
**Methods:**
#### `list_tools` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/transforms/namespace.py#L101" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
```python
list_tools(self, call_next: ListToolsNext) -> Sequence[Tool]
```
Prefix tool names with namespace.
#### `get_tool` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/transforms/namespace.py#L108" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
```python
get_tool(self, name: str, call_next: GetToolNext) -> Tool | None
```
Get tool by namespaced name.
#### `list_resources` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/transforms/namespace.py#L124" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
```python
list_resources(self, call_next: ListResourcesNext) -> Sequence[Resource]
```
Add namespace path segment to resource URIs.
#### `get_resource` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/transforms/namespace.py#L132" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
```python
get_resource(self, uri: str, call_next: GetResourceNext) -> Resource | None
```
Get resource by namespaced URI.
#### `list_resource_templates` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/transforms/namespace.py#L152" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
```python
list_resource_templates(self, call_next: ListResourceTemplatesNext) -> Sequence[ResourceTemplate]
```
Add namespace path segment to template URIs.
#### `get_resource_template` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/transforms/namespace.py#L162" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
```python
get_resource_template(self, uri: str, call_next: GetResourceTemplateNext) -> ResourceTemplate | None
```
Get resource template by namespaced URI.
#### `list_prompts` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/transforms/namespace.py#L184" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
```python
list_prompts(self, call_next: ListPromptsNext) -> Sequence[Prompt]
```
Prefix prompt names with namespace.
#### `get_prompt` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/transforms/namespace.py#L191" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
```python
get_prompt(self, name: str, call_next: GetPromptNext) -> Prompt | None
```
Get prompt by namespaced name.