anytype_search_objects
Search for objects across all spaces or within a specific space in Anytype, with options to filter by object type and limit results.
Instructions
Busca objetos en todos los espacios o en un espacio específico
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | No | Texto a buscar | |
| space_id | No | ID del espacio específico (opcional) | |
| types | No | Tipos de objetos a filtrar | |
| limit | No | Límite de resultados |
Implementation Reference
- src/handlers/objects.ts:55-102 (handler)The core handler function that executes the 'anytype_search_objects' tool. It handles search queries either globally or within a specific space by constructing the appropriate Anytype API endpoint and request body, including support for types filtering, sorting, pagination, and returns the formatted response.export async function handleSearchObjects(args: any) { const { space_id, query, types, limit = 20, offset = 0 } = args; let endpoint; let requestBody: any; if (space_id) { // Search within a specific space - using correct API v1 endpoint endpoint = `/v1/spaces/${space_id}/search?offset=${offset}&limit=${limit}`; // For space search, use property_key according to API docs requestBody = { query: query || '', sort: { direction: 'desc', property_key: 'last_modified_date' } }; // Add types filter if provided (no prefix needed for space search) if (types && types.length > 0) { requestBody.types = types; } } else { // Global search across all spaces - using correct API v1 endpoint endpoint = `/v1/search?offset=${offset}&limit=${limit}`; // For global search, use property_key according to API docs requestBody = { query: query || '', sort: { direction: 'desc', property_key: 'last_modified_date' } }; // Add types filter if provided if (types && types.length > 0) { requestBody.types = types; } } const response = await makeRequest(endpoint, { method: 'POST', body: JSON.stringify(requestBody), }); return { content: [{ type: 'text', text: JSON.stringify(response, null, 2) }] }; }
- src/tools/objects.ts:9-20 (schema)The tool schema definition including name, description, and inputSchema for validation of parameters like query, space_id, types, and limit.name: 'anytype_search_objects', description: 'Busca objetos en todos los espacios o en un espacio específico', inputSchema: { type: 'object', properties: { query: { type: 'string', description: 'Texto a buscar' }, space_id: { type: 'string', description: 'ID del espacio específico (opcional)' }, types: { type: 'array', items: { type: 'string' }, description: 'Tipos de objetos a filtrar' }, limit: { type: 'number', description: 'Límite de resultados', default: 20 }, }, }, },
- src/index.ts:122-123 (registration)Registration of the tool handler in the main switch statement that dispatches tool calls to the appropriate handler function.case 'anytype_search_objects': return await handleSearchObjects(args);
- src/index.ts:85-93 (registration)Inclusion of objectTools (containing the schema) into the full list of available tools returned by ListToolsRequest.const tools = [ ...spaceTools, ...objectTools, ...propertyTools, ...typeTools, ...tagTools, ...templateTools, ...listTools, ];
- src/index.ts:16-16 (registration)Import of the objectTools array which includes the schema for anytype_search_objects.import { objectTools } from './tools/objects.js';