mirror of
https://github.com/PrefectHQ/fastmcp.git
synced 2026-08-09 07:09:11 +02:00
Fix stale mcp.types imports in examples (#4452)
This commit is contained in:
parent
515a2244a2
commit
3c43038860
5 changed files with 14 additions and 13 deletions
|
|
@ -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}"
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -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")
|
||||
|
||||
|
|
|
|||
|
|
@ -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}]"
|
||||
)
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue