Sonos TypeScript MCP Server is a Sonos control server based on the Model Context Protocol (MCP), built from scratch in TypeScript without relying on external Sonos libraries. It communicates with Sonos audio devices over the local network via the UPnP/SOAP protocol, putting full device control capability directly in the hands of AI assistants, and is aimed at coding agents and AI-driven home audio automation workflows. All data comes from live UPnP/SOAP communication with Sonos devices to ensure accuracy and completeness.
Main capabilities include: device discovery (automatic SSDP-based discovery, performed at startup and automatically every 5 minutes, with manual device addition also available); playback control (play, pause, stop, next track, previous track); volume control (get and set volume, mute/unmute); transport information queries; zone topology queries; queue management (add, remove, reorder, save, play); DIDL-Lite metadata handling; playback attribute control (shuffle, repeat, crossfade); grouping management (join/leave multi-room groups); music library browsing (artists, albums, tracks, genres, playlists) with fuzzy search; audio/EQ control (bass, treble, loudness, night mode, dialog enhancement); sleep timer; alarm management (create, update, delete); snapshot/restore; party mode (one-click join for all devices); event subscriptions (based on the UPnP GENA protocol, with real-time notifications of playback, volume, queue, and topology changes); and the natural language agent tool sonos_agent, which can be used with an AI key. The project also provides topology persistence, smart device resolution (using friendly names instead of UUIDs), MCP prompts, and other features; more than 50 tools are currently implemented, and it is in the Phase 4 completion stage.
Usage: This server supports any MCP client that uses standard input/output (stdio) as its transport. For basic configuration, you can edit Claude Desktop's claude_desktop_config.json, Cline's cline_mcp_settings.json, Cursor's .cursor/mcp.json or ~/.cursor/mcp.json, VS Code's .vscode/mcp.json or user settings, and Windsurf's ~/.codeium/windsurf/mcp_config.json. Run modes include stdio mode (the standard way) and SSE mode (running the server as an HTTP server, suitable for web clients or remote access), configurable via the MCP_TRANSPORT environment variable, with default port 3000, and the endpoint located at http://localhost:3000/sse。项目内置基于 Mastra's CLI agent can test MCP servers using natural language, requires OPENAI_API_KEY or GOOGLE_GENERATIVE_AI_API_KEY, and optionally sets SONOS_AGENT_MODEL. The test scripts cover all implemented features. Phase 2 testing supports mock mode (using the --mock flag or MOCK_DEVICES=true), without requiring a real Sonos device; the integration test suite uses Gemini 2.5 Flash AI to verify agent output and requires GOOGLE_GENERATIVE_AI_API_KEY.
Use cases: smart home audio automation, multi-room audio experience orchestration, music library management, zone grouping, queue management, and integration with smart home platforms. The project is specifically designed for programming agents and AI-driven home audio automation workflows.
Limitations and considerations: SSDP multicast discovery may fail in some network environments due to reasons including Windows Firewall blocking UDP port 1900, network switches not correctly forwarding multicast traffic, VPN interference with multicast routing, enterprise network policies, etc.; in this case, the sonos_add_device tool can be used to manually register a device by IP address, and the server will verify connectivity before registration. SSE mode is suitable for web clients or remote access. AI agent tools require the corresponding AI API key. Some planned features (such as music service integration with Spotify and Apple Music, advanced grouping management, audio analysis and diagnostics, and MCP event tool integration) have not yet been implemented and are in the planning stage. Information such as pricing and platform limitations is not yet available.