Skip to content

feat: add MCP server plugin - #4633

Open
hwangseonu wants to merge 11 commits into
pear-devs:masterfrom
hwangseonu:feature/mcp-server-plugin
Open

feat: add MCP server plugin#4633
hwangseonu wants to merge 11 commits into
pear-devs:masterfrom
hwangseonu:feature/mcp-server-plugin

Conversation

@hwangseonu

@hwangseonu hwangseonu commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

• # Add MCP Server

Added an MCP server to the API Server plugin.

The following tools are supported:

  • music_previous, music_next, music_play, music_pause, music_toggle_playback
  • music_play_video
  • music_seek, music_set_volume
  • music_now_playing
  • music_search
  • music_enqueue, music_clear_queue

Summary by CodeRabbit

  • New Features
    • Added an optional MCP server for playback, playlists, seeking, volume, song information, search, and queue management.
    • Added a setting to enable or disable the MCP server.
    • Added support for playing videos and playlists directly by ID.
    • Added library playlist discovery and parsing.
  • Bug Fixes
    • Improved search and queue reliability with request tracking, error handling, timeouts, and cleanup.
    • Added clearer handling for unavailable songs and unsupported app features.
  • Tests
    • Added coverage for video and playlist playback navigation and library playlist parsing.

@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown

Review Change Stack

Important

Review skipped

No new commits to review since the last review.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: c311d5e5-ff84-4db6-86d4-6d3f8bdfe0bd

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 30dee4fc-a210-440f-96c1-3b8206912ff0

📥 Commits

Reviewing files that changed from the base of the PR and between ce9b232 and ac0df6f.

📒 Files selected for processing (8)
  • src/plugins/api-server/backend/routes/control.ts
  • src/plugins/api-server/backend/routes/mcp.ts
  • src/plugins/api-server/backend/routes/playlists.test.ts
  • src/plugins/api-server/backend/routes/playlists.ts
  • src/providers/play-video.test.ts
  • src/providers/play-video.ts
  • src/providers/song-controls.ts
  • src/renderer.ts
🚧 Files skipped from review as they are similar to previous changes (3)
  • src/providers/play-video.test.ts
  • src/plugins/api-server/backend/routes/control.ts
  • src/plugins/api-server/backend/routes/mcp.ts

📝 Walkthrough

Walkthrough

Adds a configurable MCP HTTP server with validated YouTube Music tools. Adds video and playlist playback plus request-correlated search, library-playlist, and queue handling across song controls and the renderer. Adds playlist parsing and MCP configuration controls.

Changes

MCP server integration

Layer / File(s) Summary
Playback and search control contract
src/providers/song-controls.ts, src/providers/play-video.ts, src/providers/play-video.test.ts, src/renderer.ts
Adds video and playlist playback, structured IPC requests, correlated responses, readiness errors, timeouts, and listener cleanup.
Correlated queue access
src/types/music-player-desktop-internal.ts, src/plugins/api-server/backend/routes/queue.ts, src/plugins/api-server/backend/routes/control.ts, src/renderer.ts
Adds request-correlated queue responses and shared helpers for selected queue items and renderers.
Library playlist parsing
src/plugins/api-server/backend/routes/playlists.ts, src/plugins/api-server/backend/routes/playlists.test.ts
Parses valid library playlists, excludes album entries, removes duplicates, and extracts continuation data.
MCP tool definitions
package.json, src/plugins/api-server/backend/routes/mcp.ts
Adds MCP dependencies and validated tools for playback, playlists, search, queue, volume, seeking, and current-song information.
MCP configuration and backend wiring
src/plugins/api-server/config.ts, src/plugins/api-server/menu.ts, src/plugins/api-server/backend/routes/index.ts, src/plugins/api-server/backend/main.ts
Adds disabled-by-default configuration, a menu checkbox, route export, and backend registration for the MCP endpoint.

Estimated code review effort: 4 (Complex) | ~60 minutes

Mergeability Score: ⚪ Minimal · up to ac0df

The MCP server plugin adds music-control and playlist API capabilities, and no actionable merge-blocking risk remains based on the supplied evidence.

Sequence Diagram(s)

