Skip to main content
Glama

Search Documents

search_docs

Enables quick document search within AFFiNE workspaces by keyword, helping users locate relevant content efficiently. Supports filtering by workspace ID and result limits for focused queries.

Instructions

Search documents in a workspace.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
keywordYes
limitNo
workspaceIdNo

Implementation Reference

  • Handler function that executes the search_docs tool by querying the GraphQL API for documents matching the keyword in the specified workspace.
    const searchDocsHandler = async (parsed: { workspaceId?: string; keyword: string; limit?: number }) => {
        try {
          const workspaceId = parsed.workspaceId || defaults.workspaceId;
        if (!workspaceId) {
          throw new Error("workspaceId is required. Provide it as a parameter or set AFFINE_WORKSPACE_ID in environment.");
        }
          const query = `query SearchDocs($workspaceId:String!, $keyword:String!, $limit:Int){ workspace(id:$workspaceId){ searchDocs(input:{ keyword:$keyword, limit:$limit }){ docId title highlight createdAt updatedAt } } }`;
          const data = await gql.request<{ workspace: any }>(query, { workspaceId, keyword: parsed.keyword, limit: parsed.limit });
          return text(data.workspace?.searchDocs || []);
        } catch (error: any) {
          // Return empty array on error (search might not be available)
          console.error("Search docs error:", error.message);
          return text([]);
        }
      };
  • Registers the search_docs MCP tool with its schema and handler reference.
    server.registerTool(
      "search_docs",
      {
        title: "Search Documents",
        description: "Search documents in a workspace.",
        inputSchema: {
          workspaceId: z.string().optional(),
          keyword: z.string().min(1),
          limit: z.number().optional()
        }
      },
      searchDocsHandler as any
    );
  • Zod input schema defining parameters for the search_docs tool: optional workspaceId, required keyword, optional limit.
    inputSchema: {
      workspaceId: z.string().optional(),
      keyword: z.string().min(1),
      limit: z.number().optional()
    }
Behavior2/5

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

With no annotations, the description carries full burden but only states the basic action. It doesn't disclose behavioral traits like whether the search is case-sensitive, supports pagination, returns partial matches, or has rate limits. For a search tool with zero annotation coverage, this is a significant gap in transparency.

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 with no wasted words, making it front-loaded and easy to parse. However, it's overly concise to the point of under-specification, slightly reducing its effectiveness.

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 3 parameters, 0% schema coverage, no annotations, and no output schema, the description is incomplete. It doesn't cover parameter meanings, behavioral context, or return values, leaving the agent with insufficient information to use the tool effectively.

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

Parameters2/5

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

Schema description coverage is 0%, so the description must compensate but adds no parameter details. It doesn't explain what 'keyword' searches (e.g., title, content), what 'limit' defaults to, or how 'workspaceId' is used. With 3 parameters and low schema coverage, the description fails to provide meaningful semantics.

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

Purpose3/5

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

The description 'Search documents in a workspace' clearly states the verb ('search') and resource ('documents'), but it's vague about scope (e.g., full-text vs. metadata) and doesn't distinguish from sibling tools like 'list_docs' or 'get_doc'. It avoids tautology but lacks specificity.

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?

No guidance is provided on when to use this tool versus alternatives such as 'list_docs' (which might list without search) or 'get_doc' (for retrieving a specific document). The description implies a search context but offers no explicit when/when-not rules or prerequisites.

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

Related 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/DAWNCR0W/affine-mcp-server'

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