autocomplete
Search OpenAlex's scholarly database to get instant suggestions for works, authors, institutions, journals, concepts, publishers, and funders as you type.
Instructions
Type ahead search across any OpenAlex entity type
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| search | Yes | Search query for autocomplete | |
| type | No | Entity type to search within | |
| per_page | No | Number of suggestions (max 50) | |
| mailto | No | Email for rate limits | |
| api_key | No | Premium API key |
Implementation Reference
- src/tools/autocomplete.ts:3-10 (handler)The primary handler function implementing the 'autocomplete' tool logic. It calls the shared makeOpenAlexRequest utility with the '/autocomplete' endpoint and args, then wraps the JSON response in the MCP content format.export async function autocomplete(args: any) { return { content: [{ type: "text", text: JSON.stringify(await makeOpenAlexRequest("/autocomplete", args), null, 2) }] }; }
- src/index.ts:224-241 (registration)Registration of the 'autocomplete' tool in the ListTools response, including name, description, and input schema.name: "autocomplete", description: "Type ahead search across any OpenAlex entity type", inputSchema: { type: "object", properties: { search: { type: "string", description: "Search query for autocomplete", required: true }, type: { type: "string", enum: ["works", "authors", "sources", "institutions", "concepts", "publishers", "funders"], description: "Entity type to search within" }, per_page: { type: "number", description: "Number of suggestions (max 50)" }, mailto: { type: "string", description: "Email for rate limits" }, api_key: { type: "string", description: "Premium API key" } }, required: ["search"] } },
- src/index.ts:297-298 (registration)Dispatch registration mapping the 'autocomplete' tool name to its handler function in the CallTool request handler switch statement.case "autocomplete": return await autocomplete(args);
- src/types.ts:468-476 (schema)TypeScript interface defining the structure of autocomplete results from OpenAlex API.export interface AutocompleteResult { id: string; display_name: string; hint?: string; cited_by_count?: number; works_count?: number; entity_type: string; external_id?: string; }
- src/utils.ts:22-22 (helper)Shared utility function used by the autocomplete handler (and others) to make HTTP requests to OpenAlex API endpoints.export async function makeOpenAlexRequest(endpoint: string, params: OpenAlexQueryParams = {}): Promise<any> {