Merge pull request 'pinchflat-mcp: add pagination, downloaded filter, and delete_media tool' (#5) from fix/pinchflat-mcp-pagination into main
NixOS Configuration CI / Nix Flake Check (push) Successful in 13s
NixOS Configuration CI / Nix Flake Check (push) Successful in 13s
Reviewed-on: #5
This commit was merged in pull request #5.
This commit is contained in:
@@ -27,3 +27,4 @@ result-*
|
||||
# Local environment overrides
|
||||
.envrc.local
|
||||
/.dir-locals.el
|
||||
__pycache__/
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
{
|
||||
lib,
|
||||
buildGoModule,
|
||||
fetchFromGitHub,
|
||||
}:
|
||||
|
||||
buildGoModule rec {
|
||||
pname = "audiobookshelf-mcp";
|
||||
version = "unstable-2026-06-27";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "michaeldvinci";
|
||||
repo = "audiobookshelf-mcp";
|
||||
rev = "e790d9c75085772180c95f2ec1376acc98e9282c";
|
||||
hash = "sha256-vQR+Ej3Qtg8ehIUWnXkSayNYpqnOZPWV0TpTVPYh+io=";
|
||||
};
|
||||
|
||||
vendorHash = "sha256-W8hlCGf4QdFbKc3QFc9pa4MWBhnp5A5GvWFNzg0BEhw=";
|
||||
|
||||
meta = with lib; {
|
||||
description = "MCP server for Audiobookshelf — libraries, audiobooks, podcasts, authors, collections, playlists";
|
||||
homepage = "https://github.com/michaeldvinci/audiobookshelf-mcp";
|
||||
license = licenses.gpl3Only;
|
||||
mainProgram = "abs-mcp";
|
||||
platforms = platforms.all;
|
||||
};
|
||||
}
|
||||
@@ -20,5 +20,6 @@
|
||||
mcp-score = pkgs.callPackage ./mcp-score/package.nix { };
|
||||
applemusic-mcp = pkgs.callPackage ./applemusic-mcp/package.nix { };
|
||||
pinchflat-mcp = pkgs.callPackage ./pinchflat-mcp/package.nix { };
|
||||
audiobookshelf-mcp = pkgs.callPackage ./audiobookshelf-mcp/package.nix { };
|
||||
# example-mcp-server = pkgs.callPackage ./example-mcp-server/package.nix { };
|
||||
}
|
||||
|
||||
@@ -150,11 +150,25 @@ def force_metadata_refresh(source_id: int) -> dict:
|
||||
# --- Media Items ---
|
||||
|
||||
@mcp.tool()
|
||||
def list_media(source_id: Optional[int] = None, limit: int = 50) -> dict:
|
||||
"""List media items. Optionally filter by source_id."""
|
||||
params = {}
|
||||
def list_media(
|
||||
source_id: Optional[int] = None,
|
||||
limit: int = 50,
|
||||
offset: int = 0,
|
||||
downloaded: Optional[bool] = None,
|
||||
) -> dict:
|
||||
"""List media items with pagination. Optionally filter by source_id or download status.
|
||||
|
||||
Args:
|
||||
source_id: Filter to a specific source
|
||||
limit: Max items to return (default 50)
|
||||
offset: Skip first N items for pagination (default 0)
|
||||
downloaded: If True, only return downloaded media; if False, only undownloaded
|
||||
"""
|
||||
params = {"limit": limit, "offset": offset}
|
||||
if source_id:
|
||||
params["source_id"] = source_id
|
||||
if downloaded is not None:
|
||||
params["downloaded"] = "true" if downloaded else "false"
|
||||
return _get("/media", params=params)
|
||||
|
||||
|
||||
@@ -176,6 +190,23 @@ def force_download_media(media_id: int) -> dict:
|
||||
return _post(f"/media/{media_id}/force_download")
|
||||
|
||||
|
||||
@mcp.tool()
|
||||
def delete_media(media_id: int, prevent_download: bool = False) -> dict:
|
||||
"""Delete a media item's downloaded files from disk.
|
||||
|
||||
Args:
|
||||
media_id: The media item ID to delete
|
||||
prevent_download: If True, prevent the item from being re-downloaded in the future
|
||||
"""
|
||||
params = {}
|
||||
if prevent_download:
|
||||
params["prevent_download"] = "true"
|
||||
with httpx.Client(timeout=120) as client:
|
||||
r = client.delete(f"{BASE}/media/{media_id}", headers=HEADERS, params=params)
|
||||
r.raise_for_status()
|
||||
return r.json()
|
||||
|
||||
|
||||
# --- Media Profiles ---
|
||||
|
||||
@mcp.tool()
|
||||
|
||||
Reference in New Issue
Block a user