Use Cases & Prompts
Copy-paste prompts and code examples for common Pushary notification use cases with AI agents
Using Pushary with AI agents
Once you have connected the Pushary MCP to your AI agent, you can use natural language prompts or drop in the utility below to trigger push notifications from your code.
Server-Side Utility
For use in Next.js Server Actions, API routes, or any Node.js backend, copy this utility. It calls the MCP endpoint directly using fetch - no extra SDK required.
# Add your API key to your environment
PUSHARY_API_KEY=pk_xxx.secret_xxxtype SendNotificationParams = {
title: string
body: string
url?: string
iconUrl?: string
imageUrl?: string
subscriberIds?: string[]
externalIds?: string[]
tags?: string[]
}
type PusharyResult = {
ok: boolean
error?: string
}
export async function sendPushNotification(params: SendNotificationParams): Promise<PusharyResult> {
const apiKey = process.env.PUSHARY_API_KEY
if (!apiKey) {
console.warn('PUSHARY_API_KEY is not set - skipping push notification')
return { ok: false, error: 'PUSHARY_API_KEY not configured' }
}
try {
const res = await fetch('https://pushary.com/api/mcp/mcp', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json, text/event-stream',
'Authorization': `Bearer ${apiKey}`,
},
body: JSON.stringify({
jsonrpc: '2.0',
id: 1,
method: 'tools/call',
params: {
name: 'send_notification',
arguments: params,
},
}),
})
if (!res.ok) {
const text = await res.text()
console.error('Pushary notification failed:', res.status, text)
return { ok: false, error: `Pushary API error: ${res.status}` }
}
const text = await res.text()
const jsonLine = text.split('\n').find(line => line.startsWith('data:'))
if (jsonLine) {
const parsed = JSON.parse(jsonLine.replace(/^data:\s*/, '')) as {
result?: { content?: Array<{ text?: string }> }
error?: { message?: string }
}
if (parsed.error) {
console.error('Pushary MCP error:', parsed.error.message)
return { ok: false, error: parsed.error.message }
}
}
return { ok: true }
} catch (error) {
console.error('Pushary notification request error:', error)
return { ok: false, error: 'Failed to send push notification' }
}
}Prompts for AI Agents
Use these prompts with Cursor, Claude, Windsurf, Lovable, or any MCP-connected agent to send notifications or integrate Pushary into your codebase.
Send a Notification via Prompt
Use the Pushary MCP to send a push notification to all subscribers tagged "admin"
with title "New Contact Form Submission" and body "A visitor just filled out the contact form."Integrate into a Contact Form (Next.js)
In my Next.js app, after a successful contact form submission in the server action,
use the sendPushNotification utility (calling https://pushary.com/api/mcp/mcp with
JSON-RPC and Accept: application/json, text/event-stream) to send a fire-and-forget
push notification with title "New Inquiry" and body showing the submitter's name and email,
targeting tags: ["admin"]. Use PUSHARY_API_KEY from env.Alert on New User Sign-Up
Whenever a new user signs up (in my auth webhook or onboarding server action),
use the Pushary MCP send_notification tool to notify subscribers tagged "team"
with title "New Sign-Up" and body showing the user's email and plan.
Use the sendPushNotification utility with PUSHARY_API_KEY from env.Alert on New Payment / Purchase
In my Stripe webhook handler, on a checkout.session.completed event, use the
Pushary MCP to send a push notification to tags: ["admin"] with title
"New Payment" and body showing the customer email and amount paid.Broadcast a Product Announcement to All Subscribers
Use the Pushary MCP send_notification tool to broadcast a notification to all
subscribers (no tags filter) with title "We just launched [Feature Name]" and
body "Check it out - link in the notification." and url "https://yoursite.com/changelog".Ask User for Confirmation (Human-in-the-Loop)
Before deploying this database migration, ask me for confirmation via Pushary.
Use ask_user to send me a push notification asking "Should I proceed with
the database migration?" targeting tags: ["admin"]. Then wait for my answer using
wait_for_answer. Only proceed with the migration if I respond "yes".Check Subscriber Count
Use the Pushary MCP count_subscribers tool to get the current total, active,
and unsubscribed subscriber counts for this site.Using Pushary with Lovable
Lovable supports custom MCP servers as personal connectors on paid plans. Connect Pushary so the Lovable agent notifies you and asks you questions while it builds. See the dedicated Lovable guide for the full setup, including the skill that makes it notify you and ask on its own.
Quick prompts
Notify when a build finishes:
After you finish implementing this feature, send me a Pushary notification with
title "Lovable build done" and a one-line summary of what changed.Ask before a risky change:
Before you delete or rename any database table, use Pushary ask_user to confirm
with me, and wait for my answer before continuing.