Skip to main content
Glama
visaacceptance

Visa Acceptance

cancel_invoice

Cancel an invoice in Visa Acceptance by providing its invoice ID. Useful for voiding or removing an invoice that is no longer needed.

Instructions

This tool will cancel an invoice in Visa Acceptance.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
invoice_idYesInvoice ID (required)

Implementation Reference

  • The main handler function for cancel_invoice. It uses cybersource-rest-client InvoicesApi to call performCancelAction with the invoice_id parameter, then masks customer info before returning the result.
    export const cancelInvoice = async (
      visaClient: any,
      context: VisaContext,
      params: z.infer<ReturnType<typeof cancelInvoiceParameters>>
    ) => {
      try {
        const invoiceApiInstance = new cybersourceRestApi.InvoicesApi(visaClient.configuration, visaClient.visaApiClient);
        
        const result = await new Promise((resolve, reject) => {
          invoiceApiInstance.performCancelAction(params.invoice_id, (error: any, data: any, response: any) => {
            if (error) {
              reject(error);
            } else {
              resolve({
                data,
                status: response['status']
              });
            }
          });
        });
        
        const maskedResult = maskInvoiceCustomerInfo(result);
        return maskedResult;
      } catch (error) {
        return 'Failed to cancel invoice';
      }
    };
  • Input parameter schema for cancel_invoice tool. Defines a required 'invoice_id' string parameter using Zod validation.
    export const cancelInvoiceParameters = (
      context: VisaContext = {} as VisaContext
    ) => {
      return z.object({
        invoice_id: z.string().describe('Invoice ID (required)')
      });
    };
  • Tool registration object for cancel_invoice. Sets method to 'cancel_invoice', name to 'Cancel Invoice', provides description, parameters, and links the execute function.
    const tool = (context: VisaContext): Tool => ({
      method: 'cancel_invoice',
      name: 'Cancel Invoice',
      description: cancelInvoicePrompt(context),
      parameters: cancelInvoiceParameters(context),
      actions: {
        invoices: {
          update: true,
        },
      },
      execute: cancelInvoice,
    });
    
    export default tool;
  • Aggregation of all tools including cancelInvoiceToolModule in the createTools function which assembles the list of all available tools.
    export function createTools(context: VisaContext): Tool[] {
      return [
        createInvoiceToolModule(context),
        updateInvoiceToolModule(context),
        getInvoiceToolModule(context),
        listInvoicesToolModule(context),
        sendInvoiceToolModule(context),
        cancelInvoiceToolModule(context),
        createPaymentLinkToolModule(context),
        updatePaymentLinkToolModule(context),
        getPaymentLinkToolModule(context),
        listPaymentLinkToolModule(context)
      ];
    }
  • Helper function maskInvoiceCustomerInfo used by the cancel_invoice handler to mask PII (name and email) in the invoice customer information before returning the response.
    export const maskInvoiceCustomerInfo = (
      invoice: any,
      context?: Context
    ): any => {
      try {
        if (!invoice) return invoice;
        
        const maskedInvoice = JSON.parse(JSON.stringify(invoice));
        
        if (maskedInvoice.customerInformation) {
          if (maskedInvoice.customerInformation.name) {
            maskedInvoice.customerInformation.name = maskPII(maskedInvoice.customerInformation.name, 'end');
          }
          
          if (maskedInvoice.customerInformation.email) {
            const emailParts = maskedInvoice.customerInformation.email.split('@');
            if (emailParts.length === 2) {
              const maskedLocalPart = maskPII(emailParts[0], 'end');
              maskedInvoice.customerInformation.email = `${maskedLocalPart}@${emailParts[1]}`;
            } else {
              maskedInvoice.customerInformation.email = maskPII(maskedInvoice.customerInformation.email, 'end');
            }
          }
        }
        
        return maskedInvoice;
      } catch (error) {
        return 'Failed to mask invoice customer information';
      }
    };
Behavior2/5

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

No annotations are present, so the description should disclose behavioral traits like irreversibility, authorization needs, or side effects. It only says 'will cancel,' omitting critical details such as whether cancellation can be undone or what happens to associated data.

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

Conciseness5/5

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

The description is a single sentence with no fluff. It directly states the action and context, making it highly concise and easy to parse.

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

Completeness3/5

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

While the tool is simple with one parameter and no output schema, the description lacks behavioral context (e.g., consequences of cancellation). A more complete description would mention effects like 'marks invoice as cancelled' or 'action is irreversible.' Given low complexity, the gap is moderate.

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 coverage is 100% with one parameter 'invoice_id' described as 'Invoice ID (required).' The tool description adds no extra meaning beyond the schema, so a baseline of 3 is appropriate.

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

Purpose5/5

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

The description clearly states 'cancel an invoice in Visa Acceptance.' The verb 'cancel' and resource 'invoice' are specific. Since no sibling tool cancels invoices (others create, get, list, update, send), it distinguishes well from alternatives.

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

Usage Guidelines2/5

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

No guidance is provided on when to use this tool versus alternatives, such as prerequisites (e.g., invoice must be unpaid) or conditions. The description simply states it cancels, without any contextual use advice.

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/visaacceptance/agent-toolkit'

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