meta_refresh_token
Refresh your Meta long-lived access token before it expires to obtain a new valid token, ensuring uninterrupted API access.
Instructions
Refresh a long-lived token before it expires. Returns a new long-lived token.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| long_lived_token | Yes | Current long-lived access token to refresh |
Implementation Reference
- src/tools/meta/auth.ts:23-38 (handler)The MCP tool handler for 'meta_refresh_token'. It accepts a 'long_lived_token' string, calls client.refreshToken(), and returns the result as JSON text content.
// ─── 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 }; } } ); - src/tools/meta/auth.ts:27-29 (schema)Input schema for meta_refresh_token: requires a single string parameter 'long_lived_token' described as 'Current long-lived access token to refresh'.
{ long_lived_token: z.string().describe("Current long-lived access token to refresh"), }, - src/tools/meta/auth.ts:24-25 (registration)Registration of the tool on the MCP server via server.tool('meta_refresh_token', ...).
server.tool( "meta_refresh_token", - src/services/meta-client.ts:123-128 (helper)The MetaClient.refreshToken() helper method that performs the actual API call to refresh a long-lived token via GET /oauth/access_token with grant_type=fb_exchange_token.
/** Refresh a long-lived token */ async refreshToken(longToken: string): Promise<ClientResponse> { return this.request(IG_BASE, longToken, "GET", "/oauth/access_token", { grant_type: "fb_exchange_token", }); } - src/index.ts:9-9 (registration)Import of registerMetaAuthTools which registers meta_refresh_token along with other Meta auth tools.
import { registerMetaAuthTools } from "./tools/meta/auth.js";