This MCP server provides access to Sveriges Radio's P3 channel music playlists, enabling AI assistants to fetch current and historical playlist data from SR's official Open API.
Current Playlist Access
Fetch the currently playing song, previous song, and next song on P3 with full details (artist, title, album, and UTC timestamps)
Historical Playlist Search
Search P3's playlist history by specific date or date range (within the last 90 days)
Filter results by artist name using case-insensitive matching
Limit the number of songs returned (1-100, default 25)
Key Features
Rate limited to 10 requests per minute to respect SR's infrastructure
Robust input validation ensuring dates are valid, not in the future, and within the 90-day window
User-friendly error handling for timeouts, invalid inputs, and rate limits
Structured JSON responses with standardized song metadata
No authentication required
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@SR P3 MCP ServerFind all songs by Zara Larsson played on P3 yesterday"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
SR P3 MCP Server
A Model Context Protocol (MCP) server that provides access to Sveriges Radio's P3 channel music playlists. This server enables AI assistants to fetch current and historical playlist data from P3, Sweden's popular music radio station.
Features
Real-time Current Playlist: Get the currently playing song, previous song, and next song on P3
Historical Playlist Search: Search P3's playlist history by date or date range (last 90 days)
Artist Filtering: Filter historical results by artist name
Rate Limiting: Built-in rate limiting (10 requests/minute) to respect SR's infrastructure
Input Validation: Robust input validation using Zod schemas
Error Handling: User-friendly error messages with graceful degradation
Installation
Prerequisites
Node.js 18 or higher
npm or yarn
Setup
Clone this repository:
Install dependencies:
Build the TypeScript code:
Usage
Configuring with Claude Desktop
To use this server with Claude Desktop, you need to add it to your Claude Desktop configuration:
Build the server (see Installation above)
Find your Claude Desktop config file:
macOS:
~/Library/Application Support/Claude/claude_desktop_config.jsonWindows:
%APPDATA%\Claude\claude_desktop_config.jsonLinux:
~/.config/Claude/claude_desktop_config.json
Add the server to your config:
Restart Claude Desktop
See CONFIGURATION.md for detailed setup instructions, including platform-specific examples.
Running Locally
Start the server:
The server runs on stdio transport, suitable for local deployment (including Raspberry Pi).
Development Mode
For development with auto-rebuild:
In another terminal:
MCP Tools
1. get_p3_current_playlist
Fetch the currently playing song on SR P3.
Parameters: None
Returns:
Current song with artist, title, album, timestamps
Previous song
Next song
Example Response:
2. search_p3_playlist_by_date
Search P3 playlist history for a specific date or date range.
Parameters:
date(required): ISO 8601 date string or date rangeSingle date:
"2024-12-15"Date range:
"2024-12-01 to 2024-12-31"
artist_filter(optional): Filter by artist name (case-insensitive)limit(optional): Max songs to return (default: 25, max: 100)
Validation:
Date must be within last 90 days
Future dates are rejected
Date format must be ISO 8601
Example Request:
Example Response:
Technical Details
P3 Channel ID
The P3 channel ID is hardcoded as 164 in the server. This is Sveriges Radio's official channel identifier for P3.
API Integration
This server uses Sveriges Radio's Open API:
Base URL:
https://api.sr.se/api/v2/playlists/No authentication required
All requests are read-only
Responses are in JSON format
Rate Limiting
The server implements rate limiting to respect SR's infrastructure:
Maximum 10 requests per minute
Tracked per server instance
Returns helpful error messages when limit is exceeded
Error Handling
All errors are converted to user-friendly messages:
Network timeouts: "Request timed out. Please try again."
API unavailable: "Service may be temporarily unavailable."
Invalid dates: Clear explanation of valid date range
Rate limit: "Please wait X seconds before trying again."
Security
All user inputs validated with Zod schemas
No API keys or secrets required
Date inputs sanitized and validated
No raw API URLs exposed in errors
Request logging to stderr (not stdout)
Project Structure
Development
Building
Type Checking
TypeScript is configured with strict mode enabled. All code is fully typed.
Logging
Server logs are written to stderr (not stdout, which is reserved for MCP protocol). This allows for debugging without interfering with the MCP communication.
Deployment
Raspberry Pi
This server is designed for Raspberry Pi deployment:
Ensure Node.js 18+ is installed
Clone and build the project
Run with
npm startConfigure your MCP client to connect via stdio
Docker (Optional)
A Dockerfile can be added for containerized deployment if needed.
Testing
Basic functionality test:
This runs the server and verifies it starts without errors.
API Reference
For more information about Sveriges Radio's Open API:
License
MIT
Contributing
Contributions are welcome! Please ensure:
All inputs are validated
Error messages are user-friendly
Code follows TypeScript best practices
Tests pass before submitting PRs
Support
For issues or questions:
GitHub Issues: github.com/tomellen/mcpsrtest/issues
Acknowledgments
Built with:
@modelcontextprotocol/sdk - MCP SDK
Zod - Input validation
Axios - HTTP client
fast-xml-parser - XML parsing
Data provided by Sveriges Radio's Open API.