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.
# Clone the repository
git clone https://github.com/weirdbrains/onesignal-mcp.git
cd onesignal-mcp
# Install dependencies
pip install -r requirements.txt
pip install onesignal-mcp
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:
Start the server with:
python onesignal_server.py
The server will register itself with the MCP system, making its tools available for use.
# 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)
# 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"
)
# 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)
# 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)
This server supports managing multiple OneSignal applications with the following tools:
Make sure you've either:
.env
file with correct credentials, oradd_app
toolVerify that:
If you encounter rate limiting:
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.
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"
]
}
}
}
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.
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.