plex-mcp 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,17 @@
1
+ {
2
+ "permissions": {
3
+ "allow": [
4
+ "Bash(mkdir:*)",
5
+ "Bash(npm test)",
6
+ "Bash(npm run test:coverage:*)",
7
+ "Bash(grep:*)",
8
+ "Bash(npm test:*)",
9
+ "Bash(node:*)",
10
+ "Bash(rg:*)",
11
+ "Bash(/opt/homebrew/Cellar/ripgrep/14.1.1/bin/rg -n -A 10 -B 5 \"POST\" /Users/blutharsch/src/plex/mcp/index.js)",
12
+ "Bash(rm:*)",
13
+ "Bash(touch:*)"
14
+ ],
15
+ "deny": []
16
+ }
17
+ }
@@ -0,0 +1,85 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [ main, develop ]
6
+ pull_request:
7
+ branches: [ main, develop ]
8
+
9
+ jobs:
10
+ test:
11
+ runs-on: ubuntu-latest
12
+
13
+ strategy:
14
+ matrix:
15
+ node-version: [16.x, 18.x, 20.x]
16
+
17
+ steps:
18
+ - name: Checkout code
19
+ uses: actions/checkout@v4
20
+
21
+ - name: Use Node.js ${{ matrix.node-version }}
22
+ uses: actions/setup-node@v4
23
+ with:
24
+ node-version: ${{ matrix.node-version }}
25
+ cache: 'npm'
26
+
27
+ - name: Install dependencies
28
+ run: npm ci
29
+
30
+ - name: Run linter
31
+ run: npm run lint --if-present
32
+
33
+ - name: Run tests
34
+ run: npm test
35
+
36
+ - name: Generate test coverage
37
+ run: npm run test:coverage --if-present
38
+
39
+ - name: Upload coverage to Codecov
40
+ if: matrix.node-version == '18.x'
41
+ uses: codecov/codecov-action@v3
42
+ with:
43
+ fail_ci_if_error: false
44
+
45
+ build:
46
+ runs-on: ubuntu-latest
47
+ needs: test
48
+
49
+ steps:
50
+ - name: Checkout code
51
+ uses: actions/checkout@v4
52
+
53
+ - name: Use Node.js 18.x
54
+ uses: actions/setup-node@v4
55
+ with:
56
+ node-version: 18.x
57
+ cache: 'npm'
58
+
59
+ - name: Install dependencies
60
+ run: npm ci
61
+
62
+ - name: Build project
63
+ run: npm run build --if-present
64
+
65
+ security:
66
+ runs-on: ubuntu-latest
67
+
68
+ steps:
69
+ - name: Checkout code
70
+ uses: actions/checkout@v4
71
+
72
+ - name: Use Node.js 18.x
73
+ uses: actions/setup-node@v4
74
+ with:
75
+ node-version: 18.x
76
+ cache: 'npm'
77
+
78
+ - name: Install dependencies
79
+ run: npm ci
80
+
81
+ - name: Run security audit
82
+ run: npm audit --audit-level=moderate
83
+
84
+ - name: Check for vulnerabilities
85
+ run: npm audit fix --dry-run
@@ -0,0 +1,107 @@
1
+ name: Pull Request Tests
2
+
3
+ on:
4
+ pull_request:
5
+ types: [opened, synchronize, reopened]
6
+
7
+ jobs:
8
+ pr-checks:
9
+ runs-on: ubuntu-latest
10
+
11
+ steps:
12
+ - name: Checkout code
13
+ uses: actions/checkout@v4
14
+ with:
15
+ fetch-depth: 0
16
+
17
+ - name: Use Node.js 18.x
18
+ uses: actions/setup-node@v4
19
+ with:
20
+ node-version: 18.x
21
+ cache: 'npm'
22
+
23
+ - name: Install dependencies
24
+ run: npm ci
25
+
26
+ - name: Run tests with coverage
27
+ run: npm test -- --coverage --coverageReporters=json-summary
28
+
29
+ - name: Check test coverage
30
+ run: |
31
+ COVERAGE=$(node -p "require('./coverage/coverage-summary.json').total.lines.pct")
32
+ echo "Test coverage: ${COVERAGE}%"
33
+ if (( $(echo "$COVERAGE < 80" | bc -l) )); then
34
+ echo "❌ Test coverage is below 80%"
35
+ #TODO: uncomment me!
36
+ # exit 1
37
+ else
38
+ echo "✅ Test coverage is above 80%"
39
+ fi
40
+
41
+ - name: Lint code
42
+ run: npm run lint --if-present
43
+
44
+ - name: Check for TypeScript errors
45
+ run: npm run type-check --if-present
46
+
47
+ - name: Validate package.json
48
+ run: npm run validate --if-present
49
+
50
+ - name: Check for security vulnerabilities
51
+ run: npm audit --audit-level=high
52
+
53
+ - name: Check dependencies for updates
54
+ run: npx npm-check-updates --errorLevel 2
55
+
56
+ integration-test:
57
+ runs-on: ubuntu-latest
58
+ if: github.event.pull_request.base.ref == 'main'
59
+
60
+ steps:
61
+ - name: Checkout code
62
+ uses: actions/checkout@v4
63
+
64
+ - name: Use Node.js 18.x
65
+ uses: actions/setup-node@v4
66
+ with:
67
+ node-version: 18.x
68
+ cache: 'npm'
69
+
70
+ - name: Install dependencies
71
+ run: npm ci
72
+
73
+ - name: Run integration tests
74
+ run: npm run test:integration --if-present
75
+ env:
76
+ PLEX_URL: ${{ secrets.TEST_PLEX_URL }}
77
+ PLEX_TOKEN: ${{ secrets.TEST_PLEX_TOKEN }}
78
+
79
+ size-check:
80
+ runs-on: ubuntu-latest
81
+
82
+ steps:
83
+ - name: Checkout code
84
+ uses: actions/checkout@v4
85
+
86
+ - name: Use Node.js 18.x
87
+ uses: actions/setup-node@v4
88
+ with:
89
+ node-version: 18.x
90
+ cache: 'npm'
91
+
92
+ - name: Install dependencies
93
+ run: npm ci
94
+
95
+ - name: Check bundle size
96
+ run: |
97
+ SIZE=$(du -sk node_modules | cut -f1)
98
+ echo "Dependencies size: ${SIZE}KB"
99
+ if [ $SIZE -gt 50000 ]; then
100
+ echo "⚠️ Dependencies are quite large (>50MB)"
101
+ fi
102
+
103
+ - name: Check for large files
104
+ run: |
105
+ find . -name "*.js" -size +100k -not -path "./node_modules/*" -not -path "./coverage/*" | while read file; do
106
+ echo "⚠️ Large file detected: $file"
107
+ done
@@ -0,0 +1,30 @@
1
+ name: Release to NPM
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - 'v*'
7
+
8
+ jobs:
9
+ release:
10
+ runs-on: ubuntu-latest
11
+ steps:
12
+ - name: Checkout code
13
+ uses: actions/checkout@v4
14
+
15
+ - name: Setup Node.js
16
+ uses: actions/setup-node@v4
17
+ with:
18
+ node-version: '18'
19
+ registry-url: 'https://registry.npmjs.org'
20
+
21
+ - name: Install dependencies
22
+ run: npm ci
23
+
24
+ - name: Run tests
25
+ run: npm test
26
+
27
+ - name: Publish to NPM
28
+ run: npm publish
29
+ env:
30
+ NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
package/LICENSE ADDED
@@ -0,0 +1,46 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 vyb1ng
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+ =======
23
+ This is free and unencumbered software released into the public domain.
24
+
25
+ Anyone is free to copy, modify, publish, use, compile, sell, or
26
+ distribute this software, either in source code form or as a compiled
27
+ binary, for any purpose, commercial or non-commercial, and by any
28
+ means.
29
+
30
+ In jurisdictions that recognize copyright laws, the author or authors
31
+ of this software dedicate any and all copyright interest in the
32
+ software to the public domain. We make this dedication for the benefit
33
+ of the public at large and to the detriment of our heirs and
34
+ successors. We intend this dedication to be an overt act of
35
+ relinquishment in perpetuity of all present and future rights to this
36
+ software under copyright law.
37
+
38
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
39
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
40
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
41
+ IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
42
+ OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
43
+ ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
44
+ OTHER DEALINGS IN THE SOFTWARE.
45
+
46
+ For more information, please refer to <https://unlicense.org>
package/README.md ADDED
@@ -0,0 +1,58 @@
1
+ # Plex MCP Server
2
+
3
+ A Model Context Protocol (MCP) server for searching Plex media libraries using Claude.
4
+
5
+ ## Features
6
+
7
+ - Search movies, TV shows, episodes, music, and other content in your Plex libraries
8
+ - Filter by content type
9
+ - Configurable result limits
10
+ - Rich formatted results with metadata
11
+
12
+ ## Setup
13
+
14
+ 1. Install dependencies:
15
+ ```bash
16
+ npm install
17
+ ```
18
+
19
+ 2. Configure your Plex connection:
20
+ - Copy `.env.example` to `.env`
21
+ - Set your Plex server URL and token:
22
+ ```
23
+ PLEX_URL=http://your-plex-server:32400
24
+ PLEX_TOKEN=your_plex_token
25
+ ```
26
+
27
+ 3. Get your Plex token:
28
+ - Log into your Plex account
29
+ - Go to Settings > Account > Privacy
30
+ - Click "Show" next to "Plex Pass Subscription"
31
+ - Your token will be displayed
32
+
33
+ ## Usage
34
+
35
+ Run the MCP server:
36
+ ```bash
37
+ node index.js
38
+ ```
39
+
40
+ ## MCP Tools
41
+
42
+ ### search_plex
43
+
44
+ Search for content in your Plex libraries.
45
+
46
+ **Parameters:**
47
+ - `query` (string, required): Search query
48
+ - `type` (string, optional): Content type ("movie", "show", "episode", "artist", "album", "track")
49
+ - `limit` (number, optional): Maximum results (default: 10)
50
+
51
+ **Example:**
52
+ ```json
53
+ {
54
+ "query": "Star Wars",
55
+ "type": "movie",
56
+ "limit": 5
57
+ }
58
+ ```
package/README.txt ADDED
@@ -0,0 +1,198 @@
1
+ ================================================================================
2
+ PLEX MCP SERVER
3
+ Model Context Protocol Server for Plex
4
+ ================================================================================
5
+
6
+ DESCRIPTION
7
+ -----------
8
+ A comprehensive MCP (Model Context Protocol) server that provides AI assistants
9
+ with full access to your Plex Media Server. Search, browse, manage playlists,
10
+ analyze listening habits, and get detailed media information through a rich set
11
+ of tools.
12
+
13
+ FEATURES
14
+ --------
15
+ • Search across all Plex libraries with advanced filtering
16
+ • Browse libraries, collections, and recently added content
17
+ • Comprehensive playlist management (create, modify, delete)
18
+ • Watch history and continue watching (On Deck) access
19
+ • Music listening statistics and recommendations
20
+ • Advanced content filtering (genre, year, rating, resolution, audio format)
21
+ • Media file analysis and codec information
22
+ • Library storage and usage analytics
23
+ • Activity-based filtering (play counts, last played dates)
24
+
25
+ REQUIREMENTS
26
+ ------------
27
+ • Node.js 14+
28
+ • Plex Media Server with API access
29
+ • Valid Plex authentication token
30
+
31
+ INSTALLATION
32
+ ------------
33
+ 1. Clone this repository
34
+ 2. Install dependencies:
35
+ npm install
36
+
37
+ 3. Set environment variables:
38
+ export PLEX_URL="http://your-plex-server:32400"
39
+ export PLEX_TOKEN="your-plex-token"
40
+
41
+ 4. Run the server:
42
+ node index.js
43
+
44
+ GETTING YOUR PLEX TOKEN
45
+ -----------------------
46
+ 1. Sign in to Plex Web App
47
+ 2. Open browser developer tools (F12)
48
+ 3. Go to Network tab
49
+ 4. Refresh the page
50
+ 5. Look for requests to plex.tv with X-Plex-Token header
51
+ 6. Copy the token value
52
+
53
+ AVAILABLE TOOLS
54
+ ---------------
55
+
56
+ SEARCH & BROWSE:
57
+ • search_plex - Search across all libraries with filters
58
+ • browse_libraries - List all available Plex libraries
59
+ • browse_library - Browse content within a specific library
60
+ • browse_collections - List all Plex collections
61
+ • browse_collection - View contents of a specific collection
62
+ • get_recently_added - Show recently added content
63
+
64
+ ACTIVITY & HISTORY:
65
+ • get_watch_history - View playback history with filtering
66
+ • get_on_deck - Show continue watching items
67
+ • get_watched_status - Check watched status of content
68
+ • get_listening_stats - Music analytics and recommendations
69
+
70
+ PLAYLIST MANAGEMENT:
71
+ • list_playlists - Show all playlists with filtering
72
+ • create_playlist - Create new playlists (regular or smart)
73
+ • add_to_playlist - Add items to existing playlists
74
+ • remove_from_playlist- Remove items from playlists
75
+ • delete_playlist - Delete playlists
76
+
77
+ MEDIA INFO & STATS:
78
+ • get_media_info - Detailed file and codec information
79
+ • get_library_stats - Storage and usage analytics
80
+
81
+ FILTERING OPTIONS
82
+ -----------------
83
+
84
+ BASIC FILTERS (search_plex, browse_library):
85
+ • genre - Filter by genre (Action, Comedy, Rock, etc.)
86
+ • year - Specific release year
87
+ • year_min/year_max - Year range filtering
88
+ • studio - Studio or record label
89
+ • director/writer/actor - Cast and crew filtering
90
+ • rating_min/rating_max - Rating range (0-10 scale)
91
+ • duration_min/duration_max - Duration in minutes
92
+ • added_after/added_before - Date-based filtering
93
+
94
+ ACTIVITY FILTERS:
95
+ • play_count_min/max - Filter by play count range
96
+ • never_played - Show only unplayed content
97
+ • last_played_after/before - Filter by last played date
98
+ • played_in_last_days - Recently played content
99
+
100
+ ADVANCED FILTERS:
101
+ • content_rating - Content rating (G, PG, PG-13, R, etc.)
102
+ • resolution - Video resolution (4k, 1080, 720, sd)
103
+ • audio_format - Audio codec or quality (lossless, lossy, flac, etc.)
104
+ • file_size_min/max - File size filtering in MB
105
+
106
+ USAGE EXAMPLES
107
+ --------------
108
+
109
+ Search for action movies from 2020-2023:
110
+ {
111
+ "tool": "search_plex",
112
+ "arguments": {
113
+ "query": "action",
114
+ "type": "movie",
115
+ "genre": "Action",
116
+ "year_min": 2020,
117
+ "year_max": 2023
118
+ }
119
+ }
120
+
121
+ Browse music library for highly-rated albums never played:
122
+ {
123
+ "tool": "browse_library",
124
+ "arguments": {
125
+ "library_id": "3",
126
+ "type": "album",
127
+ "rating_min": 8,
128
+ "never_played": true,
129
+ "sort": "rating"
130
+ }
131
+ }
132
+
133
+ Get listening stats for the past month:
134
+ {
135
+ "tool": "get_listening_stats",
136
+ "arguments": {
137
+ "period": "month",
138
+ "include_recommendations": true
139
+ }
140
+ }
141
+
142
+ TESTING
143
+ -------
144
+ Run the test suite:
145
+ npm test
146
+
147
+ Run specific test suites:
148
+ npm test -- --testPathPattern=parsers.test.js
149
+ npm test -- --testPathPattern=handlers.test.js
150
+
151
+ DEVELOPMENT
152
+ -----------
153
+ The server is built using:
154
+ • Node.js with axios for HTTP requests
155
+ • Jest for testing with comprehensive unit and integration tests
156
+ • MCP (Model Context Protocol) for AI assistant integration
157
+
158
+ Project structure:
159
+ index.js - Main server implementation
160
+ tests/
161
+ unit/ - Unit tests for parsers, formatters, filters
162
+ integration/ - Integration tests for handlers
163
+ fixtures/ - Test data and mocks
164
+
165
+ ENVIRONMENT VARIABLES
166
+ ---------------------
167
+ Required:
168
+ • PLEX_URL - Your Plex server URL (e.g., http://localhost:32400)
169
+ • PLEX_TOKEN - Your Plex authentication token
170
+
171
+ Optional:
172
+ • NODE_ENV - Set to 'development' for debug logging
173
+
174
+ TROUBLESHOOTING
175
+ ---------------
176
+ • Ensure Plex server is running and accessible
177
+ • Verify PLEX_TOKEN is valid and has proper permissions
178
+ • Check network connectivity between server and Plex
179
+ • Enable debug logging with NODE_ENV=development
180
+
181
+ For 401 Unauthorized errors, regenerate your Plex token.
182
+ For connection errors, verify PLEX_URL and network settings.
183
+
184
+ LICENSE
185
+ -------
186
+ This project is open source. See LICENSE file for details.
187
+
188
+ CONTRIBUTING
189
+ ------------
190
+ 1. Fork the repository
191
+ 2. Create a feature branch
192
+ 3. Add tests for new functionality
193
+ 4. Ensure all tests pass
194
+ 5. Submit a pull request
195
+
196
+ ================================================================================
197
+ For support and updates, visit: https://github.com/vyb1ng/plex-mcp
198
+ ================================================================================