Skip to main content
Glama
Qwinty
by Qwinty

search_space

Search for objects within a specific Anytype space, with options to filter by type, sort results, and control pagination.

Instructions

Executes a search within a specific space, with options for filtering by type and sorting.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
space_idYesSpace ID to search within
queryNoSearch term
typesNoOptional list of object type keys or IDs to filter by
sort_propertyNoProperty to sort bylast_modified_date
sort_directionNoSort directiondesc
offsetNoPagination offset
limitNoNumber of results per page (1-1000)
full_responseNoSet to true to get full unfiltered response
include_textNoSet to true to include full formatted text content from blocks. USE WITH CAUTION: This can return a large amount of data.

Implementation Reference

  • src/index.ts:727-822 (registration)
    Complete registration of the 'search_space' MCP tool, including description, Zod input schema for parameters like space_id, query, types, sorting, pagination, full_response, include_text, and inline async handler that validates limit, builds search request, calls Anytype API POST /spaces/{space_id}/search, optionally filters results with filterObjectsData, handles errors, and returns JSON-formatted response as text content.
    this.server.tool(
      "search_space",
      "Executes a search within a specific space, with options for filtering by type and sorting.",
      {
        space_id: z.string().describe("Space ID to search within"),
        query: z.string().optional().describe("Search term"),
        types: z
          .array(z.string())
          .optional()
          .describe("Optional list of object type keys or IDs to filter by"),
        sort_property: z
          .enum([
            "created_date",
            "last_modified_date",
            "last_opened_date",
            "name",
          ])
          .optional()
          .default("last_modified_date")
          .describe("Property to sort by"),
        sort_direction: z
          .enum(["asc", "desc"])
          .optional()
          .default("desc")
          .describe("Sort direction"),
        offset: z.number().optional().default(0).describe("Pagination offset"),
        limit: z
          .number()
          .optional()
          .default(100)
          .describe("Number of results per page (1-1000)"),
        full_response: z
          .boolean()
          .optional()
          .default(false)
          .describe("Set to true to get full unfiltered response"),
        include_text: z
          .boolean()
          .optional()
          .default(false)
          .describe(
            "Set to true to include full formatted text content from blocks. USE WITH CAUTION: This can return a large amount of data."
          ),
      },
      async ({
        space_id,
        query,
        types,
        sort_property,
        sort_direction,
        offset,
        limit,
        full_response,
        include_text,
      }) => {
        try {
          const validLimit = Math.max(1, Math.min(1000, limit));
          const searchRequest: any = { query };
          if (types) {
            searchRequest.types = types;
          }
          searchRequest.sort = {
            property: sort_property,
            direction: sort_direction,
          };
    
          const response = await this.makeRequest(
            "post",
            `/spaces/${space_id}/search`,
            searchRequest,
            { offset, limit: validLimit }
          );
    
          // Decide how to process the response data based on parameters
          let responseData;
          if (full_response) {
            // Return unfiltered data if full_response is true
            responseData = response.data;
          } else {
            // Filter the response data
            responseData = this.filterObjectsData(response.data, include_text);
          }
    
          return {
            content: [
              {
                type: "text" as const,
                text: JSON.stringify(responseData, null, 2),
              },
            ],
          };
        } catch (error) {
          return this.handleApiError(error);
        }
      }
    );
  • The inline handler function executing the 'search_space' tool logic: constructs and sends POST request to Anytype API `/spaces/${space_id}/search` with query, types, sort params; optionally applies filtering; returns structured content response or error.
    async ({
      space_id,
      query,
      types,
      sort_property,
      sort_direction,
      offset,
      limit,
      full_response,
      include_text,
    }) => {
      try {
        const validLimit = Math.max(1, Math.min(1000, limit));
        const searchRequest: any = { query };
        if (types) {
          searchRequest.types = types;
        }
        searchRequest.sort = {
          property: sort_property,
          direction: sort_direction,
        };
    
        const response = await this.makeRequest(
          "post",
          `/spaces/${space_id}/search`,
          searchRequest,
          { offset, limit: validLimit }
        );
    
        // Decide how to process the response data based on parameters
        let responseData;
        if (full_response) {
          // Return unfiltered data if full_response is true
          responseData = response.data;
        } else {
          // Filter the response data
          responseData = this.filterObjectsData(response.data, include_text);
        }
    
        return {
          content: [
            {
              type: "text" as const,
              text: JSON.stringify(responseData, null, 2),
            },
          ],
        };
      } catch (error) {
        return this.handleApiError(error);
      }
    }
  • Zod schema for 'search_space' tool inputs: required space_id; optional query, types array, sort_property (enum), sort_direction, offset, limit (1-1000), full_response boolean, include_text boolean.
    {
      space_id: z.string().describe("Space ID to search within"),
      query: z.string().optional().describe("Search term"),
      types: z
        .array(z.string())
        .optional()
        .describe("Optional list of object type keys or IDs to filter by"),
      sort_property: z
        .enum([
          "created_date",
          "last_modified_date",
          "last_opened_date",
          "name",
        ])
        .optional()
        .default("last_modified_date")
        .describe("Property to sort by"),
      sort_direction: z
        .enum(["asc", "desc"])
        .optional()
        .default("desc")
        .describe("Sort direction"),
      offset: z.number().optional().default(0).describe("Pagination offset"),
      limit: z
        .number()
        .optional()
        .default(100)
        .describe("Number of results per page (1-1000)"),
      full_response: z
        .boolean()
        .optional()
        .default(false)
        .describe("Set to true to get full unfiltered response"),
      include_text: z
        .boolean()
        .optional()
        .default(false)
        .describe(
          "Set to true to include full formatted text content from blocks. USE WITH CAUTION: This can return a large amount of data."
        ),
    },
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It mentions 'options for filtering by type and sorting' but lacks critical details: it doesn't specify what types of objects are searchable, the search scope (e.g., metadata, content), pagination behavior (implied by offset/limit but not explained), performance implications, or error handling. For a search tool with 9 parameters and no annotations, this is insufficient.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that front-loads the core purpose. It avoids redundancy and waste, though it could be slightly more structured (e.g., separating scope from options). It earns its place by summarizing key capabilities concisely.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (9 parameters, search functionality), lack of annotations, and no output schema, the description is incomplete. It doesn't explain what the search returns (e.g., object metadata, snippets), how results are formatted, or limitations (e.g., search accuracy, rate limits). For a search tool, this leaves significant gaps for an AI agent to infer behavior.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, meaning all parameters are documented in the schema. The description adds minimal value beyond the schema—it mentions 'filtering by type and sorting,' which aligns with the 'types,' 'sort_property,' and 'sort_direction' parameters but doesn't provide additional context like valid type values or sorting nuances. With high schema coverage, the baseline is 3.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'Executes a search within a specific space, with options for filtering by type and sorting.' It specifies the verb ('executes a search'), resource ('within a specific space'), and scope ('filtering by type and sorting'). However, it doesn't explicitly differentiate from sibling tools like 'global_search' or 'get_objects', which would require a 5.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention sibling tools like 'global_search' (for searches across all spaces) or 'get_objects' (for retrieving objects without search), nor does it specify prerequisites or exclusions. The agent must infer usage from the description alone.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/Qwinty/anytype-mcp'

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