Skip to main content
Glama
paladini

devutils-mcp-server

jwt_decode

Decode JWT tokens to inspect header and payload data for debugging purposes without verifying signatures.

Instructions

Decode a JWT (JSON Web Token) and display its header and payload without verifying the signature. Useful for debugging and inspecting tokens.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
tokenYesThe JWT string to decode

Implementation Reference

  • The handler implementation for the jwt_decode tool, which performs base64url decoding and JSON parsing of the JWT components.
    server.tool(
      "jwt_decode",
      "Decode a JWT (JSON Web Token) and display its header and payload without verifying the signature. Useful for debugging and inspecting tokens.",
      { token: z.string().describe("The JWT string to decode") },
      async ({ token }) => {
        try {
          const parts = token.split(".");
          if (parts.length !== 3) {
            return {
              content: [
                {
                  type: "text" as const,
                  text: "Error: Invalid JWT format. A JWT must have 3 parts separated by dots (header.payload.signature).",
                },
              ],
              isError: true,
            };
          }
    
          const decodeBase64Url = (str: string): string => {
            // Replace URL-safe characters and add padding
            const base64 = str.replace(/-/g, "+").replace(/_/g, "/");
            const padded = base64 + "=".repeat((4 - (base64.length % 4)) % 4);
            return Buffer.from(padded, "base64").toString("utf-8");
          };
    
          const header = JSON.parse(decodeBase64Url(parts[0]));
          const payload = JSON.parse(decodeBase64Url(parts[1]));
    
          // Enrich payload with human-readable dates
          const enriched = { ...payload };
          if (enriched.iat) enriched.iat_readable = new Date(enriched.iat * 1000).toISOString();
          if (enriched.exp) enriched.exp_readable = new Date(enriched.exp * 1000).toISOString();
          if (enriched.nbf) enriched.nbf_readable = new Date(enriched.nbf * 1000).toISOString();
    
          const result = {
            header,
            payload: enriched,
            signature: parts[2],
          };
    
          return {
            content: [
              { type: "text" as const, text: JSON.stringify(result, null, 2) },
            ],
          };
        } catch (e) {
          return {
            content: [
              {
                type: "text" as const,
                text: `Error decoding JWT: ${e instanceof Error ? e.message : String(e)}`,
              },
            ],
            isError: true,
          };
        }
      }
    );
Behavior4/5

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

With no annotations provided, the description carries the full burden. It successfully discloses the critical security limitation (signature not verified) and what content is extracted (header and payload). Minor gap: doesn't describe the output format or structure.

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, zero waste. First sentence delivers action, scope, and security-critical limitation. Second sentence provides use-case context. Front-loaded with essential technical constraints immediately.

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

Completeness4/5

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

For a single-parameter inspection tool without output schema, the description adequately covers functionality and safety constraints. Agent understands the tool reads tokens and does not perform cryptographic validation. Minor gap regarding output structure keeps this from a 5.

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?

Schema has 100% description coverage ('The JWT string to decode'), providing complete param documentation. The description implies the token format but doesn't add validation rules, format examples, or semantic constraints beyond what the schema already states. Baseline 3 is appropriate when schema coverage is complete.

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?

The description uses specific verb 'Decode' with resource 'JWT' and explicitly scopes the functionality to 'display its header and payload without verifying the signature.' This clearly distinguishes it from sibling tool jwt_validate by highlighting the lack of signature verification.

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?

Provides clear context with 'Useful for debugging and inspecting tokens' indicating when to use. The phrase 'without verifying the signature' implicitly warns against using this for security validation, suggesting jwt_validate as the alternative, though it doesn't explicitly name that sibling 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/paladini/devutils-mcp-server'

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