mirror of
https://github.com/PrefectHQ/fastmcp.git
synced 2026-08-23 22:14:18 +02:00
Fix stale SDK idioms in examples and scripts
This commit is contained in:
parent
3c43038860
commit
3c484aa4a9
4 changed files with 15 additions and 15 deletions
|
|
@ -12,8 +12,8 @@ from typing import Any
|
|||
|
||||
import yaml
|
||||
|
||||
from fastmcp import FastMCP
|
||||
from fastmcp.tools.tool import ToolResult
|
||||
from fastmcp import Client, FastMCP
|
||||
from fastmcp.tools import ToolResult
|
||||
|
||||
|
||||
def with_serializer(serializer: Callable[[Any], str]):
|
||||
|
|
@ -55,18 +55,18 @@ def get_json_data() -> dict:
|
|||
|
||||
|
||||
async def example_usage():
|
||||
# YAML serialized tool
|
||||
yaml_result = await server._call_tool_mcp("get_example_data", {})
|
||||
print("YAML Tool Result:")
|
||||
print(yaml_result)
|
||||
print()
|
||||
async with Client(server) as client:
|
||||
# YAML serialized tool
|
||||
yaml_result = await client.call_tool("get_example_data", {})
|
||||
print("YAML Tool Result:")
|
||||
print(yaml_result.content[0].text)
|
||||
print()
|
||||
|
||||
# Default JSON serialized tool
|
||||
json_result = await server._call_tool_mcp("get_json_data", {})
|
||||
print("JSON Tool Result:")
|
||||
print(json_result)
|
||||
# Default JSON serialized tool
|
||||
json_result = await client.call_tool("get_json_data", {})
|
||||
print("JSON Tool Result:")
|
||||
print(json_result.content[0].text)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(example_usage())
|
||||
server.run()
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ from rich import print
|
|||
|
||||
from fastmcp import Client, FastMCP
|
||||
from fastmcp.server.providers import Provider
|
||||
from fastmcp.tools.tool import Tool, ToolResult
|
||||
from fastmcp.tools import Tool, ToolResult
|
||||
|
||||
DB_PATH = Path(__file__).parent / "tools.db"
|
||||
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ async def main():
|
|||
print("=== Resource Templates ===")
|
||||
templates = await client.list_resource_templates()
|
||||
for t in templates:
|
||||
print(f" {t.uriTemplate}")
|
||||
print(f" {t.uri_template}")
|
||||
print()
|
||||
|
||||
# Read a skill's main file
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ import time
|
|||
from dataclasses import dataclass
|
||||
|
||||
from fastmcp import FastMCP
|
||||
from fastmcp.tools.tool import ToolResult
|
||||
from fastmcp.tools import ToolResult
|
||||
|
||||
mcp = FastMCP("Echo Server")
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue