Skip to content

πŸš€ The fast, Pythonic way to build MCP servers and clients.

Fix stale mcp.types imports in examples (#4452)

Jeremiah Lowin3c4303886075
diff --git a/examples/in_memory_proxy_example.py b/examples/in_memory_proxy_example.py
index 305e9aba2..20cea7360 100644
--- a/examples/in_memory_proxy_example.py
+++ b/examples/in_memory_proxy_example.py
@@ -9,11 +9,10 @@ It illustrates the pattern:
import asyncio
-from mcp.types import TextContent
-
from fastmcp import FastMCP
from fastmcp.client import Client
from fastmcp.server import create_proxy
+from fastmcp.types import TextContent
class EchoService:
@@ -64,8 +63,10 @@ async def main():
print(f"\n Calling 'echo' tool via proxy with message: '{message_to_echo}'")
try:
result = await final_client.call_tool("echo", {"message": message_to_echo})
- if result and isinstance(result[0], TextContent):
- print(f" Result from proxied 'echo' call: '{result[0].text}'")
+ if result.content and isinstance(result.content[0], TextContent):
+ print(
+ f" Result from proxied 'echo' call: '{result.content[0].text}'"
+ )
else:
print(
f" Error: Unexpected result format from proxied 'echo' call: {result}"
diff --git a/examples/smart_home/src/smart_home/hub.py b/examples/smart_home/src/smart_home/hub.py
index 827eae159..30c4f24d2 100644
--- a/examples/smart_home/src/smart_home/hub.py
+++ b/examples/smart_home/src/smart_home/hub.py
@@ -1,7 +1,7 @@
-from mcp.types import ToolAnnotations
from phue import Bridge
from fastmcp import FastMCP
+from fastmcp.types import ToolAnnotations
from smart_home.lights.server import lights_mcp
from smart_home.settings import settings
diff --git a/examples/smart_home/src/smart_home/lights/server.py b/examples/smart_home/src/smart_home/lights/server.py
index 7af3953d0..535b0f10d 100644
--- a/examples/smart_home/src/smart_home/lights/server.py
+++ b/examples/smart_home/src/smart_home/lights/server.py
@@ -7,12 +7,12 @@
from typing import Annotated, Any, Literal, TypedDict
-from mcp.types import ToolAnnotations
from phue.exceptions import PhueException
from pydantic import Field
from typing_extensions import NotRequired
from fastmcp import FastMCP
+from fastmcp.types import ToolAnnotations
from smart_home.lights.hue_utils import _get_bridge, handle_phue_error
diff --git a/examples/task_elicitation.py b/examples/task_elicitation.py
index 51f7b046a..2c7852e03 100644
--- a/examples/task_elicitation.py
+++ b/examples/task_elicitation.py
@@ -22,11 +22,10 @@ Requires the `docket` extra (included in dev dependencies).
import asyncio
from dataclasses import dataclass
-from mcp.types import TextContent
-
from fastmcp import Context, FastMCP
from fastmcp.client import Client
from fastmcp.server.elicitation import AcceptedElicitation
+from fastmcp.types import TextContent
mcp = FastMCP("Task Elicitation Demo")
diff --git a/examples/tasks/client.py b/examples/tasks/client.py
index f72814889..ac1dacf7c 100644
--- a/examples/tasks/client.py
+++ b/examples/tasks/client.py
@@ -21,10 +21,11 @@ from pathlib import Path
from typing import Annotated
import cyclopts
-from mcp.types import GetTaskResult, TextContent
+from mcp_types import GetTaskResult
from rich.console import Console
from fastmcp.client import Client
+from fastmcp.types import TextContent
console = Console()
app = cyclopts.App(name="tasks-client", help="FastMCP Tasks Example Client")
@@ -43,7 +44,7 @@ def load_server():
# Track last message to deduplicate consecutive identical notifications
# Note: Docket fires separate events for progress.increment() and progress.set_message(),
-# but MCP's statusMessage field only carries the text message (no numerical progress).
+# but MCP's status_message field only carries the text message (no numerical progress).
# This means we often get duplicate notifications with identical messages.
_last_notification_message = None
@@ -57,10 +58,10 @@ def print_notification(status: GetTaskResult) -> None:
global _last_notification_message
# Skip if this is the same message we just printed
- if status.statusMessage == _last_notification_message:
+ if status.status_message == _last_notification_message:
return
- _last_notification_message = status.statusMessage
+ _last_notification_message = status.status_message
color = {
"working": "yellow",
@@ -75,7 +76,7 @@ def print_notification(status: GetTaskResult) -> None:
}.get(status.status, "⚠️")
console.print(
- f"[{color}]πŸ“’ Notification: {status.status} {icon} - {status.statusMessage}[/{color}]"
+ f"[{color}]πŸ“’ Notification: {status.status} {icon} - {status.status_message}[/{color}]"
)