autocomplete
Generate instant autocomplete suggestions for partial text queries across fields like company, school, title, skill, and location to enhance search precision and efficiency.
Instructions
Get autocomplete suggestions for a partial query
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| field | Yes | Field to autocomplete (company, school, title, skill, location) | |
| size | No | Number of results to return (max 100) | |
| text | Yes | Partial text to autocomplete |
Implementation Reference
- src/index.ts:568-592 (handler)The handler function for the 'autocomplete' tool. Validates required parameters (field and text), calls the People Data Labs /autocomplete API endpoint, and returns the JSON response as text content.private async handleAutocomplete(args: any) { if (!args || typeof args !== 'object' || !args.field || !args.text) { throw new McpError( ErrorCode.InvalidParams, 'Invalid autocomplete parameters. Must provide field and text.' ); } const params: Record<string, any> = { field: args.field, text: args.text, size: args.size || 10, }; const response = await pdlApi.get('/autocomplete', { params }); return { content: [ { type: 'text', text: JSON.stringify(response.data, null, 2), }, ], }; }
- src/index.ts:365-388 (registration)Registers the 'autocomplete' tool in the ListTools response, including its name, description, and input schema definition.name: 'autocomplete', description: 'Get autocomplete suggestions for a partial query', inputSchema: { type: 'object', properties: { field: { type: 'string', description: 'Field to autocomplete (company, school, title, skill, location)', enum: ['company', 'school', 'title', 'skill', 'location'], }, text: { type: 'string', description: 'Partial text to autocomplete', }, size: { type: 'number', description: 'Number of results to return (max 100)', minimum: 1, maximum: 100, }, }, required: ['field', 'text'], }, },
- src/index.ts:426-427 (registration)In the CallTool request handler switch statement, routes calls to the 'autocomplete' tool to its handler method.case 'autocomplete': return await this.handleAutocomplete(request.params.arguments);
- src/index.ts:368-387 (schema)JSON schema defining the input parameters for the 'autocomplete' tool: required field (enum) and text, optional size.type: 'object', properties: { field: { type: 'string', description: 'Field to autocomplete (company, school, title, skill, location)', enum: ['company', 'school', 'title', 'skill', 'location'], }, text: { type: 'string', description: 'Partial text to autocomplete', }, size: { type: 'number', description: 'Number of results to return (max 100)', minimum: 1, maximum: 100, }, }, required: ['field', 'text'], },