sequenceDiagram
  participant MCPClient
  participant HonoApp
  participant MCPServer
  participant SongControls
  participant Renderer
  participant YouTubeMusicApp
  MCPClient->>HonoApp: POST /api/mcp request
  HonoApp->>MCPServer: Forward request through streamable HTTP transport
  MCPServer->>SongControls: Execute validated YouTube Music tool
  SongControls->>Renderer: Send playback, search, playlist, or queue IPC request
  Renderer->>YouTubeMusicApp: Navigate or fetch YouTube Music data
  YouTubeMusicApp-->>Renderer: Return result or error
  Renderer-->>SongControls: Return correlated response
  SongControls-->>MCPServer: Return MCP tool result
  MCPServer-->>MCPClient: Return MCP response
Loading

Possibly related PRs

  • pear-devs/pear-desktop#4615: Both changes modify src/providers/song-controls.ts and add playlist playback and library-playlist functionality.

Suggested labels: enhancement

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: adding an MCP server plugin.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@hwangseonu
hwangseonu marked this pull request as ready for review August 6, 2026 06:34
@hwangseonu

Copy link
Copy Markdown
Contributor Author

@coderabbitai resume

@coderabbitai

coderabbitai Bot commented Aug 7, 2026

Copy link
Copy Markdown
✅ Action performed

Reviews resumed.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/plugins/api-server/backend/routes/mcp.ts`:
- Around line 38-53: Update getQueue and the
requestQueueInformation/peard:get-queue-response IPC contract to generate and
propagate a unique request ID for each queue request. Include that ID in the
response payload and have the listener resolve only when the response ID matches
its request, while preserving the existing timeout cleanup behavior.
- Around line 67-79: Update getQueueItems to safely handle missing renderer
metadata by guarding title, shortBylineText, lengthText, and each runs array
before mapping; preserve valid text joining when present and return undefined or
the existing fallback when metadata is absent so music_get_queue continues
listing queue items.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: f33dd517-c200-4a66-9df1-f36d959d8498

📥 Commits

Reviewing files that changed from the base of the PR and between 54e247e and 4b2cc12.

📒 Files selected for processing (4)
  • src/plugins/api-server/backend/routes/control.ts
  • src/plugins/api-server/backend/routes/mcp.ts
  • src/plugins/api-server/backend/routes/queue.ts
  • src/providers/play-video.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/providers/play-video.ts

Comment thread src/plugins/api-server/backend/routes/mcp.ts
Comment thread src/plugins/api-server/backend/routes/mcp.ts

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/plugins/api-server/backend/routes/control.ts`:
- Around line 768-780: Update the queue response handling around
getQueueResponse to check info.items rather than info itself for an absent
queue. Return status 204 with a null body when items is undefined, and preserve
the existing 200 JSON response for queues with items.
- Around line 585-598: Update getQueueResponse to use a bounded timeout
alongside its IPC listener: clear the timer and remove the listener when a
matching queue response arrives, and on timeout remove the listener and settle
with the established no-response result or HTTP error. Ensure both queue
endpoints awaiting getQueueResponse handle that timeout outcome without leaving
the HTTP request or listener hanging.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 5863b898-0fa4-4a15-b21a-24665b38ab72

📥 Commits

Reviewing files that changed from the base of the PR and between f07cdfa and ce9b232.

📒 Files selected for processing (5)
  • src/plugins/api-server/backend/routes/control.ts
  • src/plugins/api-server/backend/routes/mcp.ts
  • src/providers/song-controls.ts
  • src/renderer.ts
  • src/types/music-player-desktop-internal.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/renderer.ts
  • src/plugins/api-server/backend/routes/mcp.ts

Comment thread src/plugins/api-server/backend/routes/control.ts
Comment thread src/plugins/api-server/backend/routes/control.ts
@hwangseonu

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 14, 2026

Copy link
Copy Markdown
⚠️ Action not completed

Already reviewed.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@hwangseonu

Copy link
Copy Markdown
Contributor Author

@coderabbitai resolve

@coderabbitai

coderabbitai Bot commented Aug 14, 2026

Copy link
Copy Markdown
✅ Action performed

Comments resolved. Approval is disabled; enable reviews.request_changes_workflow to allow explicit top-level @coderabbitai resolve or @coderabbitai approve commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant