Skip to content

Add MCP server for CLI - #37

Merged
austin-smith merged 3 commits into
mainfrom
mcp-server
Aug 4, 2026
Merged

austin-smith merged 3 commits into
mainfrom
mcp-server

Conversation

@austin-smith

Copy link
Copy Markdown
Owner

Summary

spotuify mcp runs 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.

  • Shared operations layer — the routed orchestration (device resolution, runtime-first dispatch, Web API fallback, relative seek/volume semantics) moves out of commander action closures into 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.
  • 18 tools covering playback, queue, devices, search, resource details, lyrics, library, and playlists, each with MCP annotations (readOnlyHint, destructiveHint, idempotentHint, openWorldHint). Structured output reuses the CLI's snake_case normalizers, so tool results match the documented --json shapes.
  • Same guarantees as one-shot commands — the server is a runtime client (coexists with the TUI and 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 at spotuify auth, never a prompt.
  • Built on 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": "module"} stub, and the JavaScript license allowlist gains ISC and BSD-2-Clause for the SDK's transitive tree.
  • New guide in docs/mcp.md (tool table, client registration for Claude Code, Codex, and mcpServers-style clients), plus CLI guide and README sections.

Validation

  • bun run typecheck clean, bun test 1032 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:check passes; notices regenerated
  • Compiled standalone binary answers the MCP initialize handshake and exits on stdin EOF

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.
@austin-smith austin-smith changed the title Add an MCP server to the CLI Add MCP for CLI Aug 4, 2026
@austin-smith austin-smith changed the title Add MCP for CLI Add MCP server for CLI Aug 4, 2026
@austin-smith
austin-smith merged commit 273f3ae into main Aug 4, 2026
5 checks passed
@austin-smith
austin-smith deleted the mcp-server branch August 4, 2026 06:23
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