@@ -481,6 +481,26 @@ func TestToolsForToolset(t *testing.T) {
481481 }
482482}
483483
484+ func TestToolsForToolset_RespectsReadOnly (t * testing.T ) {
485+ tools := []ServerTool {
486+ mockTool ("tool_read" , "toolset1" , true ),
487+ mockTool ("tool_write" , "toolset1" , false ),
488+ }
489+
490+ reg := mustBuild (
491+ t ,
492+ NewBuilder ().SetTools (tools ).WithToolsets ([]string {}).WithReadOnly (true ),
493+ )
494+ toolset1Tools := reg .ToolsForToolset ("toolset1" )
495+
496+ if len (toolset1Tools ) != 1 {
497+ t .Fatalf ("Expected 1 read-only tool for toolset1, got %d" , len (toolset1Tools ))
498+ }
499+ if toolset1Tools [0 ].Tool .Name != "tool_read" {
500+ t .Fatalf ("Expected tool_read, got %q" , toolset1Tools [0 ].Tool .Name )
501+ }
502+ }
503+
484504func TestWithDeprecatedAliases (t * testing.T ) {
485505 tools := []ServerTool {
486506 mockTool ("new_name" , "toolset1" , true ),
@@ -852,6 +872,30 @@ func TestForMCPRequest_ToolsCall_RespectsFilters(t *testing.T) {
852872 }
853873}
854874
875+ func TestForMCPRequest_ToolsCall_DeprecatedAliasRespectsReadOnly (t * testing.T ) {
876+ tools := []ServerTool {
877+ mockTool ("projects_write" , "projects" , false ),
878+ }
879+
880+ reg := mustBuild (
881+ t ,
882+ NewBuilder ().
883+ SetTools (tools ).
884+ WithToolsets ([]string {"all" }).
885+ WithReadOnly (true ).
886+ WithDeprecatedAliases (map [string ]string {
887+ "add_project_item" : "projects_write" ,
888+ }),
889+ )
890+
891+ filtered := reg .ForMCPRequest (MCPMethodToolsCall , "add_project_item" )
892+ available := filtered .AvailableTools (context .Background ())
893+
894+ if len (available ) != 0 {
895+ t .Fatalf ("Expected 0 tools - deprecated alias should still respect read-only, got %d" , len (available ))
896+ }
897+ }
898+
855899func TestForMCPRequest_ResourcesList (t * testing.T ) {
856900 tools := []ServerTool {
857901 mockTool ("tool1" , "repos" , true ),
0 commit comments