-
Notifications
You must be signed in to change notification settings - Fork 20
Open
Description
Tool annotations should be attached to the tool definition as closely as possible. It's currently awkward to create to a tool function that has annotations because those annotations need to be passed to chat.register_tool() at registration, which might be in a different place than where the tool is defined. (The tool could be in packaged code and the registration in user code.)
Instead of this
import faicons
from chatlas import ChatOpenAI
def get_weather_forecast(
lat: float, lon: float, location_name: str
) -> ContentToolResult:
"""Get the weather forecast for a location."""
# Mocked weather data for demonstration purposes
return {"temperature_2m": 18, "condition": "Partly Cloudy"}
# Create chat client and register tool
chat_client = ChatOpenAI(model="gpt-4.1-nano")
chat_client.register_tool(
get_weather_forecast,
annotations={ # << THIS COULD HAPPEN FAR FROM TOOL DEL
"title": "Weather Forecast",
"icon": faicons.icon_svg("cloud"),
},
)Maybe this
import faicons
from chatlas import ChatOpenAI, add_tool_annotations
@add_tool_annotations(
title="Weather Forecast",
icon=faicons.icon_svg("cloud")
)
def get_weather_forecast(
lat: float, lon: float, location_name: str
) -> ContentToolResult:
"""Get the weather forecast for a location."""
# Mocked weather data for demonstration purposes
return {"temperature_2m": 18, "condition": "Partly Cloudy"}
# Create chat client and register tool
chat_client = ChatOpenAI(model="gpt-4.1-nano")
chat_client.register_tool(get_weather_forecast)Advantages
This would also resolve some of the underlying issue in #169 where known standard MCP Tool Annotation properties could be named arguments that are documented, but additional kwargs are just added as tool annotations.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels