Trim fastmcp.types to FastMCP-unique types only

fastmcp.types re-exported 29 mcp_types symbols verbatim, which was
pointless indirection users had to discover. It now holds only Textarea,
the one type FastMCP actually defines; everything else imports from
mcp_types directly. These mirrors were added during unreleased SDK v2
migration work and never shipped, so this is not a breaking change.
This commit is contained in:
Jeremiah Lowin 2026-07-20 20:53:11 -04:00
commit e32a2098f9
No known key found for this signature in database
22 changed files with 60 additions and 165 deletions

View file

@ -412,7 +412,7 @@ The following tool books a flight across three rounds: it asks for a destination
```python
from fastmcp import FastMCP, Context
from fastmcp.types import InputRequiredResult, ElicitRequest, ElicitRequestFormParams
from mcp_types import InputRequiredResult, ElicitRequest, ElicitRequestFormParams
mcp = FastMCP("Booking Server")

View file

@ -15,7 +15,7 @@ Icons provide visual representations for your MCP servers and components, helpin
Icons use the standard MCP Icon type from the MCP protocol specification. Each icon specifies a source URL or data URI, and optionally includes MIME type, size, and theme information.
```python
from fastmcp.types import Icon
from mcp_types import Icon
icon = Icon(
src="https://example.com/icon.png",
@ -37,7 +37,7 @@ Add icons and a website URL to your server for display in client applications. M
```python
from fastmcp import FastMCP
from fastmcp.types import Icon
from mcp_types import Icon
mcp = FastMCP(
name="WeatherService",
@ -66,7 +66,7 @@ Icons can be added to individual tools, resources, resource templates, and promp
### Tool Icons
```python
from fastmcp.types import Icon
from mcp_types import Icon
@mcp.tool(
icons=[Icon(src="https://example.com/calculator-icon.png")]
@ -121,7 +121,7 @@ Supply two icons with complementary `theme` values and the client picks the one
```python
from fastmcp import FastMCP
from fastmcp.types import Icon
from mcp_types import Icon
mcp = FastMCP(
name="WeatherService",
@ -135,7 +135,7 @@ mcp = FastMCP(
The same field works on tools, resources, resource templates, and prompts:
```python
from fastmcp.types import Icon
from mcp_types import Icon
@mcp.tool(
icons=[
@ -155,7 +155,7 @@ Omitting `theme` means the icon is assumed suitable for any theme. That's the ri
For small icons or when you want to embed the icon directly without external dependencies, use data URIs. This approach eliminates the need for hosting and ensures the icon is always available.
```python
from fastmcp.types import Icon
from mcp_types import Icon
from fastmcp.utilities.types import Image
# SVG icon as data URI
@ -175,7 +175,7 @@ def my_tool() -> str:
FastMCP provides the `Image` utility class to convert local image files into data URIs.
```python
from fastmcp.types import Icon
from mcp_types import Icon
from fastmcp.utilities.types import Image
# Generate a data URI from a local image file

View file

@ -102,7 +102,7 @@ Use model preferences when different tasks benefit from different model characte
For requests that need conversational context, construct a list of `SamplingMessage` objects representing the conversation history. Each message has a `role` ("user" or "assistant") and `content` (a `TextContent` object).
```python
from fastmcp.types import SamplingMessage, TextContent
from mcp_types import SamplingMessage, TextContent
from fastmcp import FastMCP, Context
mcp = FastMCP()
@ -372,7 +372,7 @@ Use `sample_step()` when you need to:
By default, `sample_step()` executes any tool calls and includes the results in the history. Call it in a loop, passing the updated history each time, until a stop condition is met.
```python
from fastmcp.types import SamplingMessage
from mcp_types import SamplingMessage
from fastmcp import FastMCP, Context
mcp = FastMCP()
@ -425,7 +425,7 @@ The contents of `step.history` depend on `execute_tools`:
Set `execute_tools=False` to handle tool execution yourself. When disabled, `step.history` contains the user message and the assistant's response with tool calls—but no tool results. You execute the tools and append the results as a user message.
```python
from fastmcp.types import SamplingMessage, ToolResultContent, TextContent
from mcp_types import SamplingMessage, ToolResultContent, TextContent
from fastmcp import FastMCP, Context
mcp = FastMCP()

View file

@ -723,7 +723,7 @@ For complete control over tool responses, return a `ToolResult` object. This giv
```python
from fastmcp.tools.tool import ToolResult
from fastmcp.types import TextContent
from mcp_types import TextContent
@mcp.tool
def advanced_tool() -> ToolResult:
@ -944,7 +944,7 @@ Annotations serve several purposes in client applications:
You can add annotations to a tool using the `annotations` parameter in the `@mcp.tool` decorator. FastMCP accepts either a plain dict or `ToolAnnotations`; the examples below use `ToolAnnotations` for consistency and stronger editor/type support.
```python
from fastmcp.types import ToolAnnotations
from mcp_types import ToolAnnotations
@mcp.tool(
annotations=ToolAnnotations(
@ -983,7 +983,7 @@ Mark a tool as read-only when it retrieves data, performs calculations, or check
```python
from fastmcp import FastMCP
from fastmcp.types import ToolAnnotations
from mcp_types import ToolAnnotations
mcp = FastMCP("Data Server")