Skip to main content
Glama
search.ts1.75 kB
import { z } from 'zod'; import { Context, ToolParameters, UserError, Tool } from 'fastmcp'; import { getClient } from '@utils/client'; import type { SearchOptions } from '@watercrawl/nodejs/dist/types'; interface SearchArgs { query: string; searchOptions?: SearchOptions; resultLimit?: number; } const search = async (args: SearchArgs | any, { session }: Context<any>) => { const client = getClient(session?.apiKey); try { const results = await client.createSearchRequest( args.query, args.searchOptions || {}, args.resultLimit || 5, true, true, ); return JSON.stringify(results); } catch (e) { throw new UserError(String(e)); } }; const parameters = z.object({ query: z.string().describe('Search query'), searchOptions: z .object({ language: z.string().nullable().optional().describe("Language code (e.g., 'en', 'fr')"), country: z.string().nullable().optional().describe("Country code (e.g., 'us', 'fr')"), time_range: z .enum(['any', 'hour', 'day', 'week', 'month', 'year']) .optional() .describe('Time range for search results'), search_type: z.enum(['web']).optional().default('web').describe('Type of search'), depth: z.enum(['basic', 'advanced', 'ultimate']).optional().describe('Search depth level'), }) .optional() .describe('Search configuration options'), resultLimit: z.number().optional().default(5).describe('Maximum number of results to return'), }); export const SearchTool: Tool<any, ToolParameters> = { name: 'search', description: 'Search for information using configurable options for language, country, time range, and depth', parameters: parameters, execute: search, };

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/watercrawl/watercrawl-mcp'

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