Skip to main content
Glama

meta_exchange_token

Exchange a short-lived access token for a long-lived token valid for about 60 days. Requires Meta App ID and App Secret to extend token lifespan.

Instructions

Exchange a short-lived token for a long-lived token (valid ~60 days). Requires META_APP_ID and META_APP_SECRET.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
short_lived_tokenYesShort-lived access token to exchange

Implementation Reference

  • Handler function that defines the meta_exchange_token tool. Calls client.exchangeToken() with the short_lived_token input and returns the result as JSON.
    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 };
        }
      }
    );
  • Zod schema definition for the meta_exchange_token tool input: requires a short_lived_token string.
    {
      short_lived_token: z.string().describe("Short-lived access token to exchange"),
    },
  • Helper method MetaClient.exchangeToken() that makes the actual HTTP GET request to Facebook's /oauth/access_token endpoint with grant_type=fb_exchange_token to exchange a short-lived token for a long-lived one.
    async exchangeToken(shortToken: string): Promise<ClientResponse> {
      if (!this.config.appId || !this.config.appSecret) {
        throw new Error("META_APP_ID and META_APP_SECRET are required for token exchange.");
      }
      return this.request(IG_BASE, shortToken, "GET", "/oauth/access_token", {
        grant_type: "fb_exchange_token",
        client_id: this.config.appId,
        client_secret: this.config.appSecret,
        fb_exchange_token: shortToken,
      });
    }
  • src/index.ts:41-41 (registration)
    Registration call: registerMetaAuthTools(server, client) registers all Meta auth tools including meta_exchange_token on the MCP server.
    registerMetaAuthTools(server, client);
  • Export function registerMetaAuthTools that registers all Meta auth tools (including meta_exchange_token) onto the McpServer instance.
    export function registerMetaAuthTools(server: McpServer, client: MetaClient): void {
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are present, so the description fully bears the burden. It discloses token validity and required credentials but does not detail side effects, rate limits, or what happens to the old token. The information is minimal for a token exchange operation.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Two sentences convey the action, validity, and prerequisites with no extraneous words. The structure is front-loaded with the core verb and resource.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a simple token exchange with one parameter and no output schema, the description covers the essential purpose and a key setting (validity). However, it omits what the tool returns (presumably the long-lived token) and any preconditions or side effects, leaving some gaps.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema covers the sole parameter with a description, achieving 100% coverage. The description adds context about required app credentials (not in schema) but does not enhance understanding of the parameter beyond schema. Baseline 3 is appropriate.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description explicitly states the action (exchange a short-lived token for a long-lived token) and includes key details like token validity (~60 days) and required credentials. However, it does not differentiate itself from the sibling meta_refresh_token, leaving potential ambiguity.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage context by mentioning required META_APP_ID and META_APP_SECRET, but it lacks explicit guidance on when to use versus alternatives like meta_refresh_token. No when-not-to-use criteria are provided.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/mikusnuz/meta-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server