Skip to main content
Glama
mohdhaji87

JWT Auditor MCP Server

by mohdhaji87

jwt_decode

Decode JWT tokens to inspect header, payload, and signature components without verification for security auditing and analysis.

Instructions

Decode a JWT and return its header, payload, and signature (no verification).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
tokenYes

Implementation Reference

  • server.py:9-29 (handler)
    The jwt_decode tool handler function. It is registered via the @server.tool() decorator. The function splits the JWT token into header, payload, and signature parts, base64 decodes the header and payload (handling padding), parses them as JSON, and returns a dict with header, payload, and raw signature. Errors are caught and returned as {"error": str(e)}.
    @server.tool()
    def jwt_decode(token: str) -> dict:
        """Decode a JWT and return its header, payload, and signature (no verification)."""
        try:
            header_b64, payload_b64, signature_b64 = token.split(".")
            def b64decode(data):
                # Add padding if needed
                rem = len(data) % 4
                if rem:
                    data += '=' * (4 - rem)
                return base64.urlsafe_b64decode(data.encode())
            header = json.loads(b64decode(header_b64))
            payload = json.loads(b64decode(payload_b64))
            signature = signature_b64
            return {
                "header": header,
                "payload": payload,
                "signature": signature
            }
        except Exception as e:
            return {"error": str(e)}

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/mohdhaji87/JWTAuditorMCP'

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