evaluate_presentation
Check credentials against presentation definitions using DIF Presentation Exchange to verify compliance and match requirements.
Instructions
Evaluate credentials against a presentation definition using DIF Presentation Exchange Protocol. Tests credential compliance and matching.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| presentationDefinition | Yes | DIF PEX Presentation Definition | |
| credentials | Yes |
Implementation Reference
- src/tools/evaluatePresentation.ts:8-102 (handler)The main execution logic for the 'evaluate_presentation' tool. Validates input using the schema, sends credentials and presentation definition to the HiveAuth API for DIF PEX evaluation, formats detailed results with status indicators and JSON output.export async function evaluatePresentation(args: any): Promise<CallToolResult> { // Validate and sanitize input const validation = validateAndSanitizeInput(EvaluatePresentationInputSchema, args, 'evaluate_presentation'); if (!validation.success) { return createValidationErrorResult(validation.error!); } const data = validation.data!; const { presentationDefinition, credentials } = data; const HIVEAUTH_API_BASE_URL = process.env.HIVEAUTH_API_BASE_URL || 'http://localhost:3000'; const EVALUATE_ENDPOINT = `${HIVEAUTH_API_BASE_URL}/api/presentation/evaluate`; try { const response = await fetch(EVALUATE_ENDPOINT, { method: 'POST', headers: { 'Content-Type': 'application/json', }, body: JSON.stringify({ presentationDefinition, credentials }), }); if (!response.ok) { const errorData = await response.json().catch(() => ({ message: response.statusText })); throw new Error(`Failed to evaluate presentation: ${errorData.message}`); } const result = await response.json(); const details = [ `• Definition ID: ${presentationDefinition.id}`, `• Credentials Evaluated: ${credentials.length}`, `• Evaluation Status: ${result.canSubmit ? '✅ Can Submit' : '❌ Cannot Submit'}`, '' ]; if (result.inputDescriptorResults) { details.push('Input Descriptor Results:'); result.inputDescriptorResults.forEach((descriptorResult: any) => { const status = descriptorResult.canSubmit ? '✅' : '❌'; details.push(` • ${descriptorResult.inputDescriptor.id}: ${status} ${descriptorResult.canSubmit ? 'Satisfied' : 'Not satisfied'}`); if (descriptorResult.matchingCredentials) { details.push(` - Matching credentials: ${descriptorResult.matchingCredentials.length}`); descriptorResult.matchingCredentials.forEach((match: any, index: number) => { const credId = match.credential?.id || `Credential ${index + 1}`; details.push(` • ${credId}`); }); } if (descriptorResult.errors && descriptorResult.errors.length > 0) { details.push(` - Errors: ${descriptorResult.errors.length}`); descriptorResult.errors.forEach((error: string) => { details.push(` • ${error}`); }); } details.push(''); }); } if (result.errors && result.errors.length > 0) { details.push('Overall Errors:'); result.errors.forEach((error: string) => { details.push(` • ${error}`); }); } return { content: [ { type: 'text', text: `Presentation Evaluation 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 evaluate presentation: ${error.message}` } ], isError: true }; } }
- src/schemas/toolSchemas.ts:122-125 (schema)Zod schema defining the input structure for the evaluate_presentation tool: a presentationDefinition (DIF PEX) and an array of credentials (at least one required).export const EvaluatePresentationInputSchema = z.object({ presentationDefinition: PresentationDefinitionSchema, credentials: z.array(CredentialSchema).min(1, 'At least one credential is required') });
- src/index.ts:98-99 (registration)Handler dispatch registration in the main MCP server request handler switch statement, routing 'evaluate_presentation' calls to the evaluatePresentation function.case 'evaluate_presentation': return await evaluatePresentation(args);
- src/utils/schemaConverter.ts:41-45 (registration)MCP Tool registration definition including name, description, and input schema reference, used by createMCPTools() to generate the Tool[] for the server.{ name: 'evaluate_presentation', description: 'Evaluate credentials against a presentation definition using DIF Presentation Exchange Protocol. Tests credential compliance and matching.', inputSchema: TOOL_SCHEMAS.evaluate_presentation },