Labsco
niavasha logo

Plex

β˜… 35

from niavasha

Provides AI assistants with comprehensive access to a Plex Media Server.

πŸ”₯πŸ”₯πŸ”₯βœ“ VerifiedAccount requiredAdvanced setup

Plex MCP Server

A Model Context Protocol (MCP) server that provides AI assistants with comprehensive access to your Plex Media Server, Sonarr, Radarr, and Trakt.tv β€” all from a single unified server.

<a href="https://glama.ai/mcp/servers/@niavasha/plex-mcp-server"> <img width="380" height="200" src="https://glama.ai/mcp/servers/@niavasha/plex-mcp-server/badge" alt="Plex Server MCP server" /> </a>

TypeScript Node.js MCP License: MIT

What is this?

This MCP server transforms your Plex Media Server into an AI-queryable database. Ask your AI assistant questions like:

  • "What movies have I watched recently?"
  • "Show me my viewing statistics for the past month"
  • "What's the most popular content on my server?"
  • "Find action movies in my library"
  • "What's on my continue watching list?"
  • "Add that new show to Sonarr"
  • "What's in my download queue?"
  • "Sync my watch history to Trakt"
  • "Recommend me some movies I haven't seen"

Features

45 tools out of the box (54 with write operations enabled):

  • Plex Library Management β€” Browse libraries, search media, get detailed metadata, list playlists and watchlist
  • Tautulli-Style Analytics β€” Viewing statistics, user activity, popular content, watch history
  • Personalized Recommendations β€” AI-powered movie suggestions based on your watch history, genres, directors, and actors. Supports per-user profiles for multi-user Plex servers.
  • Sonarr/Radarr Integration β€” Browse, search, add series/movies, view queues, trigger downloads
  • Trakt.tv Sync β€” OAuth authentication, watch history sync, enhanced statistics, scrobbling. When configured, Trakt data enriches recommendations by catching movies watched outside Plex.
  • Write Operations (opt-in) β€” Create/edit playlists, update metadata, manage watchlist

One server, all tools. Trakt and Sonarr/Radarr credentials are optional β€” tools that need them return a helpful setup message if the key is missing. You don't need to configure everything upfront.

Available Functions

Plex Tools (19 tools)

FunctionDescription
get_librariesList all Plex libraries
get_library_itemsList items in a library with pagination
export_libraryExport a full library to JSON (under ./exports)
search_mediaSearch media globally or within one library
get_recently_addedRecently added content
get_on_deckContinue watching list
get_media_detailsDetailed media info
get_editable_fieldsShow editable fields and available tags for an item
get_playlistsList all Plex playlists
get_playlist_itemsList items in a playlist
get_watchlistGet current Plex watchlist
get_recently_watchedRecently watched content
get_watch_historyDetailed watch sessions
get_fully_watchedFully watched movies/shows
get_watch_statsComprehensive viewing statistics
get_user_statsUser activity statistics
get_library_statsLibrary usage metrics
get_popular_contentMost popular content analysis
get_recommendationsPersonalized movie recommendations based on your watch history

Write Operations (9 tools, opt-in)

Set PLEX_ENABLE_MUTATIVE_OPS=true to enable these tools. They allow your AI assistant to make changes to your Plex server. Use with care β€” while we test these tools, there are no guarantees. Review changes your assistant proposes before confirming.

FunctionDescription
update_metadataUpdate metadata fields and editable tags for a media item
update_metadata_from_jsonApply a metadata JSON payload using best-effort field mapping
create_playlistCreate a new smart or static playlist
add_to_playlistAdd a media item to a playlist
remove_from_playlistRemove an item from a playlist
clear_playlistPreview and optionally clear all items from a playlist (confirm=true)
delete_playlistDelete a playlist without deleting the underlying media
add_to_watchlistAdd a media item to the Plex watchlist
remove_from_watchlistRemove a media item from the Plex watchlist

Sonarr Tools (8 tools)

FunctionDescription
sonarr_get_seriesList series with optional title filter
sonarr_searchSearch TheTVDB for new series
sonarr_add_seriesAdd series by TVDB ID
sonarr_get_missingMissing/wanted episodes
sonarr_get_queueDownload queue
sonarr_get_calendarUpcoming episodes
sonarr_get_profilesQuality profiles and root folders
sonarr_trigger_searchTrigger missing episode search

Radarr Tools (8 tools)

FunctionDescription
radarr_get_moviesList movies with optional title filter
radarr_searchSearch TMDB for new movies
radarr_add_movieAdd movie by TMDB ID
radarr_get_missingMissing/wanted movies
radarr_get_queueDownload queue
radarr_get_calendarUpcoming movies
radarr_get_profilesQuality profiles and root folders
radarr_trigger_searchTrigger missing movie search

Cross-Service Tools (1 tool)

FunctionDescription
arr_get_statusCheck Sonarr/Radarr connection status

