Skip to main content
Glama
paladini

devutils-mcp-server

jwt_validate

Validate JWT structure by checking format, Base64URL encoding, JSON validity, and expiration status without cryptographic signature verification.

Instructions

Validate the structure of a JWT. Checks format, Base64URL encoding, JSON validity, and expiration status. Does NOT verify the cryptographic signature.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
tokenYesThe JWT string to validate

Implementation Reference

  • Implementation of the jwt_validate tool handler, which performs structural validation on a JWT, including checking its format, Base64URL encoding, JSON validity, and expiration, without verifying the signature.
    server.tool(
      "jwt_validate",
      "Validate the structure of a JWT. Checks format, Base64URL encoding, JSON validity, and expiration status. Does NOT verify the cryptographic signature.",
      { token: z.string().describe("The JWT string to validate") },
      async ({ token }) => {
        const issues: string[] = [];
        const checks: Record<string, boolean> = {};
    
        const parts = token.split(".");
        checks["has_three_parts"] = parts.length === 3;
    
        if (parts.length !== 3) {
          issues.push(`Expected 3 parts, got ${parts.length}`);
          return {
            content: [
              {
                type: "text" as const,
                text: JSON.stringify({ valid: false, checks, issues }, null, 2),
              },
            ],
          };
        }
    
        const decodeBase64Url = (str: string): string => {
          const base64 = str.replace(/-/g, "+").replace(/_/g, "/");
          const padded = base64 + "=".repeat((4 - (base64.length % 4)) % 4);
          return Buffer.from(padded, "base64").toString("utf-8");
        };
    
        // Check header
        try {
          const header = JSON.parse(decodeBase64Url(parts[0]));
          checks["valid_header_json"] = true;
          checks["has_alg"] = "alg" in header;
          if (!("alg" in header)) issues.push("Header missing 'alg' field");
        } catch {
          checks["valid_header_json"] = false;
          issues.push("Header is not valid Base64URL-encoded JSON");
        }
    
        // Check payload
        try {
          const payload = JSON.parse(decodeBase64Url(parts[1]));
          checks["valid_payload_json"] = true;
    
          // Check expiration
          if (payload.exp) {
            const now = Math.floor(Date.now() / 1000);
            checks["not_expired"] = payload.exp > now;
            if (payload.exp <= now) {
              issues.push(
                `Token expired at ${new Date(payload.exp * 1000).toISOString()}`
              );
            }
          }
        } catch {
          checks["valid_payload_json"] = false;
          issues.push("Payload is not valid Base64URL-encoded JSON");
        }
    
        // Check signature exists
        checks["has_signature"] = parts[2].length > 0;
        if (parts[2].length === 0) issues.push("Signature is empty");
    
        const valid = issues.length === 0;
    
        return {
          content: [
            {
              type: "text" as const,
              text: JSON.stringify({ valid, checks, issues }, null, 2),
            },
          ],
        };
      }
    );
Behavior5/5

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

No annotations provided, yet description fully discloses behavioral traits: enumerates exact checks performed (format, Base64URL encoding, JSON validity, expiration status) and explicitly states security limitations. No 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?

Three sentences with zero waste: purpose → specific checks → critical limitation. Front-loaded with the main action, structured logically, and avoids redundancy with schema.

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?

Comprehensive for a single-parameter validation utility. Captures all necessary behavioral context (scope, limitations, specific validations). Minor gap: does not hint at return value structure (pass/fail object vs boolean), though this is acceptable without an output schema.

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 coverage is 100% ('The JWT string to validate'), establishing baseline 3. Description does not add parameter-specific guidance (e.g., expected JWT format details, string length constraints) beyond the schema, but this is acceptable given the high schema coverage.

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?

Specific verb 'Validate' + resource 'structure of a JWT' clearly defines scope. Explicitly distinguishes from cryptographic verification and implicitly from sibling jwt_decode by emphasizing structural checks (format, encoding, expiration) rather than decoding or signature validation.

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 explicit when-NOT guidance ('Does NOT verify the cryptographic signature'), which is critical for JWT tools where signature verification is commonly expected. However, does not explicitly name jwt_decode as the alternative for pure decoding, or suggest what tool to use for signature verification.

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