revoke_credential
Revoke a verifiable credential by updating its status in the W3C Status List 2021 bitstring, ensuring the credential is marked as invalid for future verification processes.
Instructions
Revoke a verifiable credential using W3C Status List 2021 specification. Updates the credential status in the bitstring status list.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| credentialId | Yes | ||
| reason | No | Reason for revocation | |
| statusListIndex | Yes |
Implementation Reference
- src/tools/revokeCredential.ts:8-76 (handler)The main handler function that implements the revoke_credential tool logic. Validates input, calls the HiveAuth revoke API, processes the response, and returns formatted results including success details and JSON output.export async function revokeCredential(args: any): Promise<CallToolResult> { // Validate and sanitize input const validation = validateAndSanitizeInput(RevokeCredentialInputSchema, args, 'revoke_credential'); if (!validation.success) { return createValidationErrorResult(validation.error!); } const data = validation.data!; const { credentialId, statusListIndex, reason } = data; const HIVEAUTH_API_BASE_URL = process.env.HIVEAUTH_API_BASE_URL || 'http://localhost:3000'; const REVOKE_ENDPOINT = `${HIVEAUTH_API_BASE_URL}/api/revoke`; try { const response = await fetch(REVOKE_ENDPOINT, { method: 'POST', headers: { 'Content-Type': 'application/json', }, body: JSON.stringify({ credentialId, statusListIndex, reason }), }); if (!response.ok) { const errorData = await response.json().catch(() => ({ message: response.statusText })); throw new Error(`Failed to revoke credential: ${errorData.message}`); } const result = await response.json(); const details = [ `• Credential ID: ${credentialId}`, `• Status List Index: ${statusListIndex}`, `• Revocation Status: ✅ Successfully revoked`, `• Status List Updated: ${result.statusListCredential ? '✅ Yes' : '❌ No'}` ]; if (result.statusListCredential?.id) { details.push(`• Updated Status List ID: ${result.statusListCredential.id}`); } return { content: [ { type: 'text', text: `Credential Revocation Result:\n\n${details.join('\n')}` }, { type: 'text', text: `\`\`\`json\n${JSON.stringify(result, null, 2)}\n\`\`\`` } ] }; } catch (error: any) { return { content: [ { type: 'text', text: `Failed to revoke credential: ${error.message}` } ], isError: true }; } }
- src/schemas/toolSchemas.ts:109-113 (schema)Zod schema defining the input parameters for the revoke_credential tool: credentialId (required string), statusListIndex (non-negative integer), and optional reason string.export const RevokeCredentialInputSchema = z.object({ credentialId: z.string().min(1, 'Credential ID is required'), statusListIndex: z.number().int().min(0, 'Status list index must be a non-negative integer'), reason: z.string().optional().describe('Reason for revocation') });
- src/utils/schemaConverter.ts:31-35 (registration)MCP tool registration entry in TOOL_DEFINITIONS array, specifying name, description, and input schema reference for automatic JSON Schema conversion.{ name: 'revoke_credential', description: 'Revoke a verifiable credential using W3C Status List 2021 specification. Updates the credential status in the bitstring status list.', inputSchema: TOOL_SCHEMAS.revoke_credential },
- src/index.ts:92-93 (registration)Tool dispatch/registration in the MCP server's call handler switch statement, routing 'revoke_credential' calls to the revokeCredential handler function.case 'revoke_credential': return await revokeCredential(args);
- src/schemas/toolSchemas.ts:181-181 (schema)Reference to RevokeCredentialInputSchema in the TOOL_SCHEMAS lookup object used by tool registrations.revoke_credential: RevokeCredentialInputSchema,