Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docker/pyproject.deps.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "mcp-plex"
version = "2.0.11"
version = "2.0.12"
requires-python = ">=3.11,<3.13"
dependencies = [
"fastmcp>=2.11.2",
Expand Down
26 changes: 19 additions & 7 deletions mcp_plex/server/tools/media_library.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,10 +344,13 @@ async def query_media(
Field(description="Match a TMDb identifier", examples=[568467]),
] = None,
similar_to: Annotated[
str | Sequence[str] | None,
str | int | Sequence[str | int] | None,
Field(
description="Recommend candidates similar to these identifiers",
examples=[["49915"], "tt8367814"],
description=(
"Recommend candidates similar to Plex rating keys, "
"IMDb/TMDb identifiers, or titles"
),
examples=[[49915], "tt8367814", 568467, "The Gentlemen"],
),
] = None,
limit: Annotated[
Expand All @@ -372,12 +375,21 @@ async def query_media(
) -> MediaSummaryResponse | list[AggregatedMediaItem]:
"""Run a structured query against indexed payload fields and optional vector searches."""

def _listify(value: Sequence[str] | str | None) -> list[str]:
def _listify(
value: Sequence[str | int] | str | int | None,
) -> list[str]:
if value is None:
return []
if isinstance(value, str):
return [value]
return [v for v in value if isinstance(v, str) and v]
if isinstance(value, (str, int)):
text = str(value).strip()
return [text] if text else []
items: list[str] = []
for entry in value:
if isinstance(entry, (str, int)):
text = str(entry).strip()
if text:
items.append(text)
return items

def _finalize(
items: list[AggregatedMediaItem],
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "mcp-plex"
version = "2.0.11"
version = "2.0.12"

description = "Plex-Oriented Model Context Protocol Server"
requires-python = ">=3.11,<3.13"
Expand Down
15 changes: 15 additions & 0 deletions tests/test_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,21 @@ def test_server_tools(monkeypatch):
if isinstance(item.get("plex"), dict)
} >= {"61960"}

similar_structured_int = asyncio.run(
server.query_media.fn(
similar_to=49915,
type="episode",
limit=3,
summarize_for_llm=False,
)
)
assert similar_structured_int
assert {
item["plex"]["rating_key"]
for item in similar_structured_int
if isinstance(item.get("plex"), dict)
} >= {"61960"}

assert (
asyncio.run(
server.query_media.fn(
Expand Down
2 changes: 1 addition & 1 deletion uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.