feat: validate contact and group search args

This commit is contained in:
zhaoyilun
2026-07-10 01:38:48 +08:00
parent 95699e05b5
commit b1891dd6cd
10 changed files with 207 additions and 21 deletions

View File

@@ -58,14 +58,18 @@ func RegisterISphereReadTools(server *mcp.Server, source ReceiveMessagesSource)
}
func validateReceiveMessagesArgs(input ReceiveMessagesArgs) error {
sourcePreference := strings.ToLower(strings.TrimSpace(input.SourcePreference))
return validateLocalReadonlySourceAndCursor(ToolNameReceiveMessages, input.SourcePreference, input.Cursor)
}
func validateLocalReadonlySourceAndCursor(toolName string, sourcePreferenceValue string, cursorValue string) error {
sourcePreference := strings.ToLower(strings.TrimSpace(sourcePreferenceValue))
switch sourcePreference {
case "", "auto", "local_readonly":
default:
return fmt.Errorf("isphere_receive_messages source_preference %q is not available; only auto and local_readonly are supported", input.SourcePreference)
return fmt.Errorf("%s source_preference %q is not available; only auto and local_readonly are supported", toolName, sourcePreferenceValue)
}
if strings.TrimSpace(input.Cursor) != "" {
return fmt.Errorf("isphere_receive_messages cursor pagination is not available yet")
if strings.TrimSpace(cursorValue) != "" {
return fmt.Errorf("%s cursor pagination is not available yet", toolName)
}
return nil
}