feat: validate contact and group search args
This commit is contained in:
@@ -12,8 +12,11 @@ import (
|
||||
const ToolNameSearchContacts = "isphere_search_contacts"
|
||||
|
||||
type SearchContactsArgs struct {
|
||||
Query string `json:"query" jsonschema:"contact search query; currently matches bare JIDs from local readonly message logs"`
|
||||
Limit int `json:"limit,omitempty" jsonschema:"maximum number of contacts to return; zero or negative returns all matches"`
|
||||
Query string `json:"query" jsonschema:"contact search query; currently matches bare JIDs from local readonly message logs"`
|
||||
Limit int `json:"limit,omitempty" jsonschema:"maximum number of contacts to return; zero or negative returns all matches"`
|
||||
Cursor string `json:"cursor,omitempty" jsonschema:"pagination cursor; currently only empty cursor is supported"`
|
||||
SourcePreference string `json:"source_preference,omitempty" jsonschema:"source selector; currently supports auto or local_readonly only"`
|
||||
IncludeInactive bool `json:"include_inactive,omitempty" jsonschema:"accepted for contract compatibility; local readonly message logs do not expose inactive state"`
|
||||
}
|
||||
|
||||
func RegisterISphereContactTools(server *mcp.Server, source ReceiveMessagesSource) {
|
||||
@@ -25,6 +28,9 @@ func RegisterISphereContactTools(server *mcp.Server, source ReceiveMessagesSourc
|
||||
Name: ToolNameSearchContacts,
|
||||
Description: "Search iSphere contact candidates from the configured read-only message source.",
|
||||
}, func(ctx context.Context, _ *mcp.CallToolRequest, input SearchContactsArgs) (*mcp.CallToolResult, map[string]any, error) {
|
||||
if err := validateLocalReadonlySourceAndCursor(ToolNameSearchContacts, input.SourcePreference, input.Cursor); err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
started := time.Now().UTC()
|
||||
messages, err := source.ReceiveMessages(ctx, isphere.ReceiveMessagesQuery{Limit: 0})
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user