Skip to main content
Glama

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
NameRequiredDescriptionDefault
queryNoTexto a buscar
space_idNoID del espacio específico (opcional)
typesNoTipos de objetos a filtrar
limitNoLímite de resultados

Implementation Reference

  • 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) }] };
    }
  • 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';

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/cryptonahue/mcp-anytype'

If you have feedback or need assistance with the MCP directory API, please join our Discord server