validate_key
Verify the validity of a WolframAlpha LLM API key to ensure secure and authorized access for querying natural language questions.
Instructions
Validate the WolframAlpha LLM API key
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools/index.ts:135-143 (handler)The 'validate_key' tool handler function. It calls wolframLLMService.validateApiKey() and returns a text response indicating if the API key is valid or invalid.handler: async (_args: EmptyArgs): Promise<ToolResponse> => { const isValid = await wolframLLMService.validateApiKey(); return { content: [{ type: "text", text: isValid ? "API key is valid" : "API key is invalid" }] }; }
- src/services/wolfram-llm.ts:368-383 (helper)The core helper method in WolframLLMService class that validates the API key by making a test query to '2+2' and checking the response format.async validateApiKey(): Promise<boolean> { try { const params = new URLSearchParams({ appid: this.config.appId, input: '2+2' }); const response = await axios.get(`${this.baseUrl}?${params.toString()}`); return typeof response.data === 'string' && response.data.includes('Result:'); } catch (error) { if (axios.isAxiosError(error) && error.response?.data) { console.error('API Key Validation Error Response:', error.response.data); } return false; } }
- src/index.ts:26-29 (registration)MCP server capabilities registration declaring the 'validate_key' tool as available.ask_llm: true, get_simple_answer: true, validate_key: true },
- src/index.ts:80-82 (registration)Specific handling in the MCP CallToolRequestSchema handler for the 'validate_key' tool, invoking it with empty args.if (tool.name === 'validate_key') { response = await (tool as Tool<EmptyArgs>).handler({}); } else {
- src/tools/index.ts:130-134 (schema)Input schema for the 'validate_key' tool, which requires no arguments.inputSchema: { type: "object", properties: {}, required: [] },