update mcp definition example
This commit is contained in:
@@ -1,5 +1,41 @@
|
||||
check my understand:
|
||||
1) if LLM didn't use tool calls, assistantMessage get pushed into agent._state.messages and
|
||||
it will be the latest message in agent._state.messages. then _agentLoop() can pick it as
|
||||
the output to outputChannel
|
||||
2) if LLM use tool calls but toolResultBatch.terminate is false, assistantMessageToolCall
|
||||
# "tools/list" input:
|
||||
mcpServer("tools/list")
|
||||
# sending out payload before smart packed by msghandler
|
||||
Dict(
|
||||
"method"=> "tools/list"
|
||||
)
|
||||
# expected return after smart unpacked by msghandler
|
||||
Dict("tools" => [
|
||||
Dict("toolName" => "getWeather",
|
||||
"title" => "Weather Lookup",
|
||||
"description" => "Fetch current weather for a city.",
|
||||
"inputSchema" => Dict("type"=>"object",
|
||||
"properties" => Dict("city"=>Dict("type"=>"string", "description"=>"City name"),
|
||||
"units"=>Dict("type"=>"string", "enum"=>["celsius","fahrenheit"], "default"=>"celsius")),
|
||||
"required" => ["city"])
|
||||
)
|
||||
])
|
||||
|
||||
# "tools/call" input:
|
||||
mcpServer("tools/call", "getWeather", Dict("city"=>"Tokyo", "units"=>"celsius"))
|
||||
# sending out payload before smart packed by msghandler
|
||||
Dict(
|
||||
"method"=> "tools/call",
|
||||
"tools"=> Dict("toolName"=>"getWeather", "arguments"=>Dict("city"=>"Tokyo", "units"=>"celsius"))
|
||||
)
|
||||
# expected return after smart unpacked by msghandler
|
||||
Dict(
|
||||
"toolName"=>"getWeather",
|
||||
"content": [{"type": "text", "text": "Weather in Tokyo: Sunny, 22°C"}],
|
||||
"isError": false
|
||||
)
|
||||
|
||||
# If an error occurs, mcpServer returns after smart unpacked by msghandler:
|
||||
Dict(
|
||||
"toolName"=>"getWeather",
|
||||
"content": [],
|
||||
"error": Dict("code"=>1, "message"=>"City not found"),
|
||||
"isError": true
|
||||
)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user