OneSignal MCP server

Integrates with OneSignal to manage push notifications, emails, and SMS across multiple applications with support for device management, segmentation, and template operations.
Back to servers
Provider
Weirdbrains
Release date
Mar 09, 2025
Language
Python
Stats
1 star

This MCP server provides a convenient interface for the OneSignal API, allowing you to manage push notifications, emails, SMS, user devices, segments, templates, and multiple OneSignal applications through a standardized protocol.

Requirements

  • Python 3.7 or higher
  • python-dotenv package
  • requests package
  • OneSignal account with API credentials

Installation

Clone from GitHub

# Clone the repository
git clone https://github.com/weirdbrains/onesignal-mcp.git
cd onesignal-mcp

# Install dependencies
pip install -r requirements.txt

Package Installation (Coming Soon)

pip install onesignal-mcp

Configuration

Create a .env file in the root directory with your OneSignal credentials:

# Default app credentials (optional, you can also add apps via the API)
ONESIGNAL_APP_ID=your_app_id_here
ONESIGNAL_API_KEY=your_rest_api_key_here

# Organization API key (for org-level operations)
ONESIGNAL_ORG_API_KEY=your_organization_api_key_here

You can find your OneSignal credentials in your OneSignal dashboard:

  • App ID: Settings > Keys & IDs > OneSignal App ID
  • REST API Key: Settings > Keys & IDs > REST API Key
  • Organization API Key: Organization Settings > API Keys

Running the Server

Start the server with:

python onesignal_server.py

The server will register itself with the MCP system, making its tools available for use.

Usage Examples

Sending Push Notifications

# Send a notification to all subscribed users
result = await send_notification(
    title="Hello World",
    message="This is a test notification",
    segment="Subscribed Users"
)
print(result)

Managing Multiple Apps

# Add a new app configuration
await add_app(
    key="my_second_app", 
    app_id="second-app-id", 
    api_key="second-app-api-key", 
    name="My Second App"
)

# List all configured apps
apps = await list_apps()
print(apps)

# Switch to the new app
await switch_app("my_second_app")

# Send a notification using the current app
await send_notification(
    title="Hello", 
    message="This is from my second app"
)

# Send a notification from a specific app (without switching)
await send_notification(
    title="Hello", 
    message="This is from my first app", 
    app_key="mandible"
)

Managing Segments

# List all segments
segments = await view_segments()
print(segments)

# Create a new segment
result = await create_segment(
    name="High Value Users",
    filters='[{"field":"amount_spent", "relation":">", "value":"100"}]'
)
print(result)

Working with Templates

# Create an email template
result = await create_template(
    name="Welcome Email",
    title="Welcome to Our App",
    message="<html><body><h1>Welcome!</h1><p>Thank you for joining us.</p></body></html>",
    template_type="email"
)
print(result)

Multi-App Support

This server supports managing multiple OneSignal applications with the following tools:

  • list_apps: List all configured OneSignal apps
  • add_app: Add a new OneSignal app configuration
  • update_app: Update an existing app configuration
  • remove_app: Remove an app configuration
  • switch_app: Switch the current app for API requests

Available Tools

Message Management

  • send_notification: Send push notifications, emails, or SMS
  • view_messages: List recent messages
  • view_message_details: Get details about a specific message
  • cancel_message: Cancel a scheduled message

Device Management

  • view_devices: List registered devices/users
  • view_device_details: Get device-specific information

Segment Management

  • view_segments: List all segments
  • create_segment: Create a new segment with filters
  • delete_segment: Remove an existing segment

Template Management

  • view_templates: List all templates
  • view_template_details: Get template details
  • create_template: Create new notification or email templates

App Information

  • view_app_details: Get information about the configured app

Troubleshooting

Common Issues

No App Configuration Available

Make sure you've either:

  • Set up your .env file with correct credentials, or
  • Added an app configuration using the add_app tool

API Key Errors

Verify that:

  • Your API keys are correct
  • You're using the right key for the operation (REST API Key vs Organization API Key)
  • The key has the necessary permissions in OneSignal

Rate Limiting

If you encounter rate limiting:

  • Reduce request frequency
  • Implement retry logic with exponential backoff

How to add this MCP server to Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > MCP and click "Add new global MCP server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "cursor-rules-mcp": {
            "command": "npx",
            "args": [
                "-y",
                "cursor-rules-mcp"
            ]
        }
    }
}

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later