Add local-tool-calling module: six small Ollama models scored on one MCP-served tool suite
Four tools served over MCP, twelve prompts, LangChain4j 1.24.0 OllamaChatModel, a scorer that validates each call against the tool's own JSON schema, and scripts to run and summarise the benchmark. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_017ic4b3obqqePfZ9m2Jk5Ub
This commit is contained in:
co-authored by
Claude Sonnet 5.5
parent
ae8fe985b4
commit
f4f90b3b30
@@ -0,0 +1,39 @@
|
||||
"""The tool suite, served over MCP (stdio). Run by the Java harness; you never start it by hand.
|
||||
|
||||
Requires: pip install "mcp>=2" (mcp 2.x renamed FastMCP to MCPServer; the old import raises ModuleNotFoundError)
|
||||
The four tools are deliberately dull. The benchmark never executes them (it only looks at what
|
||||
the model ASKS for); McpWiring executes one of them end to end.
|
||||
"""
|
||||
from typing import Literal, Optional
|
||||
from mcp.server.mcpserver import MCPServer
|
||||
|
||||
mcp = MCPServer("local-tool-suite")
|
||||
|
||||
|
||||
@mcp.tool()
|
||||
def get_weather(city: str, unit: Literal["celsius", "fahrenheit"] = "celsius") -> str:
|
||||
"""Get the current weather for a city."""
|
||||
temp = 31 if unit == "celsius" else 88
|
||||
return f"{city}: {temp} degrees {unit}, humid"
|
||||
|
||||
|
||||
@mcp.tool()
|
||||
def convert_currency(amount: float, from_currency: str, to_currency: str) -> str:
|
||||
"""Convert an amount of money between two currencies using ISO 4217 codes such as USD or INR."""
|
||||
return f"{amount} {from_currency} = {round(amount * 83.2, 2)} {to_currency} (fixed demo rate)"
|
||||
|
||||
|
||||
@mcp.tool()
|
||||
def create_reminder(text: str, minutes_from_now: int) -> str:
|
||||
"""Create a reminder that fires the given number of minutes from now."""
|
||||
return f"Reminder set for +{minutes_from_now} min: {text}"
|
||||
|
||||
|
||||
@mcp.tool()
|
||||
def search_notes(query: str, limit: Optional[int] = None) -> str:
|
||||
"""Search the user's personal notes. Optionally cap the number of results."""
|
||||
return f"3 notes match '{query}' (limit={limit})"
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
mcp.run(transport="stdio")
|
||||
Reference in New Issue
Block a user