Trakt Tools (9 tools)

FunctionDescription
trakt_authenticateStart Trakt.tv OAuth flow
trakt_complete_authComplete authentication
trakt_get_auth_statusCheck auth status
trakt_sync_to_traktSync Plex history to Trakt
trakt_sync_from_traktGet Trakt data for comparison
trakt_get_user_statsEnhanced stats from Trakt
trakt_searchSearch Trakt database
trakt_start_scrobblingReal-time scrobbling
trakt_get_sync_statusCheck sync operation status

Getting Your Plex Token

  1. Open Plex Web App in your browser
  2. Navigate to Settings > Account > Privacy
  3. Click "Show Advanced" at the bottom
  4. Copy your Plex Token

Alternative method:

  • Visit: http://YOUR_PLEX_IP:32400/web/index.html#!/settings/account
  • Look for the "Plex Token" field

Project Structure

Copy & paste β€” that's it
plex-mcp-server/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ plex-mcp-server.ts    # Unified server entry point (44+ tools)
β”‚   β”œβ”€β”€ index.ts               # Deprecated shim β†’ plex-mcp-server
β”‚   β”œβ”€β”€ plex-arr-server.ts     # Deprecated shim β†’ plex-mcp-server
β”‚   β”œβ”€β”€ plex-trakt-server.ts   # Deprecated shim β†’ plex-mcp-server
β”‚   β”œβ”€β”€ plex/                  # Shared Plex module
β”‚   β”‚   β”œβ”€β”€ client.ts          #   Plex API client
β”‚   β”‚   β”œβ”€β”€ tools.ts           #   Plex tool implementations
β”‚   β”‚   β”œβ”€β”€ tool-registry.ts   #   Map-based tool dispatch
β”‚   β”‚   β”œβ”€β”€ tool-schemas.ts    #   MCP tool schema definitions
β”‚   β”‚   β”œβ”€β”€ constants.ts       #   Configuration defaults
β”‚   β”‚   └── types.ts           #   TypeScript type definitions
β”‚   β”œβ”€β”€ arr/                   # Sonarr/Radarr module
β”‚   β”‚   β”œβ”€β”€ client.ts          #   Base ArrClient + Sonarr/Radarr subclasses
β”‚   β”‚   β”œβ”€β”€ mcp-functions.ts   #   Tool implementations (17 tools)
β”‚   β”‚   β”œβ”€β”€ tool-registry.ts   #   Map-based tool dispatch
β”‚   β”‚   β”œβ”€β”€ tool-schemas.ts    #   MCP tool schema definitions
β”‚   β”‚   β”œβ”€β”€ constants.ts       #   Configuration defaults
β”‚   β”‚   └── types.ts           #   TypeScript type definitions
β”‚   β”œβ”€β”€ trakt/                 # Trakt.tv module
β”‚   β”‚   β”œβ”€β”€ client.ts          #   Trakt API client + OAuth
β”‚   β”‚   β”œβ”€β”€ sync.ts            #   Plex-to-Trakt sync engine
β”‚   β”‚   β”œβ”€β”€ mapper.ts          #   Plex-to-Trakt data mapping
β”‚   β”‚   β”œβ”€β”€ mcp-functions.ts   #   Tool implementations (9 tools)
β”‚   β”‚   β”œβ”€β”€ tool-registry.ts   #   Map-based tool dispatch
β”‚   β”‚   └── tool-schemas.ts    #   MCP tool schema definitions
β”‚   β”œβ”€β”€ shared/                # Shared utilities
β”‚   β”‚   └── utils.ts           #   truncate, sleep, chunkArray
β”‚   └── __tests__/             # Test suite (94 tests)
β”œβ”€β”€ build/                     # Compiled JavaScript output
β”œβ”€β”€ docs/                      # Documentation
β”œβ”€β”€ package.json
β”œβ”€β”€ tsconfig.json
β”œβ”€β”€ vitest.config.ts
β”œβ”€β”€ .env.example               # Environment variables template
└── README.md

Development

Scripts

Copy & paste β€” that's it
# Development mode with auto-reload
npm run dev

# Build for production
npm run build

# Start production server
npm start

# Run tests
npm test
npm run test:watch

Building from Source

Copy & paste β€” that's it
git clone https://github.com/niavasha/plex-mcp-server.git
cd plex-mcp-server
npm install
npm run dev

Contributing

Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.

Development Guidelines

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Security Notes

  • Keep your Plex token secure - never commit it to version control
  • Use environment variables for sensitive configuration
  • Run on trusted networks - the server communicates directly with Plex
  • Regular token rotation - consider refreshing tokens periodically
  • Write operations are disabled by default β€” enable only if you trust your AI assistant's judgment

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

  • Anthropic for the Model Context Protocol
  • Plex for the amazing media server
  • Tautulli for analytics inspiration
  • The open-source community for various libraries and tools

Related Projects


Built with love for the Plex and AI community