debug_token
Debug a Meta access token to verify its properties, permissions, expiration, and validity. Requires app ID and secret.
Instructions
Debug an access token to inspect its properties, permissions, expiration, and validity. Requires META_APP_ID and META_APP_SECRET.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| input_token | Yes | Access token to debug/inspect |
Implementation Reference
- src/services/ads-client.ts:296-320 (handler)Implementation of the debugToken method on AdsClient. Calls Meta's /debug_token endpoint with an app access token (appId|appSecret) to inspect the provided input_token. Returns the JSON response with token properties, permissions, expiration, and validity.
async debugToken(inputToken: string): Promise<ClientResponse> { if (!this.config.appId || !this.config.appSecret) { throw new Error( "META_APP_ID and META_APP_SECRET are required for token debug." ); } const appToken = `${this.config.appId}|${this.config.appSecret}`; const qs = new URLSearchParams({ input_token: inputToken, access_token: appToken, }); const url = `${this.baseUrl}/debug_token?${qs.toString()}`; const res = await fetch(url, { signal: AbortSignal.timeout(30_000) }); if (!res.ok) { const text = await res.text().catch(() => ""); throw new Error(`Token debug failed (${res.status}): ${text}`); } const data = await res.json(); if (data.error) { throw new Error(this.formatError(data)); } return { data }; } - src/tools/auth.ts:44-46 (schema)Zod schema for the debug_token tool: requires 'input_token' as a string. No additional validation or output schema defined.
{ input_token: z.string().describe("Access token to debug/inspect"), }, - src/tools/auth.ts:40-56 (registration)Registration of the 'debug_token' tool using server.tool() in the registerAuthTools function. The tool handler extracts input_token, calls client.debugToken(), and returns the data as formatted JSON text.
// ─── debug_token ────────────────────────────────────────────── server.tool( "debug_token", "Debug an access token to inspect its properties, permissions, expiration, and validity. Requires META_APP_ID and META_APP_SECRET.", { input_token: z.string().describe("Access token to debug/inspect"), }, async ({ input_token }) => { try { const { data } = await client.debugToken(input_token); return { content: [{ type: "text" as const, text: JSON.stringify(data, null, 2) }] }; } catch (error) { return { content: [{ type: "text" as const, text: `Failed: ${error instanceof Error ? error.message : String(error)}` }], isError: true }; } } ); } - src/index.ts:93-93 (registration)Call to registerAuthTools(server, client) which wires up the debug_token tool into the MCP server.
registerAuthTools(server, client);