Skip to main content
Glama

Send Message Notification

notify

Send notifications across desktop, email, and API to inform users of important updates, task completions, or alerts.

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 main handler function for the 'notify' tool. It sends notifications through multiple channels (ntfy, email, API, desktop sound, desktop notification) based on configuration, and returns results for 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,
      }
    },
  • Input schema for the 'notify' tool using Zod. Defines two optional string inputs: 'title' (notification title) and 'message' (main content).
    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 via server.registerTool(). The tool is named 'notify' and is registered with its metadata, schema, and handler on the McpServer instance.
    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,
        }
      },
    )
  • Helper function getBoolean() used to parse environment variables for the config, e.g., disableDesktop and smtpSecure.
    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
    }
  • Helper function getHeaders() used to parse API_HEADERS env var into a HeadersInit object for the API notification channel.
    export function getHeaders(headers?: string): HeadersInit {
      if (!headers) return {}
    
      try {
        const parsed = JSON.parse(headers)
        return parsed && typeof parsed === 'object' && !Array.isArray(parsed)
          ? parsed
          : {}
      } catch (error) {
        console.error('Invalid headers format, using empty headers:', error)
        return {}
      }
    }
Behavior2/5

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

No annotations are provided, so the description must fully disclose behavior. It claims multi-channel delivery but does not clarify if all channels are always used or if there is implicit selection. No mention of side effects, permissions, or rate limits.

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?

Two sentences with no wasted words. First sentence states purpose and channels, second gives use cases. Very concise.

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

Completeness4/5

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

For a simple tool with no output schema and two string parameters, the description covers purpose and use cases adequately. However, it lacks clarity on channel selection and does not specify the return type (likely void).

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%, so the baseline is 3. The description does not add meaning beyond the schema for the parameters; it only states the notification's purpose.

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 the verb 'send' and resource 'notifications/messages', and specifies multiple channels (desktop, email, API). Though there are no sibling tools, the purpose is unambiguous.

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 explicitly says 'Use this tool to notify users...' and lists use cases, but it does not provide when not to use or mention that channel selection is not available via parameters, which could mislead an agent.

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