Skip to main content
Glama

Send Message Notification

notify

Send notifications through desktop, email, or API channels to alert users about important information, progress updates, task completions, or communication needs.

Instructions

Send notifications and messages through multiple channels (desktop, email, API). Use this tool to notify users about any important information, progress updates, task completions, alerts, or any other communication needs.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
titleNoThe title of the notification
messageNoThe main content of the notification message

Implementation Reference

  • The asynchronous handler function for the 'notify' tool. It processes the title and message inputs, constructs notification content, and dispatches notifications across multiple channels including NTFY, email (via nodemailer), custom API, sound playback, and desktop notifications (via node-notifier). It awaits all promises and returns a content array with results from each channel.
      async ({ title, message }) => {
        const notifyTitle = title || 'Message MCP'
        const notifyMessage = message || 'Task completed, please review.'
        const allNotifyPromise: { [key: string]: Promise<unknown> } = {}
    
        // NTFY notification
        if (config.ntfyTopic) {
          const safeTopic = encodeURIComponent(config.ntfyTopic)
          allNotifyPromise.ntfy = upfetch(`https://ntfy.sh/${safeTopic}`, {
            method: 'POST',
            body: notifyMessage,
            headers: {
              Title: rfc2047.encode(notifyTitle),
              Priority: 'urgent',
            },
          })
        }
    
        // Email notification
        if (config.smtpHost && config.smtpUser && config.smtpPass) {
          const transporter = nodemailer.createTransport({
            host: config.smtpHost,
            port: config.smtpPort,
            secure: config.smtpSecure,
            auth: {
              user: config.smtpUser,
              pass: config.smtpPass,
            },
            pool: true,
            maxConnections: 5,
          })
    
          const mailOptions = {
            from: config.smtpUser,
            to: config.smtpUser,
            subject: notifyTitle,
            text: notifyMessage,
          }
    
          allNotifyPromise.nodemailer = transporter.sendMail(mailOptions)
        }
    
        // API notification
        if (config.apiUrl) {
          allNotifyPromise.api = upfetch(config.apiUrl, {
            method: config.apiMethod,
            headers: config.apiHeaders,
            body: {
              title: notifyTitle,
              message: notifyMessage,
            },
          })
        }
    
        // Desktop play sound notification
        if (!config.disableDesktop) {
          // Sound notification
          const player = play({})
          const internalSoundPath = join(__dirname, 'assets', 'notify.mp3')
          const soundPath = config.soundPath || internalSoundPath
    
          allNotifyPromise.sound = new Promise((resolve, reject) => {
            player.play(soundPath, (error) => {
              if (error) {
                reject(error)
              }
            })
            setTimeout(() => {
              resolve({
                message: 'Sound notification played successfully!',
              })
            }, 1500)
          })
    
          // Desktop notification
          allNotifyPromise.desktop = new Promise((resolve, reject) => {
            notifier.notify(
              {
                title: notifyTitle,
                message: notifyMessage,
                sound: false,
              },
              (error) => {
                if (error) {
                  reject(error)
                }
              },
            )
    
            setTimeout(() => {
              resolve({
                message: 'Desktop notification sent successfully!',
              })
            }, 1500)
          })
        }
    
        // Wait for all notifications to complete
        if (Object.keys(allNotifyPromise).length === 0) {
          return {
            content: [
              {
                type: 'text' as const,
                text: 'No notification channels configured.',
              },
            ],
          }
        }
    
        // Collect results from all notifications
        const entries = Object.entries(allNotifyPromise)
        const results = await Promise.allSettled(entries.map(([, p]) => p))
        const content: { type: 'text'; text: string }[] = []
    
        results.forEach((result, i) => {
          const [name] = entries[i]
          let message = ''
    
          if (result.status === 'fulfilled') {
            message =
              typeof result.value === 'object'
                ? `successfully! ${JSON.stringify(result.value)}`
                : 'successfully!'
          } else {
            message =
              result.reason instanceof Error
                ? `failed! ${result.reason.message}`
                : 'failed!'
          }
    
          content.push({
            type: 'text' as const,
            text: `${name} ${message}`,
          })
        })
    
        return {
          content,
        }
      },
    )
  • Zod input schema definition for the 'notify' tool, defining optional 'title' and 'message' string parameters with descriptions.
    inputSchema: {
      title: z.string().optional().describe('The title of the notification'),
      message: z
        .string()
        .optional()
        .describe('The main content of the notification message'),
    },
  • src/index.ts:68-222 (registration)
    Registration of the 'notify' tool on the McpServer instance, specifying the tool name, metadata (title, description, inputSchema), and the handler function.
    server.registerTool(
      'notify',
      {
        title: 'Send Message Notification',
        description:
          'Send notifications and messages through multiple channels (desktop, email, API). Use this tool to notify users about any important information, progress updates, task completions, alerts, or any other communication needs.',
        inputSchema: {
          title: z.string().optional().describe('The title of the notification'),
          message: z
            .string()
            .optional()
            .describe('The main content of the notification message'),
        },
      },
      async ({ title, message }) => {
        const notifyTitle = title || 'Message MCP'
        const notifyMessage = message || 'Task completed, please review.'
        const allNotifyPromise: { [key: string]: Promise<unknown> } = {}
    
        // NTFY notification
        if (config.ntfyTopic) {
          const safeTopic = encodeURIComponent(config.ntfyTopic)
          allNotifyPromise.ntfy = upfetch(`https://ntfy.sh/${safeTopic}`, {
            method: 'POST',
            body: notifyMessage,
            headers: {
              Title: rfc2047.encode(notifyTitle),
              Priority: 'urgent',
            },
          })
        }
    
        // Email notification
        if (config.smtpHost && config.smtpUser && config.smtpPass) {
          const transporter = nodemailer.createTransport({
            host: config.smtpHost,
            port: config.smtpPort,
            secure: config.smtpSecure,
            auth: {
              user: config.smtpUser,
              pass: config.smtpPass,
            },
            pool: true,
            maxConnections: 5,
          })
    
          const mailOptions = {
            from: config.smtpUser,
            to: config.smtpUser,
            subject: notifyTitle,
            text: notifyMessage,
          }
    
          allNotifyPromise.nodemailer = transporter.sendMail(mailOptions)
        }
    
        // API notification
        if (config.apiUrl) {
          allNotifyPromise.api = upfetch(config.apiUrl, {
            method: config.apiMethod,
            headers: config.apiHeaders,
            body: {
              title: notifyTitle,
              message: notifyMessage,
            },
          })
        }
    
        // Desktop play sound notification
        if (!config.disableDesktop) {
          // Sound notification
          const player = play({})
          const internalSoundPath = join(__dirname, 'assets', 'notify.mp3')
          const soundPath = config.soundPath || internalSoundPath
    
          allNotifyPromise.sound = new Promise((resolve, reject) => {
            player.play(soundPath, (error) => {
              if (error) {
                reject(error)
              }
            })
            setTimeout(() => {
              resolve({
                message: 'Sound notification played successfully!',
              })
            }, 1500)
          })
    
          // Desktop notification
          allNotifyPromise.desktop = new Promise((resolve, reject) => {
            notifier.notify(
              {
                title: notifyTitle,
                message: notifyMessage,
                sound: false,
              },
              (error) => {
                if (error) {
                  reject(error)
                }
              },
            )
    
            setTimeout(() => {
              resolve({
                message: 'Desktop notification sent successfully!',
              })
            }, 1500)
          })
        }
    
        // Wait for all notifications to complete
        if (Object.keys(allNotifyPromise).length === 0) {
          return {
            content: [
              {
                type: 'text' as const,
                text: 'No notification channels configured.',
              },
            ],
          }
        }
    
        // Collect results from all notifications
        const entries = Object.entries(allNotifyPromise)
        const results = await Promise.allSettled(entries.map(([, p]) => p))
        const content: { type: 'text'; text: string }[] = []
    
        results.forEach((result, i) => {
          const [name] = entries[i]
          let message = ''
    
          if (result.status === 'fulfilled') {
            message =
              typeof result.value === 'object'
                ? `successfully! ${JSON.stringify(result.value)}`
                : 'successfully!'
          } else {
            message =
              result.reason instanceof Error
                ? `failed! ${result.reason.message}`
                : 'failed!'
          }
    
          content.push({
            type: 'text' as const,
            text: `${name} ${message}`,
          })
        })
    
        return {
          content,
        }
      },
    )
  • Configuration object for the notify tool, loaded from environment variables using utility functions for various notification channels.
    const config: MessageMcpConfig = {
      disableDesktop: getBoolean(options.shttp || process.env.DISABLE_DESKTOP),
      soundPath: process.env.SOUND_PATH,
      ntfyTopic: process.env.NTFY_TOPIC,
      smtpHost: process.env.SMTP_HOST,
      smtpPort: Number(process.env.SMTP_PORT) || 587,
      smtpSecure: getBoolean(process.env.SMTP_SECURE),
      smtpUser: process.env.SMTP_USER,
      smtpPass: process.env.SMTP_PASS,
      apiUrl: process.env.API_URL,
      apiHeaders: getHeaders(process.env.API_HEADERS),
      apiMethod: getApiMethod(process.env.API_METHOD),
    }
  • Utility function getBoolean used to parse boolean config values like disableDesktop from env vars or options.
    export function getBoolean(value?: string | boolean): boolean {
      if (typeof value === 'boolean') {
        return value
      }
      if (typeof value === 'string') {
        return value.toLowerCase() === 'true' || value === '1'
      }
      return false
    }
