Skip to main content
Glama
Qwinty
by Qwinty

global_search

Search across all accessible spaces with filtering by object type, sorting options, and pagination controls to find specific content.

Instructions

Executes a search across all spaces the user has access to, with options for filtering by type and sorting.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesSearch 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)
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

  • The async handler function that implements the core logic of the global_search tool: validates limit, builds search request with query, types, sort; POSTs to /search API; filters results with filterObjectsData; returns JSON text content.
    async ({
      query,
      types,
      sort_property,
      sort_direction,
      offset,
      limit,
      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",
          `/search`,
          searchRequest,
          { offset, limit: validLimit }
        );
        // Pass include_text to filterObjectsData
        const 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 input schema for the global_search tool parameters: required query, optional types filter, sorting (property/direction), pagination (offset/limit), and include_text flag.
    {
      query: z.string().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)"),
      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."
        ),
    },
  • src/index.ts:643-724 (registration)
    MCP server tool registration call for 'global_search', specifying name, description, Zod input schema, and async handler function.
    this.server.tool(
      "global_search",
      "Executes a search across all spaces the user has access to, with options for filtering by type and sorting.",
      {
        query: z.string().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)"),
        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 ({
        query,
        types,
        sort_property,
        sort_direction,
        offset,
        limit,
        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",
            `/search`,
            searchRequest,
            { offset, limit: validLimit }
          );
          // Pass include_text to filterObjectsData
          const 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);
        }
      }
    );
  • Supporting helper invoked by the handler to process and simplify API response data, filtering out unnecessary fields and optionally extracting full markdown-formatted text from object blocks.
    private filterObjectsData(data: any, includeText: boolean = false): any {
      if (!data || !data.data || !Array.isArray(data.data)) {
        return data;
      }
    
      const filteredObjects = data.data.map((obj: any) => {
        // Create a simplified object with only essential information
        const simplified: any = {
          id: obj.id,
          type: obj.type,
          name: obj.name,
          icon: obj.icon,
          layout: obj.layout,
          space_id: obj.space_id,
          root_id: obj.root_id,
        };
    
        // Include snippet only if not requested full text
        if (!includeText) {
          simplified.snippet = obj.snippet;
        }
    
        // Process blocks data
        if (obj.blocks && Array.isArray(obj.blocks)) {
          simplified.blocks_count = obj.blocks.length;
    
          // Extract full text content if requested
          if (includeText) {
            const fullText = this.extractFullText(obj.blocks);
            if (fullText) {
              simplified.full_text = fullText;
            }
          }
        }
    
        // Include simplified details (dates and creator)
        if (obj.details && Array.isArray(obj.details)) {
          const dates: any = {};
          let created_by: any = null;
    
          obj.details.forEach((detail: any) => {
            if (detail.id === "created_date" && detail.details?.created_date) {
              dates.created_date = detail.details.created_date;
            }
            if (
              detail.id === "last_modified_date" &&
              detail.details?.last_modified_date
            ) {
              dates.last_modified_date = detail.details.last_modified_date;
            }
            if (
              detail.id === "last_opened_date" &&
              detail.details?.last_opened_date
            ) {
              dates.last_opened_date = detail.details.last_opened_date;
            }
            if (detail.id === "tags" && detail.details?.tags) {
              simplified.tags = detail.details.tags;
            }
            // Добавление информации о создателе
            if (detail.id === "created_by" && detail.details?.details) {
              created_by = {
                name: detail.details.details.name,
                identity: detail.details.details.identity,
                role: detail.details.details.role,
              };
            }
          });
    
          if (Object.keys(dates).length > 0) {
            simplified.dates = dates;
          }
    
          if (created_by) {
            simplified.created_by = created_by;
          }
        }
    
        return simplified;
      });
    
      // Return the filtered data with the same structure
      return {
        data: filteredObjects,
        pagination: data.pagination,
      };
    }
  • Utility helper used by the handler to perform authenticated HTTP requests to the Anytype API using axios.
    private async makeRequest(
      method: "get" | "post" | "delete",
      endpoint: string,
      data?: any,
      params?: any
    ) {
      try {
        const config = {
          method,
          url: `${this.apiBaseUrl}${endpoint}`,
          headers: {
            Authorization: `Bearer ${this.appKey}`,
            "Content-Type": "application/json",
          },
          data,
          params,
        };
    
        return await axios(config);
      } catch (error) {
        console.error(`API request error: ${error}`);
        throw error;
      }
    }
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions the search scope and filtering/sorting options but lacks critical behavioral information: it doesn't mention pagination behavior (though offset/limit parameters exist), rate limits, authentication requirements, performance characteristics, or what happens when no results are found. The description is insufficient for a tool with 7 parameters and no annotation coverage.

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 communicates the core functionality. It's appropriately sized for the tool's complexity and gets straight to the point without unnecessary verbiage. However, it could be more front-loaded with critical behavioral information given the lack of annotations.

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?

For a search tool with 7 parameters, no annotations, and no output schema, the description is incomplete. It doesn't explain what the search returns (objects, metadata, content snippets), how results are structured, or important behavioral aspects like pagination, rate limits, or error conditions. The mention of 'include_text' parameter with 'USE WITH CAUTION' in the schema suggests performance implications that should be addressed in the description.

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?

The description mentions 'filtering by type and sorting' which corresponds to the 'types', 'sort_property', and 'sort_direction' parameters. However, with 100% schema description coverage, all parameters are already documented in the schema. The description adds minimal value beyond what's in the structured schema - it doesn't explain parameter interactions, provide examples, or clarify edge cases.

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 across all spaces the user has access to, with options for filtering by type and sorting.' It specifies the verb ('executes a search'), resource ('all spaces the user has access to'), and scope ('filtering by type and sorting'). However, it doesn't explicitly differentiate from its sibling 'search_space', which appears to be a more targeted search tool.

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 the sibling tool 'search_space' or explain when a global search is preferred over a space-specific search. There's no discussion of prerequisites, performance considerations, or use case scenarios.

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