docs: verify five-tool mcp surface

This commit is contained in:
zhaoyilun
2026-07-09 23:16:02 +08:00
parent 57eb7a5fc7
commit 220f3f68c1
4 changed files with 147 additions and 40 deletions

View File

@@ -6,7 +6,8 @@ $expectedTools = @(
"win_helper_version",
"win_helper_self_check",
"win_helper_scan_windows",
"win_helper_dump_uia"
"win_helper_dump_uia",
"isphere_receive_messages"
)
$tempRoot = Join-Path ([System.IO.Path]::GetTempPath()) ("isphere-go-mcp-verify-" + [guid]::NewGuid().ToString("N"))
@@ -74,9 +75,10 @@ var expectedTools = []string{
"win_helper_self_check",
"win_helper_scan_windows",
"win_helper_dump_uia",
"isphere_receive_messages",
}
var forbiddenTerms = []string{"send", "search", "file", "login", "conversation", "upload", "download", "receive", "autologin"}
var forbiddenTerms = []string{"send", "search", "file", "login", "conversation", "upload", "download", "autologin"}
func main() {
ctx, cancel := context.WithTimeout(context.Background(), 20*time.Second)
@@ -122,7 +124,7 @@ func main() {
sort.Strings(toolNames)
want := append([]string(nil), expectedTools...)
sort.Strings(want)
if len(toolNames) != 4 || !reflect.DeepEqual(toolNames, want) {
if len(toolNames) != 5 || !reflect.DeepEqual(toolNames, want) {
fail("tools/list", fmt.Errorf("tool names = %#v, want %#v", toolNames, want))
}
@@ -153,6 +155,26 @@ func main() {
fail("tools/call win_helper_version", fmt.Errorf("helper_name = %q, want ISphereWinHelper", helperName))
}
receiveResult, err := session.CallTool(ctx, &mcp.CallToolParams{Name: "isphere_receive_messages", Arguments: map[string]any{"limit": 5}})
if err != nil {
fail("tools/call isphere_receive_messages", err)
}
if receiveResult.IsError {
fail("tools/call isphere_receive_messages", fmt.Errorf("tool returned isError=true: %#v", receiveResult.Content))
}
var receivePayload map[string]any
receiveEncoded, _ := json.Marshal(receiveResult.StructuredContent)
if err := json.Unmarshal(receiveEncoded, &receivePayload); err != nil {
fail("tools/call isphere_receive_messages", fmt.Errorf("decode structuredContent %s: %w", receiveEncoded, err))
}
messagesValue, ok := receivePayload["messages"].([]any)
if !ok {
fail("tools/call isphere_receive_messages", fmt.Errorf("messages missing or not array: %s", receiveEncoded))
}
if len(messagesValue) != 0 {
fail("tools/call isphere_receive_messages", fmt.Errorf("default empty source returned %d messages, want 0", len(messagesValue)))
}
result := map[string]any{
"ok": true,
"transport": "sdk_in_memory",
@@ -160,6 +182,7 @@ func main() {
"tool_count": len(toolNames),
"tools": toolNames,
"helper_name": helperName,
"receive_message_count": len(messagesValue),
"real_isphere_login_required": false,
"python_runtime_required": false,
"action_tools_present": false,
@@ -195,7 +218,8 @@ func fail(step string, err error) {
Assert-True ($script:harnessJson.ok -eq $true) "SDK harness did not return ok=true"
Assert-True ($script:harnessJson.helper_name -eq "ISphereWinHelper") "SDK harness helper_name mismatch: $($script:harnessJson.helper_name)"
Assert-True ($script:harnessJson.tool_count -eq 4) "SDK harness tool_count mismatch: $($script:harnessJson.tool_count)"
Assert-True ($script:harnessJson.tool_count -eq 5) "SDK harness tool_count mismatch: $($script:harnessJson.tool_count)"
Assert-True ($script:harnessJson.receive_message_count -eq 0) "SDK harness receive_message_count mismatch: $($script:harnessJson.receive_message_count)"
[ordered]@{
ok = $true
@@ -204,6 +228,7 @@ func fail(step string, err error) {
helper_name = $script:harnessJson.helper_name
tool_count = $script:harnessJson.tool_count
tools = $script:harnessJson.tools
receive_message_count = $script:harnessJson.receive_message_count
python_runtime_required = $false
real_isphere_login_required = $false
action_tools_present = $false
@@ -216,4 +241,4 @@ finally {
if (Test-Path -LiteralPath $harnessDir) {
Remove-Item -LiteralPath $harnessDir -Recurse -Force
}
}
}