Enforce an explicit read-only tool allowlist

Remove every tool that is not explicitly approved for the private Buzz agent. This keeps future mutating tools closed by default instead of relying on a denylist that must be updated manually.

Co-authored-by: fredamn76 <fredrik.fallman@gmail.com>
Signed-off-by: fredamn76 <fredrik.fallman@gmail.com>
This commit is contained in:
2026-07-31 10:48:15 +02:00
committed by fredamn76
parent 242bb15641
commit e46c327875
2 changed files with 35 additions and 16 deletions
+20 -4
View File
@@ -31,19 +31,35 @@ def test_read_only_server_removes_all_mutating_tools():
def search_recipes(query: str) -> list[str]:
return [query]
def mutating_tool(value: str) -> str:
@test_server.tool()
def patch_recipe(value: str) -> str:
return value
for name in server.WRITE_TOOL_NAMES:
test_server.tool(name=name)(mutating_tool)
@test_server.tool()
def future_mutating_tool(value: str) -> str:
return value
server._configure_read_only(test_server)
server._configure_read_only(test_server, frozenset({"search_recipes"}))
tool_names = {tool.name for tool in asyncio.run(test_server.list_tools())}
assert tool_names == {"search_recipes"}
def test_read_only_tool_allowlist_is_explicit():
assert server.READ_ONLY_TOOL_NAMES == {
"check_auth",
"find_by_source_url",
"get_recipe",
"list_organizers",
"resolve_foods",
"scale_ingredients",
"search_recipes",
"suggest_recipes",
"verify_recipe",
}
class TestUrlImportResponse:
def test_slug_only_import_response_is_resolved_before_reporting(self, monkeypatch):
recipe = {"slug": "lax-med-citron", "name": "Lax med citron", "recipeIngredient": []}