Something went wrong. Try again.
mirror of github.com/PrefectHQ/fastmcp
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465---title: Namespace TransformsidebarTitle: Namespacedescription: Prefix component names to prevent conflictsicon: tagtag: NEW---
import { VersionBadge } from '/snippets/version-badge.mdx'
<VersionBadge version="3.0.0" />
The `Namespace` transform prefixes all component names, preventing conflicts when composing multiple servers.
Tools and prompts receive an underscore-separated prefix. Resources and templates receive a path-segment prefix in their URIs.
| Component | Original | With `Namespace("api")` ||-----------|----------|-------------------------|| Tool | `my_tool` | `api_my_tool` || Prompt | `my_prompt` | `api_my_prompt` || Resource | `data://info` | `data://api/info` || Template | `data://{id}` | `data://api/{id}` |
The most common use is through the `mount()` method's `namespace` parameter.
```pythonfrom fastmcp import FastMCP
weather = FastMCP("Weather")calendar = FastMCP("Calendar")
@weather.tooldef get_data() -> str: return "Weather data"
@calendar.tooldef get_data() -> str: return "Calendar data"
# Without namespacing, these would conflictmain = FastMCP("Main")main.mount(weather, namespace="weather")main.mount(calendar, namespace="calendar")
# Clients see: weather_get_data, calendar_get_data```
You can also apply namespacing directly using the `Namespace` transform.
```pythonfrom fastmcp import FastMCPfrom fastmcp.server.transforms import Namespace
mcp = FastMCP("Server")
@mcp.tooldef greet(name: str) -> str: return f"Hello, {name}!"
# Namespace all componentsmcp.add_transform(Namespace("api"))
# Tool is now: api_greet```