MCP Notification Server
by whocaresthat
README.md
# MCP Notification Server - Complete Demonstration
A **comprehensive, production-ready demonstration** of MCP (Model Context Protocol) notifications and subscriptions with working examples, multiple patterns, interactive demos, and complete documentation.
## π― What's This?
This repository provides the **most complete demonstration** of MCP notifications available, including:
- Working server implementations (basic and advanced)
- Interactive client demos
- Real-world notification patterns
- Comprehensive testing scenarios
- Complete architecture documentation
- Step-by-step guides
Perfect for learning how to implement notifications in your own MCP servers!
## β‘ Quick Start
**Get running in 5 minutes** β [**QUICKSTART.md**](./QUICKSTART.md)
```bash
git clone https://github.com/whocaresthat/mcp-notification-server.git
cd mcp-notification-server
npm install
npm run build
# Run interactive demo
node dist/examples/client.js
```
## π Complete Documentation
| Document | Description |
|----------|-------------|
| π [**QUICKSTART.md**](./QUICKSTART.md) | Get up and running in 5 minutes |
| π¬ [**DEMO.md**](./DEMO.md) | Interactive demonstration walkthrough |
| ποΈ [**ARCHITECTURE.md**](./ARCHITECTURE.md) | System design, patterns, and best practices |
| π§ͺ [**test-scenarios.md**](./examples/test-scenarios.md) | 10 comprehensive test scenarios |
| π [**patterns.md**](./examples/patterns.md) | 7 notification patterns with code examples |
## β¨ Features
### Three Implementation Levels
1. **Basic Server** ([src/index.ts](./src/index.ts))
- Simple, easy to understand
- Core notification concepts
- Perfect for learning
2. **Advanced Server** ([examples/advanced-server.ts](./examples/advanced-server.ts))
- File system watching
- Webhook endpoints
- Periodic updates
- Production patterns
3. **Interactive Client** ([examples/client.ts](./examples/client.ts))
- Full client implementation
- Automated demo
- Shows notifications in action
### Comprehensive Examples
β
Event-driven notifications
β
Periodic updates (timers)
β
File system monitoring
β
Webhook integration
β
Threshold-based alerts
β
Batched notifications
β
Multiple subscribers
β
Subscription lifecycle management
## π What You'll Learn
### For Beginners
- β What are MCP notifications?
- β How to enable subscriptions
- β Sending your first notification
- β Testing with Claude Desktop
### For Advanced Users
- β Production-ready patterns
- β Performance optimization
- β Error handling strategies
- β Security considerations
- β Scalability patterns
## π Usage
### Option 1: Interactive Demo
```bash
npm install
npm run build
node dist/examples/client.js
```
See notifications in action with automated demo!
### Option 2: Claude Desktop
Add to your Claude config:
```json
{
"mcpServers": {
"notification-demo": {
"command": "node",
"args": ["/absolute/path/to/mcp-notification-server/dist/index.js"]
}
}
}
```
Then try in Claude:
- "Subscribe to counter://main"
- "Increment the counter by 5"
- "What's the current counter value?"
### Option 3: MCP Inspector
```bash
npx @modelcontextprotocol/inspector dist/index.js
```
Open http://localhost:5173 for interactive testing.
### Option 4: Custom Integration
Use the code as a template for your own MCP server!
## π Documentation Highlights
### Architecture Overview
```
Client ββsubscribeββ> Server
Client <ββnotifyβββββββ
```
The server:
1. Accepts subscriptions from clients
2. Monitors resources for changes
3. Automatically notifies subscribers
4. Manages subscription lifecycle
See [ARCHITECTURE.md](./ARCHITECTURE.md) for complete details.
### Notification Patterns
From [patterns.md](./examples/patterns.md):
1. **Event-Driven** - User actions trigger notifications
2. **Periodic** - Regular updates (timers)
3. **File System** - Monitor file changes
4. **Threshold** - Alert on important values
5. **Batched** - Group notifications
6. **Filtered** - Conditional updates
7. **Cascading** - Related resource updates
### Test Scenarios
From [test-scenarios.md](./examples/test-scenarios.md):
- Basic subscribe and notify
- Multiple subscribers
- Unsubscribe behavior
- Multiple resources
- Error handling
- Performance under load
- Connection loss recovery
- And more...
## π― Real-World Use Cases
This demonstration shows patterns for:
- π **Real-time Dashboards** - Live data updates
- π **System Monitoring** - Health checks and alerts
- π **File Synchronization** - Hot-reload configurations
- π **Log Streaming** - Real-time log viewing
- π¨ **Alert Systems** - Threshold-based notifications
- π₯ **Collaboration Tools** - Multi-user updates
- π **Analytics** - Live metrics tracking
## π¦ What's Included
```
mcp-notification-server/
βββ π QUICKSTART.md # 5-minute setup guide
βββ π DEMO.md # Interactive walkthrough
βββ π ARCHITECTURE.md # System design docs
βββ src/
β βββ index.ts # Basic server (start here!)
βββ examples/
β βββ advanced-server.ts # Production patterns
β βββ client.ts # Interactive demo
β βββ patterns.md # 7 notification patterns
β βββ test-scenarios.md # Testing guide
β βββ run-demo.sh # Easy demo runner
βββ package.json
βββ tsconfig.json
```
## π§ Development
```bash
# Install dependencies
npm install
# Build everything
npm run build
# Run basic server
npm start
# Run advanced server
node dist/examples/advanced-server.js
# Run interactive client demo
node dist/examples/client.js
```
## π Code Examples
### Minimal Server
```typescript
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
const server = new Server(
{ name: "my-server", version: "1.0.0" },
{ capabilities: { resources: { subscribe: true } } }
);
// Handle subscriptions
server.setRequestHandler(SubscribeRequestSchema, async (request) => {
subscriptions.set(clientId, request.params.uri);
return {};
});
// Send notifications
await server.notification({
method: "notifications/resources/updated",
params: { uri: "resource://example" }
});
```
### Minimal Client
```typescript
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
// Handle notifications
client.setNotificationHandler({
method: "notifications/resources/updated",
handler: async (notification) => {
console.log(`Updated: ${notification.params.uri}`);
}
});
// Subscribe
await client.request({
method: "resources/subscribe",
params: { uri: "resource://example" }
});
```
## π§ͺ Testing
Run the comprehensive test scenarios:
```bash
# See all test scenarios
cat examples/test-scenarios.md
# Run with MCP Inspector
npx @modelcontextprotocol/inspector dist/index.js
```
## π Key Features
| Feature | Basic Server | Advanced Server |
|---------|--------------|-----------------|
| Subscribe/Unsubscribe | β
| β
|
| Tool-triggered notifications | β
| β
|
| File system watching | β | β
|
| Periodic updates | β | β
|
| Webhook integration | β | β
|
| Multiple subscribers | β
| β
|
| Error handling | β
| β
|
| Performance optimized | Basic | β
|
## π€ Contributing
Contributions welcome! Please:
1. Read [ARCHITECTURE.md](./ARCHITECTURE.md)
2. Check [test-scenarios.md](./examples/test-scenarios.md)
3. Add tests for new features
4. Update documentation
## π Learn More
- π [MCP Specification](https://spec.modelcontextprotocol.io)
- π§ [MCP TypeScript SDK](https://github.com/modelcontextprotocol/typescript-sdk)
- π [MCP Documentation](https://modelcontextprotocol.io)
- π¬ [MCP Community](https://github.com/modelcontextprotocol/community)
## π― Next Steps
1. **Start Here** β [QUICKSTART.md](./QUICKSTART.md)
2. **Try Demo** β `node dist/examples/client.js`
3. **Read Patterns** β [patterns.md](./examples/patterns.md)
4. **Understand Design** β [ARCHITECTURE.md](./ARCHITECTURE.md)
5. **Build Your Own** β Use this as a template!
## π License
MIT License - See [LICENSE](./LICENSE) file for details
---
## π Why This Repository?
This is the **most comprehensive MCP notification demonstration** available because it includes:
- β
Three levels of implementation (basic, advanced, client)
- β
Seven real-world notification patterns
- β
Complete architecture documentation
- β
Ten comprehensive test scenarios
- β
Interactive demos you can run immediately
- β
Production-ready code you can use as a template
- β
Step-by-step guides for every skill level
**Ready to master MCP notifications?** Start with [QUICKSTART.md](./QUICKSTART.md)! π
This server cannot be deployed
Maintenance
ActivityInactive
ResponsivenessNo recent community issues