classify_text
Predict research concepts and confidence scores from text titles or abstracts using OpenAlex's scholarly classification system.
Instructions
Classify arbitrary text to predict research concepts and confidence scores
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| title | No | Title text to classify | |
| abstract | No | Abstract text to classify | |
| mailto | No | Email for rate limits | |
| api_key | No | Premium API key |
Implementation Reference
- src/tools/classifyText.ts:3-18 (handler)The classifyText function implements the core logic of the 'classify_text' tool. It extracts title, abstract, and mailto from args, constructs params, calls makeOpenAlexRequest to the /text endpoint, and returns the JSON response formatted as MCP content.export async function classifyText(args: any) { const { title, abstract, mailto } = args; const params: Record<string, any> = {}; if (title) params.title = title; if (abstract) params.abstract = abstract; if (mailto) params.mailto = mailto; return { content: [{ type: "text", text: JSON.stringify(await makeOpenAlexRequest("/text", params), null, 2) }] }; }
- src/index.ts:245-253 (schema)Input schema for the classify_text tool, defining optional parameters: title, abstract, mailto, and api_key.inputSchema: { type: "object", properties: { title: { type: "string", description: "Title text to classify" }, abstract: { type: "string", description: "Abstract text to classify" }, mailto: { type: "string", description: "Email for rate limits" }, api_key: { type: "string", description: "Premium API key" } } }
- src/index.ts:242-254 (registration)Registration of the classify_text tool in the ListToolsRequestHandler response, providing name, description, and input schema.{ name: "classify_text", description: "Classify arbitrary text to predict research concepts and confidence scores", inputSchema: { type: "object", properties: { title: { type: "string", description: "Title text to classify" }, abstract: { type: "string", description: "Abstract text to classify" }, mailto: { type: "string", description: "Email for rate limits" }, api_key: { type: "string", description: "Premium API key" } } } },
- src/index.ts:299-300 (registration)Dispatch registration in the CallToolRequestHandler switch statement, mapping 'classify_text' to the classifyText handler function.case "classify_text": return await classifyText(args);
- src/index.ts:31-31 (registration)Import statement that brings the classifyText handler into the main index.ts for use in tool dispatch.import { classifyText } from "./tools/classifyText.js";