Plex Assistant MCP

Plex Assistant MCP

Enables users to manage and control their Plex media library through natural language commands in MCP-compatible AI clients. It supports searching content, managing playlists, tracking library statistics, and monitoring live viewing sessions.

Category
访问服务器

README

Plex Assistant MCP

🎬 MCP (Model Context Protocol) server for managing your Plex library through AI assistants like Claude.

Plex Assistant MCP enables you to control Plex directly from Claude Desktop or any MCP-compatible client. Search for content, manage playlists, mark items as watched, and get library statistics using natural language!

Features

  • 🔍 Search - Find movies, shows, music, and photos across all libraries
  • 📊 Statistics - View library overview and content breakdown
  • 👥 Live Sessions - See who's watching what right now
  • 📋 Playlists - Create, view, and manage playlists
  • Watchlist - Mark content as watched/unwatched
  • 🏷️ Collections - Organize content into custom collections
  • 📡 Server Info - Get Plex server details and status
  • 🎯 Advanced Search - Filter by library, media type, and more

Prerequisites

  • Python ≥ 3.12
  • uv - Fast Python package manager (Install here)
  • Plex Server - Running instance with admin access
  • Claude Desktop - Latest version (or any MCP-compatible client)

Quick Start

1. Clone or Create Project

# Create project directory
mkdir plex-assistant-mcp
cd plex-assistant-mcp

# Or clone if you have a repo
git clone https://github.com/yourusername/plex-assistant-mcp.git
cd plex-assistant-mcp

2. Initialize with uv

# Initialize Python project
uv init

# Install dependencies
uv sync

3. Configure Plex Connection

Create a .env file at the project root:

PLEX_URL=http://your-ip:32400
PLEX_TOKEN=your-plex-auth-token

How to Find Your Plex Token

Method 1: Using PlexAPI (Automatic)

python3 -c "from plexapi.myplex import MyPlexAccount; account = MyPlexAccount(username='your-email', password='your-password'); print(account.authenticationToken)"

Method 2: Browser DevTools

  1. Open https://app.plex.tv/desktop/
  2. Open DevTools (F12) → Network tab
  3. Look for any request to plex.tv
  4. Find header X-Plex-Token - copy that value

Method 3: Plex Settings

  1. Open Plex Web App
  2. Settings → Your Account → Scroll to "Authorized Applications"
  3. Generate a token in your Plex account settings

4. Configure Claude Desktop

Edit your Claude Desktop configuration file:

Windows:

%APPDATA%\Claude\claude_desktop_config.json

macOS:

~/Library/Application Support/Claude/claude_desktop_config.json

Linux:

~/.config/Claude/claude_desktop_config.json

Add the following MCP server configuration:

{
  "mcpServers": {
    "plex-assistant": {
      "command": "uv",
      "args": [
        "--directory",
        "C:/Users/YourUsername/Documents/plex-assistant-mcp",
        "run",
        "src/plex_assistant_mcp/main.py"
      ],
      "env": {
        "PLEX_URL": "http://localhost:32400",
        "PLEX_TOKEN": "your-actual-token-here"
      }
    }
  }
}

Important:

  • Update the --directory path to match your installation
  • Replace PLEX_URL with your actual Plex server address
  • Replace PLEX_TOKEN with your actual authentication token

5. Restart Claude Desktop

Close and reopen Claude Desktop. The Plex tools will now be available!

Usage Examples

Search for Content

"Search for The Matrix in my library"
"Find all movies from 2024"
"Show me TV shows with drama in the title"

Library Management

"How many items do I have in my Plex library?"
"Show me my movie library statistics"
"What libraries do I have?"

Active Sessions

"Who's watching something right now?"
"Show me current Plex sessions"

Watchlist & Marking

"Mark The Dark Knight as watched"
"Add Oppenheimer to my watchlist"
"Mark this show as unwatched"

Playlists

"Create a playlist called Favorites"
"Show me all my playlists"
"Get my available playlists"

Collections

"Add this to my Sci-Fi collection"
"Mark Inception as part of my Best Movies collection"

Available Tools

