send_google_chat_cards_v2
Send structured Cards V2 messages to Google Chat webhooks for formatted notifications with headers, lists, tables, and images.
Instructions
Send a Cards V2 message to configured Google Chat webhook
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| text | No | ||
| cardsV2 | Yes |
Implementation Reference
- src/server.ts:111-120 (registration)Registers the 'send_google_chat_cards_v2' tool with the MCP server, including title, description, input and output schemas, and references the handler function.
server.registerTool( 'send_google_chat_cards_v2', { title: 'Send Google Chat Cards V2', description: 'Send a Cards V2 message to configured Google Chat webhook', inputSchema: ( { text: z.string().optional(), cardsV2: z.array(z.any()) } as unknown ) as any, outputSchema: ( { success: z.boolean() } as unknown ) as any }, sendCardsHandler ); - src/server.ts:100-109 (handler)The MCP tool handler for 'send_google_chat_cards_v2'. It receives input parameters, calls the sendCardsV2Message helper, handles success/error responses, and formats output for MCP protocol.
const sendCardsHandler = (async ({ text, cardsV2 }: { text?: string; cardsV2: any[] }) => { try { await sendCardsV2Message({ text, cardsV2 }, webhook); const out = { success: true }; return { content: [{ type: 'text', text: JSON.stringify(out) }], structuredContent: out }; } catch (err: unknown) { const e = err as Error; return { content: [{ type: 'text', text: `Error: ${e.message}` }], isError: true }; } }) as any; - src/tools/sendCardsV2Message.ts:9-38 (helper)Core implementation that performs HTTP POST to Google Chat webhook with Cards V2 payload using axios. Includes input validation, mock mode without webhook, logging, and error handling.
export async function sendCardsV2Message(params: SendCardsV2Params, webhookUrl?: string) { if (!params || !Array.isArray(params.cardsV2)) { const error = 'Invalid params for sendCardsV2Message'; logger.error('sendCardsV2Message', 'send_failed', { error }); throw new Error(error); } if (!webhookUrl) { logger.warn('sendCardsV2Message', 'send_failed' as any, { message: 'No webhook configured — skipping HTTP send', }); console.log('[sendCardsV2Message] no webhook configured — skipping HTTP send. payload:', params); return { mock: true }; } const payload: any = { cardsV2: params.cardsV2 }; if (params.text) payload.text = params.text; try { console.log(`[sendCardsV2Message] Sending to: ${webhookUrl}`); const res = await axios.post(webhookUrl, payload, { timeout: 5000 }); return res.data; } catch (error: any) { logger.error('sendCardsV2Message', 'send_failed', { error: error.message || String(error), text: params.text, }); throw error; } } - src/tools/sendCardsV2Message.ts:4-7 (schema)TypeScript type definition for the input parameters expected by sendCardsV2Message, matching the tool's input schema.
export type SendCardsV2Params = { text?: string; cardsV2: any[]; };