meta_debug_token
Inspect an access token to validate its structure, check expiration status, review granted permissions, and identify the associated user account.
Instructions
Debug/inspect an access token to check validity, expiration, scopes and associated user.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| input_token | Yes | Access token to inspect |
Implementation Reference
- src/tools/meta/auth.ts:41-55 (handler)Tool handler for 'meta_debug_token' - calls client.debugToken() and returns result as JSON text, or an error message on failure.
server.tool( "meta_debug_token", "Debug/inspect an access token to check validity, expiration, scopes and associated user.", { input_token: z.string().describe("Access token to inspect"), }, async ({ input_token }) => { try { const { data, rateLimit } = await client.debugToken(input_token); return { content: [{ type: "text", text: JSON.stringify({ ...data as object, _rateLimit: rateLimit }, null, 2) }] }; } catch (error) { return { content: [{ type: "text", text: `Token debug failed: ${error instanceof Error ? error.message : String(error)}` }], isError: true }; } } ); - src/tools/meta/auth.ts:44-46 (schema)Zod schema for the tool: requires 'input_token' (string) which is the access token to inspect.
{ input_token: z.string().describe("Access token to inspect"), }, - src/tools/meta/auth.ts:5-41 (registration)The 'registerMetaAuthTools' function registers the tool via server.tool(). Called from src/index.ts line 41.
export function registerMetaAuthTools(server: McpServer, client: MetaClient): void { // ─── meta_exchange_token ───────────────────────────────────── server.tool( "meta_exchange_token", "Exchange a short-lived token for a long-lived token (valid ~60 days). Requires META_APP_ID and META_APP_SECRET.", { short_lived_token: z.string().describe("Short-lived access token to exchange"), }, async ({ short_lived_token }) => { try { const { data, rateLimit } = await client.exchangeToken(short_lived_token); return { content: [{ type: "text", text: JSON.stringify({ ...data as object, _rateLimit: rateLimit }, null, 2) }] }; } catch (error) { return { content: [{ type: "text", text: `Token exchange failed: ${error instanceof Error ? error.message : String(error)}` }], isError: true }; } } ); // ─── meta_refresh_token ────────────────────────────────────── server.tool( "meta_refresh_token", "Refresh a long-lived token before it expires. Returns a new long-lived token.", { long_lived_token: z.string().describe("Current long-lived access token to refresh"), }, async ({ long_lived_token }) => { try { const { data, rateLimit } = await client.refreshToken(long_lived_token); return { content: [{ type: "text", text: JSON.stringify({ ...data as object, _rateLimit: rateLimit }, null, 2) }] }; } catch (error) { return { content: [{ type: "text", text: `Token refresh failed: ${error instanceof Error ? error.message : String(error)}` }], isError: true }; } } ); // ─── meta_debug_token ──────────────────────────────────────── server.tool( - src/services/meta-client.ts:130-139 (helper)MetaClient.debugToken() - calls the Meta Graph API /debug_token endpoint with an app access token to inspect the given input token.
/** Debug a token */ 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}`; return this.request(IG_BASE, appToken, "GET", "/debug_token", { input_token: inputToken, }); }