Tool Description
test_plex_connection Test connection to Plex server
get_server_info Get Plex server details
get_libraries List all media libraries
get_library_statistics Get library statistics and breakdown
search_content Search across all libraries
search_in_library Search within a specific library
get_currently_playing See active sessions and what's being watched
get_playlists List all playlists
create_playlist Create a new playlist
add_to_watchlist Add item to watchlist
toggle_watched Mark content as watched/unwatched
mark_collection Add item to a collection

Local Development & Testing

Run the MCP Server Directly

export PLEX_URL="http://your-ip:32400"
export PLEX_TOKEN="your-token"
uv run src/plex_assistant_mcp/main.py

The server will start and wait for MCP commands via stdio.

Test Connection

python3 << 'EOF'
from src.plex_assistant_mcp.plex_client import PlexClient
import os

client = PlexClient(
    os.getenv("PLEX_URL", "http://localhost:32400"),
    os.getenv("PLEX_TOKEN", "")
)
print("Connection test:", client.test_connection())
print("Server info:", client.get_server_info())
EOF

Project Structure

plex-assistant-mcp/
├── src/
│   └── plex_assistant_mcp/
│       ├── __init__.py           # Package initialization
│       ├── main.py               # MCP server entry point
│       ├── plex_client.py         # Plex API wrapper
│       └── tools.py              # MCP tool definitions & handlers
├── pyproject.toml                # Project configuration
├── requirements.txt              # Python dependencies
├── .env.example                  # Example environment variables
└── README.md                     # This file

Troubleshooting

Error: PLEX_TOKEN environment variable not set

Solution: Make sure your .env file exists and contains:

PLEX_URL=http://your-ip:32400
PLEX_TOKEN=your-token

Error: Connection refused or Unable to connect

Solutions:

  • Verify Plex is running on your server
  • Check that the PLEX_URL is correct (including IP and port)
  • Test the URL in your browser: http://your-ip:32400
  • Check firewall rules on your server
  • Ensure Claude Desktop can reach your Plex server

Error: HTTP 401: Unauthorized

Solutions:

  • Verify your PLEX_TOKEN is correct
  • Generate a new token if the old one expired
  • Ensure you're using the correct authentication token format

Error: No results found for search

Solutions:

  • Try different spelling or keywords
  • Use exact titles if possible
  • Check that content exists in your Plex library
  • Verify library is properly indexed

Claude Desktop Shows No Plex Tools

Solutions:

  • Verify the configuration file is properly formatted JSON
  • Restart Claude Desktop completely (not just refresh)
  • Check the MCP server logs in Claude Desktop settings
  • Verify the --directory path is correct
  • Test connection manually to ensure Plex is reachable

API Reference

PlexClient Methods

# Connection
test_connection() -> bool

# Server & Libraries
get_server_info() -> Dict[str, Any]
get_libraries() -> List[Dict[str, Any]]
get_library_statistics() -> Dict[str, Any]

# Search & Discovery
search(query: str, limit: int = 20) -> List[Dict[str, Any]]
search_in_library(query: str, library_key: str, media_type: str = "") -> List[Dict[str, Any]]
find_item(title: str) -> Optional[Dict[str, Any]]

# Sessions
get_currently_playing() -> List[Dict[str, Any]]

# Playlists
get_playlists() -> List[Dict[str, Any]]
create_playlist(title: str, items: Optional[List] = None, description: str = "") -> Dict[str, Any]

# Content Management
set_watched(item_key: str) -> bool
set_unwatched(item_key: str) -> bool
add_to_collection(item_key: str, collection_name: str) -> bool
remove_from_collection(item_key: str, collection_name: str) -> bool

Resources

Contributing

Contributions are welcome! Feel free to:

  • Report bugs and issues
  • Suggest new features
  • Submit pull requests
  • Improve documentation

License

This project is open source and available under the MIT License.

Disclaimer

This project is not officially affiliated with Plex or Anthropic. Use at your own risk and ensure you have proper authorization to access your Plex server.


Made with ❤️ for Plex enthusiasts who want AI-powered library management

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选