Behavior2/5

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

No annotations are provided, so the description carries the full burden. It mentions sending through multiple channels but doesn't disclose behavioral traits such as permissions required, rate limits, delivery guarantees, or error handling. For a notification tool with potential side effects, this is a significant gap in transparency.

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 front-loaded with the core purpose and uses two sentences efficiently. However, the second sentence is somewhat verbose with a list of examples ('important information, progress updates...'), which could be streamlined. Overall, it's appropriately sized with minimal waste.

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?

Given the tool's moderate complexity (sending notifications with 2 parameters) and no annotations or output schema, the description is minimally adequate. It covers the purpose and usage but lacks details on behavior, error handling, and response format. It meets basic needs but leaves gaps for effective agent use.

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?

The schema description coverage is 100%, with clear descriptions for both parameters (title and message). The description adds no additional meaning beyond the schema, as it doesn't explain parameter usage, constraints, or examples. Baseline 3 is appropriate since the schema does the heavy lifting.

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 with 'Send notifications and messages through multiple channels' and specifies the resource (notifications/messages). It distinguishes the action (send) and channels (desktop, email, API), but without sibling tools, differentiation isn't applicable. It's specific but could be more precise about the scope.

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 provides implied usage with 'Use this tool to notify users about any important information...', listing examples like progress updates and alerts. However, it lacks explicit guidance on when to use this tool versus alternatives, prerequisites, or exclusions. Without siblings, this is adequate but not comprehensive.

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/gimjin/message-mcp'

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