Skip to main content
Glama
AlyssonM

HiveAuth MCP Server

by AlyssonM

batch_issue_credentials

Issue multiple verifiable credentials in batches of up to 50, with options for parallel or sequential processing, error handling, and performance tracking.

Instructions

Issue multiple verifiable credentials in parallel or sequentially. Supports up to 50 credentials per batch with comprehensive error handling and performance metrics.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
credentialsYes
parallelNoWhether to process credentials in parallel

Implementation Reference

  • The main handler function that implements the batch_issue_credentials tool. It validates input, issues multiple verifiable credentials via HiveAuth API in parallel or sequential mode, and returns detailed results with summary and JSON output.
    export async function batchIssueCredentials(args: any): Promise<CallToolResult> {
      // Validate and sanitize input
      const validation = validateAndSanitizeInput(BatchIssueCredentialsInputSchema, args, 'batch_issue_credentials');
      
      if (!validation.success) {
        return createValidationErrorResult(validation.error!);
      }
    
      const data = validation.data!;
      const { credentials, parallel = true } = data;
    
      const HIVEAUTH_API_BASE_URL = process.env.HIVEAUTH_API_BASE_URL || 'http://localhost:3000';
      const ISSUE_ENDPOINT = `${HIVEAUTH_API_BASE_URL}/api/issue`;
    
      const startTime = Date.now();
      const results: any[] = [];
      const errors: any[] = [];
    
      try {
        console.log(`[BatchIssue] Starting batch issuance of ${credentials.length} credentials (parallel: ${parallel})`);
    
        if (parallel) {
          // Process credentials in parallel
          const promises = credentials.map(async (credentialData, index) => {
            try {
              const payload = {
                credentialSubject: credentialData.credentialSubject,
                type: credentialData.type,
                vcVersion: credentialData.vcVersion || '2.0',
                ...(credentialData.expirationDate && { expirationDate: credentialData.expirationDate }),
                ...(credentialData.validUntil && { validUntil: credentialData.validUntil }),
                ...(credentialData.context && { context: credentialData.context }),
                ...(credentialData.issuer && { issuer: credentialData.issuer })
              };
    
              const response = await fetch(ISSUE_ENDPOINT, {
                method: 'POST',
                headers: { 'Content-Type': 'application/json' },
                body: JSON.stringify(payload),
              });
    
              if (!response.ok) {
                const errorData = await response.json().catch(() => ({ message: response.statusText }));
                throw new Error(`Credential ${index + 1}: ${errorData.message}`);
              }
    
              const result = await response.json();
              return { index, success: true, credential: result.credential, result };
            } catch (error: any) {
              return { index, success: false, error: error.message };
            }
          });
    
          const allResults = await Promise.all(promises);
          
          // Separate successful results from errors
          allResults.forEach(result => {
            if (result.success) {
              results.push(result);
            } else {
              errors.push(result);
            }
          });
        } else {
          // Process credentials sequentially
          for (let index = 0; index < credentials.length; index++) {
            const credentialData = credentials[index];
            
            try {
              const payload = {
                credentialSubject: credentialData.credentialSubject,
                type: credentialData.type,
                vcVersion: credentialData.vcVersion || '2.0',
                ...(credentialData.expirationDate && { expirationDate: credentialData.expirationDate }),
                ...(credentialData.validUntil && { validUntil: credentialData.validUntil }),
                ...(credentialData.context && { context: credentialData.context }),
                ...(credentialData.issuer && { issuer: credentialData.issuer })
              };
    
              const response = await fetch(ISSUE_ENDPOINT, {
                method: 'POST',
                headers: { 'Content-Type': 'application/json' },
                body: JSON.stringify(payload),
              });
    
              if (!response.ok) {
                const errorData = await response.json().catch(() => ({ message: response.statusText }));
                throw new Error(`Credential ${index + 1}: ${errorData.message}`);
              }
    
              const result = await response.json();
              results.push({ index, success: true, credential: result.credential, result });
            } catch (error: any) {
              errors.push({ index, success: false, error: error.message });
            }
          }
        }
    
        const endTime = Date.now();
        const duration = endTime - startTime;
        const successCount = results.length;
        const errorCount = errors.length;
        const totalCount = credentials.length;
    
        // Generate summary
        const summary = [
          `📊 **Batch Credential Issuance Results**`,
          ``,
          `• Total Credentials: ${totalCount}`,
          `• Successfully Issued: ${successCount} ✅`,
          `• Failed: ${errorCount} ❌`,
          `• Processing Mode: ${parallel ? 'Parallel' : 'Sequential'}`,
          `• Duration: ${duration}ms`,
          `• Average per credential: ${Math.round(duration / totalCount)}ms`,
          ``
        ];
    
        if (successCount > 0) {
          summary.push(`**✅ Successfully Issued Credentials:**`);
          results.forEach(result => {
            const credId = result.credential?.id || 'unknown';
            const vcVersion = result.result?.credential?.['@context']?.includes('credentials/v2') ? '2.0' : '1.1';
            summary.push(`${result.index + 1}. **${credId}** (VC ${vcVersion})`);
          });
          summary.push(``);
        }
    
        if (errorCount > 0) {
          summary.push(`**❌ Failed Credentials:**`);
          errors.forEach(error => {
            summary.push(`${error.index + 1}. ${error.error}`);
          });
          summary.push(``);
        }
    
        // Performance insights
        if (parallel && totalCount > 1) {
          const sequentialEstimate = duration * totalCount;
          const speedup = Math.round((sequentialEstimate / duration) * 10) / 10;
          summary.push(`**⚡ Performance:**`);
          summary.push(`• Parallel speedup: ~${speedup}x faster than sequential`);
          summary.push(`• Estimated sequential time: ${sequentialEstimate}ms`);
        }
    
        return {
          content: [
            {
              type: 'text',
              text: summary.join('\n')
            },
            {
              type: 'text',
              text: `\`\`\`json\n${JSON.stringify({
                summary: {
                  total: totalCount,
                  successful: successCount,
                  failed: errorCount,
                  duration: duration,
                  parallel: parallel
                },
                results: results.map(r => ({
                  index: r.index,
                  credentialId: r.credential?.id,
                  success: true
                })),
                errors: errors.map(e => ({
                  index: e.index,
                  error: e.error,
                  success: false
                }))
              }, null, 2)}\n\`\`\``
            }
          ]
        };
      } catch (error: any) {
        return {
          content: [
            {
              type: 'text',
              text: `Failed to issue credentials in batch: ${error.message}`
            }
          ],
          isError: true
        };
      }
    }
  • Zod input schema definition for the batch_issue_credentials tool, defining the structure for batch credentials and parallel processing option.
    export const BatchIssueCredentialsInputSchema = z.object({
      credentials: z.array(IssueCredentialInputSchema).min(1).max(50, 'Maximum 50 credentials per batch'),
      parallel: z.boolean().default(true).describe('Whether to process credentials in parallel')
    });
  • Mapping of the tool name to its input schema in the TOOL_SCHEMAS object used for MCP tool registration.
    batch_issue_credentials: BatchIssueCredentialsInputSchema,
  • src/index.ts:101-102 (registration)
    Registration in the main switch statement that dispatches calls to the batchIssueCredentials handler function.
    case 'batch_issue_credentials':
      return await batchIssueCredentials(args);
  • src/index.ts:26-26 (registration)
    Import of the batchIssueCredentials handler into the main index file.
    import { batchIssueCredentials } from './tools/batchIssueCredentials.js';
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions 'comprehensive error handling and performance metrics,' which adds some context about outputs and robustness. However, it doesn't disclose critical behavioral traits such as whether this is a read-only or destructive operation, authentication requirements, rate limits, or what happens on partial failures. For a batch mutation tool, this leaves significant gaps.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that front-loads the core purpose and includes key constraints. Every phrase ('issue multiple verifiable credentials,' 'parallel or sequentially,' 'up to 50 credentials,' 'error handling and performance metrics') adds value without redundancy. It could be slightly more structured but is appropriately concise.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (batch mutation with up to 50 items), lack of annotations, and no output schema, the description is incomplete. It mentions error handling and performance metrics but doesn't describe the return format, success/failure semantics, or authentication needs. For a tool that modifies data in bulk, this leaves the agent with insufficient context to use it effectively.

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 description coverage is 50%, with the 'credentials' parameter well-documented in the schema but 'parallel' only having a basic description. The description adds value by specifying 'up to 50 credentials per batch,' which clarifies the maxItems constraint, and mentions parallel/sequential processing, hinting at the 'parallel' parameter's purpose. However, it doesn't fully compensate for the schema's coverage gap, as it doesn't explain parameter interactions or provide examples.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'Issue multiple verifiable credentials in parallel or sequentially.' It specifies the verb ('issue'), resource ('verifiable credentials'), and scope ('multiple'), distinguishing it from the sibling 'issue_credential' which presumably handles single credentials. However, it doesn't explicitly contrast with other credential-related siblings like 'derive_credential' or 'refresh_credential'.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage context by mentioning 'parallel or sequentially' and 'up to 50 credentials per batch,' suggesting this tool is for bulk operations. However, it doesn't provide explicit guidance on when to use this versus the single 'issue_credential' tool or other alternatives like 'derive_credential,' nor does it mention prerequisites or exclusions.

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/AlyssonM/hiveauth-mcp'

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