Plex

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

Plex MCP Server

A Model Context Protocol (MCP) server that provides AI assistants with comprehensive access to your Plex Media Server. Query your libraries, get viewing statistics, and manage your media through natural language interactions.

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?"

✨ Features

šŸ“š Library Management

  • Browse all Plex libraries
  • Search across movies, TV shows, music, and more
  • Get detailed metadata for any media item

šŸ“Š Tautulli-Style Analytics

  • Comprehensive viewing statistics
  • User activity tracking
  • Popular content analysis
  • Watch history with progress tracking
  • Library usage metrics

šŸŽÆ Smart Querying

  • Recently watched content
  • Fully watched movies/shows
  • Continue watching (On Deck)
  • Recently added media

šŸš€ Quick Start

Prerequisites

  • Node.js 18+
  • Plex Media Server (any recent version)
  • Plex Token (How to get your token)
  • MCP-compatible client (Claude Desktop, etc.)

Installation

# Clone the repository
git clone https://github.com/niavasha/plex-mcp-server.git
cd plex-mcp-server

# Install dependencies
npm install

# Build the project
npm run build

Configuration

  1. Get your Plex token (see instructions below)

  2. Create environment file:

# Copy the example environment file
cp .env.example .env

# Edit with your details
PLEX_URL=http://localhost:32400
PLEX_TOKEN=your_plex_token_here
  1. Configure your MCP client:

Add to your MCP client configuration (e.g., Claude Desktop):

{
  "mcpServers": {
    "plex": {
      "command": "node",
      "args": ["/path/to/plex-mcp-server/build/index.js"],
      "env": {
        "PLEX_URL": "http://localhost:32400",
        "PLEX_TOKEN": "your_plex_token_here"
      }
    }
  }
}

Usage

Once configured, you can ask your AI assistant:

šŸŽ¬ "What movies did I watch last week?"
šŸ“ŗ "Show me my most popular TV shows this month"
šŸ“Š "Give me viewing statistics for the past 30 days"
šŸ” "Search for Christopher Nolan movies in my library"
ā–¶ļø "What's on my continue watching list?"
šŸ“š "List all my Plex libraries"

šŸ› ļø Available Functions

FunctionDescriptionExample Usage
get_librariesList all Plex libraries"What libraries do I have?"
search_mediaSearch across all media"Find movies with Tom Hanks"
get_recently_addedRecently added content"What's new on my server?"
get_on_deckContinue watching list"What should I continue watching?"
get_media_detailsDetailed media info"Tell me about The Matrix"
get_recently_watchedRecently watched content"What did I watch yesterday?"
get_fully_watchedCompleted content"Show me all watched movies"
get_watch_historyDetailed watch sessions"Show my viewing history"
get_watch_statsViewing analytics"My watching statistics"
get_user_statsUser activity data"Who watches the most?"
get_library_statsLibrary information"Tell me about my movie library"
get_popular_contentMost popular media"What's trending on my server?"

šŸ”‘ 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

plex-mcp-server/
ā”œā”€ā”€ src/
│   └── index.ts          # Main MCP server implementation
ā”œā”€ā”€ build/                # Compiled JavaScript output
ā”œā”€ā”€ package.json          # Node.js dependencies and scripts
ā”œā”€ā”€ tsconfig.json         # TypeScript configuration
ā”œā”€ā”€ .env.example          # Environment variables template
ā”œā”€ā”€ README.md             # This file
└── LICENSE               # MIT License

šŸ”§ Development

Scripts

# Development mode with auto-reload
npm run dev

# Build for production
npm run build

# Start production server
npm start

# Run tests (if implemented)
npm test

Building from Source

# Clone and setup
git clone https://github.com/niavasha/plex-mcp-server.git
cd plex-mcp-server
npm install

# Development
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

šŸ› Troubleshooting

Common Issues

Connection refused:

  • Verify your Plex server is running
  • Check the PLEX_URL in your .env file
  • Ensure the port (usually 32400) is correct

Authentication errors:

  • Verify your Plex token is correct
  • Check token permissions in Plex settings
  • Ensure token hasn't expired

Empty responses:

  • Some features require Plex Pass
  • Check if your libraries are accessible
  • Verify media has been scanned and is available

MCP client issues:

  • Ensure the path to build/index.js is correct
  • Check that Node.js is in your system PATH
  • Verify environment variables are set in client config

Getting Help

šŸ“‹ Requirements

  • Node.js 18.0.0 or higher
  • Plex Media Server (any recent version)
  • Network access between MCP server and Plex server
  • Valid Plex token with appropriate permissions

šŸ”’ 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

šŸ“„ 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 ā¤ļø for the Plex and AI community

Related Servers