Skip to main content
Glama

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() }

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