refresh-token
Renew expired access tokens for EVE Online's MCP server using a valid refresh token, ensuring continued access to real-time market data via the ESI API.
Instructions
Refresh an expired access token
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| refresh_token | Yes | Refresh token from previous authentication |
Implementation Reference
- src/index.ts:536-562 (handler)Handler function for the refresh-token tool. It calls the refreshToken helper with the provided refresh_token, formats the new token data, and returns it as text content. Handles errors by returning an error message.async ({ refresh_token }) => { try { const token = await refreshToken(refresh_token); return { content: [ { type: "text", text: JSON.stringify({ access_token: token.access_token, refresh_token: token.refresh_token, expires_in: token.expires_in, token_type: token.token_type }, null, 2) } ] }; } catch (error) { return { content: [ { type: "text", text: `Token refresh failed: ${error instanceof Error ? error.message : 'Unknown error'}` } ] }; } }
- src/index.ts:533-535 (schema)Zod input schema for the refresh-token tool defining the required refresh_token string parameter.{ refresh_token: z.string().describe("Refresh token from previous authentication") },
- src/index.ts:530-563 (registration)Registration of the refresh-token tool on the MCP server using server.tool(). Includes tool name, description, schema, and handler.server.tool( "refresh-token", "Refresh an expired access token", { refresh_token: z.string().describe("Refresh token from previous authentication") }, async ({ refresh_token }) => { try { const token = await refreshToken(refresh_token); return { content: [ { type: "text", text: JSON.stringify({ access_token: token.access_token, refresh_token: token.refresh_token, expires_in: token.expires_in, token_type: token.token_type }, null, 2) } ] }; } catch (error) { return { content: [ { type: "text", text: `Token refresh failed: ${error instanceof Error ? error.message : 'Unknown error'}` } ] }; } } );
- src/index.ts:152-174 (helper)Supporting helper function refreshToken that performs the HTTP POST request to EVE Online SSO OAuth endpoint to exchange refresh_token for new access_token and refresh_token.async function refreshToken(refresh_token: string): Promise<EveAuthToken> { const response = await fetch("https://login.eveonline.com/v2/oauth/token", { method: "POST", headers: { "Content-Type": "application/x-www-form-urlencoded", "Authorization": `Basic ${Buffer.from(`${EVE_CLIENT_ID}:${EVE_CLIENT_SECRET}`).toString("base64")}` }, body: new URLSearchParams({ grant_type: "refresh_token", refresh_token: refresh_token }) }); if (!response.ok) { throw new Error("Failed to refresh token"); } const data = await response.json() as EveAuthToken; return { ...data, issued_at: Date.now() }; }