Termux Notification List MCP Server
Enables AI agents to monitor and read Android notifications in real-time via Termux. Provides access to current notifications with filtering capabilities and real-time streaming of new notifications as they arrive.
README
Termux Notification List MCP Server
A Model Context Protocol (MCP) server that provides access to Android notifications via Termux, enabling AI agents to monitor and read Android notifications in real-time.
Features
- Real-time notification monitoring: Stream new notifications as they arrive
- Current notification retrieval: Get a snapshot of all active notifications
- Filtering capabilities: Filter notifications by package name or limit results
- Clean notification data: Structured JSON output with all notification metadata
Prerequisites
- Android device with Termux installed
- Termux API app installed and configured
- Node.js 18+ in Termux environment
- Proper permissions for notification access
Setup Termux Environment
- Install Termux and Termux:API from F-Droid or Google Play
- Install required packages in Termux:
pkg update && pkg upgrade pkg install nodejs termux-api - Grant notification access permissions to Termux:API in Android settings
Installation
npm install termux-notification-list-mcp
Or build from source:
git clone <repository-url>
cd termux-notification-list-mcp
npm install
npm run build
Usage
As MCP Server (stdio)
Run the server directly:
npx termux-notification-list-mcp
Or use the built version:
node dist/stdio.js
As SSE Server
The package can also run as an SSE server for web-based MCP clients:
npx termux-notification-list-mcp-sse
Or use the built version:
node dist/sse.js
The SSE server listens on port 3000 by default, configurable via PORT environment variable.
Security Configuration
The SSE server includes several security features for remote access:
Environment Variables
MCP_AUTH_TOKEN: Bearer token for authentication (required for production)MCP_BASIC_USER: Username for HTTP Basic AuthenticationMCP_BASIC_PASS: Password for HTTP Basic AuthenticationALLOWED_ORIGINS: Comma-separated list of allowed CORS origins (default:http://localhost:3000)PORT: Server port (default: 3000)
Authentication
The server supports both Bearer token and HTTP Basic Authentication:
Bearer Token Authentication:
curl -H "Authorization: Bearer your-token" https://your-server:3000/sse
HTTP Basic Authentication:
curl -u username:password https://your-server:3000/sse
Or with explicit header:
curl -H "Authorization: Basic $(echo -n 'username:password' | base64)" https://your-server:3000/sse
Configuration:
# Bearer token
export MCP_AUTH_TOKEN=your-secure-token
# Basic auth
export MCP_BASIC_USER=admin
export MCP_BASIC_PASS=secure-password
You can enable both authentication methods simultaneously for maximum compatibility.
Security Features
- Rate Limiting: 100 requests per 15 minutes per IP
- CORS Protection: Configurable allowed origins
- Input Validation: JSON payload validation
- Helmet Security Headers: XSS protection, HSTS, CSP
- TLS 1.2+: Strong cipher suites for HTTPS
- Error Handling: Secure error responses without information leakage
Running as a Background Service in Termux
To run the SSE server indefinitely as a background service using runit:
Automated Setup
Run the provided setup script:
wget https://raw.githubusercontent.com/faisalhakim47/termux-notification-list-mcp/main/setup-service.sh
chmod +x setup-service.sh
./setup-service.sh
Note: After running the setup script, restart your Termux session or run source $PREFIX/etc/profile to use service management commands.
Manual Setup
-
Install termux-services:
pkg install termux-services -
Install the package globally:
npm install -g termux-notification-list-mcp -
Create the service directory:
mkdir -p $PREFIX/var/service/termux-notification-sse -
Create the run script:
cat > $PREFIX/var/service/termux-notification-sse/run << 'EOF' #!/bin/sh exec termux-notification-list-mcp-sse EOF chmod +x $PREFIX/var/service/termux-notification-sse/run -
Enable and start the service:
sv-enable termux-notification-sse
The service will now run automatically and restart if it crashes. You can check its status with:
source $PREFIX/etc/profile # If not already done
sv status termux-notification-sse
Stop the service with:
sv down termux-notification-sse
Restart the service with:
sv restart termux-notification-sse
Configuration for MCP Clients
Add to your MCP client configuration (e.g., Claude Desktop):
{
"mcpServers": {
"termux-notifications": {
"command": "npx",
"args": ["termux-notification-list-mcp"]
}
}
}
For SSE clients, connect to http://localhost:3000/sse
Available Tools
waitForNotification
Start monitoring for new Android notifications. Returns immediately and sends notifications via server events as they arrive.
Parameters:
timeout(optional): Number of seconds to monitor before automatically stopping
Example:
// Monitor indefinitely
await client.callTool({
name: 'waitForNotification',
arguments: {}
});
// Monitor for 30 seconds
await client.callTool({
name: 'waitForNotification',
arguments: { timeout: 30 }
});
stopWaitingForNotification
Stop monitoring for new notifications.
Parameters: None
Example:
await client.callTool({
name: 'stopWaitingForNotification',
arguments: {}
});
getCurrentNotifications
Retrieve all currently active Android notifications.
Parameters:
packageName(optional): Filter notifications by specific app package namelimit(optional): Limit the number of notifications returned (1-100)
Example:
// Get all notifications
await client.callTool({
name: 'getCurrentNotifications',
arguments: {}
});
// Get notifications from a specific app
await client.callTool({
name: 'getCurrentNotifications',
arguments: { packageName: 'com.bca.mybca.omni.android' }
});
// Get first 5 notifications
await client.callTool({
name: 'getCurrentNotifications',
arguments: { limit: 5 }
});
Notification Data Structure
Each notification contains the following fields:
interface Notification {
id: number; // Unique notification ID
tag: string; // Notification tag
key: string; // Unique notification key
group: string; // Notification group
packageName: string; // App package name that created the notification
title: string; // Notification title
content: string; // Notification content/body
when: string; // Timestamp when notification was created
}
Server Events
The server sends real-time notifications via MCP's notification system:
- New Notification Event: Sent when
waitForNotificationis active and a new notification arrives - Error Events: Sent when monitoring encounters errors
Best Practices
- Monitoring Lifecycle: Always call
stopWaitingForNotificationwhen done monitoring to free resources - Error Handling: Handle cases where
termux-notification-listcommand is not available - Privacy: Be mindful that this tool can access all Android notifications - implement appropriate access controls
- Performance: Use
limitparameter when you only need recent notifications
Security Considerations
- This server provides access to all Android notifications, which may contain sensitive information
- Ensure proper authentication and authorization when deploying
- Consider implementing filtering or access controls for production use
- Follow the principle of least privilege
Troubleshooting
termux-notification-list command not found
- Ensure Termux:API is installed
- Verify
termux-apipackage is installed:pkg install termux-api - Check that notification permissions are granted in Android settings
No notifications received
- Verify Termux:API has notification access permissions
- Check that there are active notifications to read
- Ensure the monitoring is actually started with
waitForNotification
Permission denied errors
- Grant all requested permissions to Termux:API in Android settings
- Restart Termux after granting permissions
Development
Building
npm run build
Testing
npm test
Running in Development
npx tsx app/cli.ts
License
FSL-1.1-MIT - See LICENSE file for details.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。