Skip to main content
Glama
kongyo2

eve-online-mcp

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
NameRequiredDescriptionDefault
refresh_tokenYesRefresh token from previous authentication

Implementation Reference

  • 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'}`
            }
          ]
        };
      }
    }
  • 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'}`
              }
            ]
          };
        }
      }
    );
  • 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()
      };
    }
Install Server

Other Tools

Related 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/kongyo2/eve-online-mcp'

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