fastmcp/examples/tool_result_echo.py
Brandon Shar c18782f02b
Add meta support to ToolResult (#2283)
* Add meta to ToolResult

* add this at the client level and test the full integration

* add example

* slipped through linting somehow

---------

Co-authored-by: Jeremiah Lowin <153965+jlowin@users.noreply.github.com>
2025-11-02 16:46:52 -05:00

22 lines
371 B
Python

"""
FastMCP Echo Server
"""
from dataclasses import dataclass
from fastmcp import FastMCP
from fastmcp.tools.tool import ToolResult
mcp = FastMCP("Echo Server")
@dataclass
class EchoData:
data: str
@mcp.tool
def echo(text: str) -> ToolResult:
return ToolResult(
content=text, structured_content=EchoData(data=text), meta={"some": "metadata"}
)