search_locations
Utilize SQL-like queries to find locations based on specific criteria, returning up to 100 results for targeted searches using data models from People Data Labs.
Instructions
Search for locations matching specific criteria
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | SQL-like query to search for locations | |
| size | No | Number of results to return (max 100) |
Implementation Reference
- src/index.ts:543-566 (handler)Core handler function implementing the search_locations tool logic. Validates input arguments, constructs API parameters with SQL query, calls People Data Labs /location/search endpoint, and returns JSON response.private async handleSearch(dataType: string, args: any) { if (!isValidSearchArgs(args)) { throw new McpError( ErrorCode.InvalidParams, `Invalid search parameters. Must provide a query string.` ); } const params: Record<string, any> = { sql: args.query, size: args.size || 10, }; const response = await pdlApi.get(`/${dataType}/search`, { params }); return { content: [ { type: 'text', text: JSON.stringify(response.data, null, 2), }, ], }; }
- src/index.ts:298-317 (schema)Input schema definition for the search_locations tool, specifying query (required) and optional size parameters.{ name: 'search_locations', description: 'Search for locations matching specific criteria', inputSchema: { type: 'object', properties: { query: { type: 'string', description: 'SQL-like query to search for locations', }, size: { type: 'number', description: 'Number of results to return (max 100)', minimum: 1, maximum: 100, }, }, required: ['query'], }, },
- src/index.ts:414-415 (registration)Registration and dispatch handler for search_locations tool in the CallToolRequestSchema switch statement, invoking handleSearch with 'location' dataType.case 'search_locations': return await this.handleSearch('location', request.params.arguments);
- src/index.ts:82-90 (helper)Helper validation function for search tool arguments, ensuring query is string and size is valid number (1-100), used by search_locations handler.const isValidSearchArgs = (args: any): args is { query: string; size?: number; } => { return typeof args === 'object' && args !== null && typeof args.query === 'string' && (args.size === undefined || (typeof args.size === 'number' && args.size > 0 && args.size <= 100)); };