Skip to content

Commit af17ea2

Browse files
added a new ut for stale uri check
1 parent b4f9be7 commit af17ea2

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

‎tests/server/skills/test_catalog.py‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1135,6 +1135,30 @@ async def test_reload_picks_up_added_and_removed_skills_and_files_in_one_swap()
11351135
assert keep_directory == ["skill://keep/SKILL.md", "skill://keep/added.md"]
11361136

11371137

1138+
async def test_reload_serves_a_renamed_file_at_its_new_uri_after_lookups_have_used_the_old_one() -> None:
1139+
"""SDK-defined: each reload publishes a new tuple of new resources, so the server's URI index never goes stale."""
1140+
provider, catalog, server = await _reloadable({"guide/SKILL.md": _skill_md("guide"), "guide/old-name.md": b"notes"})
1141+
async with Client(server) as client:
1142+
before = (await client.read_resource("skill://guide/old-name.md")).contents[0]
1143+
published = catalog.resources()
1144+
provider.files = {"guide/SKILL.md": _skill_md("guide"), "guide/new-name.md": b"notes"}
1145+
await catalog.reload()
1146+
after = (await client.read_resource("skill://guide/new-name.md")).contents[0]
1147+
with pytest.raises(MCPError) as old_uri:
1148+
await client.read_resource("skill://guide/old-name.md")
1149+
1150+
assert isinstance(before, TextResourceContents)
1151+
assert before.text == "notes"
1152+
assert isinstance(after, TextResourceContents)
1153+
assert after.text == "notes"
1154+
assert old_uri.value.code == INVALID_PARAMS
1155+
assert catalog.resources() is not published
1156+
assert [str(binding.resource.uri) for binding in published] == [
1157+
"skill://guide/SKILL.md",
1158+
"skill://guide/old-name.md",
1159+
]
1160+
1161+
11381162
async def test_reload_reports_a_nested_skill_that_is_removed_and_comes_back() -> None:
11391163
"""SDK-defined: a nested skill's files are also served through its parent, so it can come and go on reload."""
11401164
provider, catalog, server = await _reloadable(

0 commit comments

Comments
 (0)