refactor: use snake case instead of camel case in types (#1894)
This commit is contained in:
parent
7080fcf1e6
commit
e94b386a13
3 changed files with 1063 additions and 1057 deletions
|
|
@ -20,5 +20,5 @@ class EchoResponse(BaseModel):
|
|||
def echo(text: str) -> Annotated[CallToolResult, EchoResponse]:
|
||||
"""Echo the input text with structure and metadata"""
|
||||
return CallToolResult(
|
||||
content=[TextContent(type="text", text=text)], structuredContent={"text": text}, _meta={"some": "metadata"}
|
||||
content=[TextContent(type="text", text=text)], structured_content={"text": text}, _meta={"some": "metadata"}
|
||||
)
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ icon_path = Path(__file__).parent / "mcp.png"
|
|||
icon_data = base64.standard_b64encode(icon_path.read_bytes()).decode()
|
||||
icon_data_uri = f"data:image/png;base64,{icon_data}"
|
||||
|
||||
icon_data = Icon(src=icon_data_uri, mimeType="image/png", sizes=["64x64"])
|
||||
icon_data = Icon(src=icon_data_uri, mime_type="image/png", sizes=["64x64"])
|
||||
|
||||
# Create server with icons in implementation
|
||||
mcp = FastMCP("Icons Demo Server", website_url="https://github.com/modelcontextprotocol/python-sdk", icons=[icon_data])
|
||||
|
|
@ -40,9 +40,9 @@ def prompt_with_icon(text: str) -> str:
|
|||
|
||||
@mcp.tool(
|
||||
icons=[
|
||||
Icon(src=icon_data_uri, mimeType="image/png", sizes=["16x16"]),
|
||||
Icon(src=icon_data_uri, mimeType="image/png", sizes=["32x32"]),
|
||||
Icon(src=icon_data_uri, mimeType="image/png", sizes=["64x64"]),
|
||||
Icon(src=icon_data_uri, mime_type="image/png", sizes=["16x16"]),
|
||||
Icon(src=icon_data_uri, mime_type="image/png", sizes=["32x32"]),
|
||||
Icon(src=icon_data_uri, mime_type="image/png", sizes=["64x64"]),
|
||||
]
|
||||
)
|
||||
def multi_icon_tool(action: str) -> str:
|
||||
|
|
|
|||
|
|
@ -161,32 +161,32 @@ if __name__ == "__main__":
|
|||
# Test get_weather
|
||||
result = await client.call_tool("get_weather", {"city": "London"})
|
||||
print("\nWeather in London:")
|
||||
print(json.dumps(result.structuredContent, indent=2))
|
||||
print(json.dumps(result.structured_content, indent=2))
|
||||
|
||||
# Test get_weather_summary
|
||||
result = await client.call_tool("get_weather_summary", {"city": "Paris"})
|
||||
print("\nWeather summary for Paris:")
|
||||
print(json.dumps(result.structuredContent, indent=2))
|
||||
print(json.dumps(result.structured_content, indent=2))
|
||||
|
||||
# Test get_weather_metrics
|
||||
result = await client.call_tool("get_weather_metrics", {"cities": ["Tokyo", "Sydney", "Mumbai"]})
|
||||
print("\nWeather metrics:")
|
||||
print(json.dumps(result.structuredContent, indent=2))
|
||||
print(json.dumps(result.structured_content, indent=2))
|
||||
|
||||
# Test get_weather_alerts
|
||||
result = await client.call_tool("get_weather_alerts", {"region": "California"})
|
||||
print("\nWeather alerts for California:")
|
||||
print(json.dumps(result.structuredContent, indent=2))
|
||||
print(json.dumps(result.structured_content, indent=2))
|
||||
|
||||
# Test get_temperature
|
||||
result = await client.call_tool("get_temperature", {"city": "Berlin", "unit": "fahrenheit"})
|
||||
print("\nTemperature in Berlin:")
|
||||
print(json.dumps(result.structuredContent, indent=2))
|
||||
print(json.dumps(result.structured_content, indent=2))
|
||||
|
||||
# Test get_weather_stats
|
||||
result = await client.call_tool("get_weather_stats", {"city": "Seattle", "days": 30})
|
||||
print("\nWeather stats for Seattle (30 days):")
|
||||
print(json.dumps(result.structuredContent, indent=2))
|
||||
print(json.dumps(result.structured_content, indent=2))
|
||||
|
||||
# Also show the text content for comparison
|
||||
print("\nText content for last result:")
|
||||
|
|
@ -204,11 +204,11 @@ if __name__ == "__main__":
|
|||
print(f"\nTool: {tool.name}")
|
||||
print(f"Description: {tool.description}")
|
||||
print("Input Schema:")
|
||||
print(json.dumps(tool.inputSchema, indent=2))
|
||||
print(json.dumps(tool.input_schema, indent=2))
|
||||
|
||||
if tool.outputSchema:
|
||||
if tool.output_schema:
|
||||
print("Output Schema:")
|
||||
print(json.dumps(tool.outputSchema, indent=2))
|
||||
print(json.dumps(tool.output_schema, indent=2))
|
||||
else:
|
||||
print("Output Schema: None (returns unstructured content)")
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue