check_token
Avoid authentication failures by validating the current API token before interacting with AnythingLLM workspaces and chat.
Instructions
Validate the current API token
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "check_token"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/index.ts:89-89 (handler)The handler for the 'system_check_token' tool. It calls the API endpoint /system/check-token via the apiRequest helper.
else if (name === "system_check_token") { result = await apiRequest("/system/check-token"); } - src/index.ts:66-66 (registration)Registration of the 'system_check_token' tool in the ListToolsRequestSchema handler, providing its name, description, and empty input schema.
{ name: "system_check_token", description: "Check API token", inputSchema: { type: "object", properties: {}, required: [] } }, - src/index.ts:23-55 (helper)The apiRequest helper function that performs HTTP/HTTPS requests to the AnythingLLM API, used by the check_token handler.
function apiRequest(path: string, method = "GET", body?: any, extraHeaders = {}): Promise<any> { return new Promise((resolve, reject) => { const baseUrl = new URL(ANYTHING_LLM_BASE); const fullUrl = new URL(path, baseUrl); const options: any = { hostname: fullUrl.hostname, port: fullUrl.port || (fullUrl.protocol === "https:" ? 443 : 80), path: fullUrl.pathname + fullUrl.search, method, headers: Object.assign({ "Authorization": "Bearer " + ANYTHING_LLM_API_KEY, "Content-Type": "application/json", "Accept": "application/json", }, extraHeaders), }; const lib = fullUrl.protocol === "https:" ? https : http; const req = lib.request(options, (res: any) => { let data = ""; res.on("data", (chunk: string) => { data += chunk; }); res.on("end", () => { try { resolve(data ? JSON.parse(data) : {}); } catch { resolve({ raw: data }); } }); }); req.on("error", reject); if (body) req.write(JSON.stringify(body)); req.end(); }); }