Skip to main content
Glama
getJwt.ts950 B
import { randomUUID } from 'node:crypto'; import { JWTHeaderParameters, JWTPayload, SignJWT } from 'jose'; export async function getJwt({ username, connectedApp, scopes, additionalPayload, }: { username: string; connectedApp: { clientId: string; secretId: string; secretValue: string; }; scopes: Set<string>; additionalPayload?: Record<string, unknown>; }): Promise<string> { const header: JWTHeaderParameters = { alg: 'HS256', typ: 'JWT', kid: connectedApp.secretId, }; const payload: JWTPayload = { jti: randomUUID(), iss: connectedApp.clientId, aud: 'tableau', sub: username, scp: [...scopes], iat: Math.floor(Date.now() / 1000) - 5, exp: Math.floor(Date.now() / 1000) + 5 * 60, ...additionalPayload, }; const token = await new SignJWT(payload) .setProtectedHeader(header) .sign(new TextEncoder().encode(connectedApp.secretValue)); return token; }

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/datalabs89/tableau-mcp'

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