Add MCP server for CLI - #37
Merged
Merged
Conversation
move the routed orchestration - device resolution, runtime-first dispatch, web api fallback, and relative seek and volume semantics - out of anonymous commander action closures into src/cli/operations, so a second frontend can drive the same code paths. commands become thin parse-and-emit adapters and emitted shapes, messages, and routing behavior are unchanged. the new operations tests exercise the routing against a real control server and a mocked web api.
run a model context protocol server on stdio with eighteen tools covering playback, queue, devices, search, resource details, lyrics, library, and playlists, all calling the shared operations layer so structured output matches the documented --json shapes. the server is a runtime client like every one-shot command, never starts an auth flow or engine, keeps stdout protocol-only, and exits when the client closes stdin or sends a signal. domain failures are tool errors with the cli's message and hint, never protocol errors. uses the stable @modelcontextprotocol/sdk 1.x line with zod. the license walker now resolves a package's real manifest when an exports map answers with a type stub, and the javascript allowlist gains isc and bsd-2-clause for the sdk's transitive tree.
add docs/mcp.md with the tool table, auth prerequisite, and client registration for claude code, codex, and mcpservers-style clients; add the mcp command to the cli guide and a short readme section.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
spotuify mcpruns a Model Context Protocol server on stdio so AI agents can search Spotify and control playback through the same routing, sessions, and output shapes as the CLI.src/cli/operations/, and both the CLI commands and the MCP tools call it. Emitted shapes, messages, and routing behavior are unchanged; the pre-existing suite passes untouched.readOnlyHint,destructiveHint,idempotentHint,openWorldHint). Structured output reuses the CLI's snake_case normalizers, so tool results match the documented--jsonshapes.service run), never starts an auth flow, engine, or renderer, keeps stdout protocol-only, and exits when the client closes stdin or sends a signal. Missing credentials surface as a tool error pointing atspotuify auth, never a prompt.@modelcontextprotocol/sdk1.x line with zod. The license walker now resolves a package's real manifest when an exports map answers with a{"type": "module"}stub, and the JavaScript license allowlist gains ISC and BSD-2-Clause for the SDK's transitive tree.docs/mcp.md(tool table, client registration for Claude Code, Codex, andmcpServers-style clients), plus CLI guide and README sections.Validation
bun run typecheckclean,bun test1032 pass / 0 fail (27 new tests: operations routing against a real control server, in-memory MCP client, spawned stdio integration including stdin-EOF shutdown)bun run licenses:checkpasses; notices regenerated