Skip to main content
Glama

check-session

Confirm that your Garmin Connect session is still valid after logging in. This verification step ensures authentication and continued data access.

Instructions

Check if the saved Garmin Connect session is still valid. MUST be called after garmin-login to verify authentication worked.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The handler function for the 'check-session' tool. It checks if a saved Garmin Connect session exists, and if so, tests it by calling the userprofile API. On success returns {status:'ok', profile}. On failure resets the shared client and returns an error.
    server.tool(
      "check-session",
      "Check if the saved Garmin Connect session is still valid. MUST be called after garmin-login to verify authentication worked.",
      {},
      async () => {
        if (!sessionExists()) {
          return errorResult(
            "No session file found. Call the garmin-login tool for instructions."
          );
        }
        try {
          const client = getClient();
          const profile = await client.get(
            "userprofile-service/userprofile/user-settings/"
          );
          return jsonResult({ status: "ok", profile });
        } catch (e) {
          const msg = e instanceof Error ? e.message : String(e);
          // Reset the singleton so the next attempt re-reads the session file
          await resetSharedClient();
          return errorResult(
            `Session invalid or expired: ${msg}\nCall the garmin-login tool to re-authenticate.`
          );
        }
      }
    );
  • src/index.ts:7-41 (registration)
    Registration via registerTools(server) which calls the registration function in tools.ts that registers all tools including 'check-session' via server.tool().
    async function startMcpServer(): Promise<void> {
      const server = new McpServer({
        name: "garmin-connect-mcp",
        version: "0.1.0",
      });
    
      registerTools(server);
      registerResources(server);
    
      const transport = new StdioServerTransport();
      await server.connect(transport);
      console.error("garmin-connect-mcp server running on stdio");
    }
    
    async function main(): Promise<void> {
      const command = process.argv[2];
    
      if (command === "login") {
        const { runLogin } = await import("./auth.js");
        await runLogin();
      } else {
        await startMcpServer();
      }
    }
    
    main().catch((err) => {
      console.error("Fatal error:", err);
      process.exit(1);
    });
  • getClient() helper called inside check-session handler; uses sessionExists() to check for session file and returns the shared client via getSharedClient().
    function getClient() {
      if (!sessionExists()) {
        throw new Error(
          "No Garmin session found. The user needs to run: npx garmin-connect-mcp login"
        );
      }
      return getSharedClient();
    }
  • sessionExists() helper that checks if the session.json file exists on disk. Used by the check-session handler to determine if there is a saved session.
    export function sessionExists(): boolean {
      return existsSync(SESSION_FILE);
    }
Behavior4/5

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

The description correctly implies a non-destructive read operation (checking session validity). Since annotations are absent, the description adequately conveys the tool's behavior without contradictions.

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?

The description is two sentences long, front-loading the purpose and usage. Every word is necessary and earns its place.

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

Completeness5/5

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

Given the tool's simplicity (no parameters, no output schema), the description fully covers what the agent needs to know: what it does, when to call it, and its relation to garmin-login.

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

Parameters5/5

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

The input schema has no parameters (100% coverage by default). The description does not need to add parameter information, as none exist.

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

Purpose5/5

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

Clearly states the tool checks if the saved Garmin Connect session is valid. It uses a specific verb and resource and distinguishes itself from siblings by requiring it to be called after garmin-login.

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

Usage Guidelines4/5

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

Explicitly states it must be called after garmin-login to verify authentication, providing clear usage context. However, it does not mention when not to use it or provide alternatives, though this is sufficient for a simple check tool.

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/etweisberg/garmin-connect-mcp'

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