@@ -1858,22 +1858,22 @@ func mockToolWithMeta(name string, toolsetID string, meta map[string]any) Server
18581858}
18591859
18601860func TestWithMCPApps_DisabledStripsUIMetadata (t * testing.T ) {
1861- toolWithUI := mockToolWithMeta ("tool_with_ui" , "toolset1" , map [string ]any {
1862- "ui" : map [string ]any {"html" : "<div>hello</div>" },
1863- "description" : "kept" ,
1864- })
1861+ toolWithUI := mockToolWithMeta ("tool_with_ui" , "toolset1" , map [string ]any {
1862+ "ui" : map [string ]any {"html" : "<div>hello</div>" },
1863+ "description" : "kept" ,
1864+ })
18651865
1866- // Default: MCP Apps is disabled - UI meta should be stripped on registration.
1867- reg := mustBuild (t , NewBuilder ().SetTools ([]ServerTool {toolWithUI }).WithToolsets ([]string {"all" }))
1868- registered := captureRegisteredTools (t , reg , context .Background ())
1866+ // Default: MCP Apps is disabled - UI meta should be stripped on registration.
1867+ reg := mustBuild (t , NewBuilder ().SetTools ([]ServerTool {toolWithUI }).WithToolsets ([]string {"all" }))
1868+ registered := captureRegisteredTools (t , reg , context .Background ())
18691869
1870- require .Len (t , registered , 1 )
1871- if registered [0 ].Meta ["ui" ] != nil {
1872- t .Errorf ("Expected 'ui' meta to be stripped, but it was present" )
1873- }
1874- if registered [0 ].Meta ["description" ] != "kept" {
1875- t .Errorf ("Expected 'description' meta to be preserved, got %v" , registered [0 ].Meta ["description" ])
1876- }
1870+ require .Len (t , registered , 1 )
1871+ if registered [0 ].Meta ["ui" ] != nil {
1872+ t .Errorf ("Expected 'ui' meta to be stripped, but it was present" )
1873+ }
1874+ if registered [0 ].Meta ["description" ] != "kept" {
1875+ t .Errorf ("Expected 'description' meta to be preserved, got %v" , registered [0 ].Meta ["description" ])
1876+ }
18771877}
18781878
18791879func TestWithMCPApps_EnabledPreservesUIMetadata (t * testing.T ) {
@@ -1945,19 +1945,19 @@ func TestWithMCPApps_ToolsWithoutUIMetaUnaffected(t *testing.T) {
19451945}
19461946
19471947func TestWithMCPApps_UIOnlyMetaBecomesNil (t * testing.T ) {
1948- toolUIOnly := mockToolWithMeta ("tool_ui_only" , "toolset1" , map [string ]any {
1949- "ui" : map [string ]any {"html" : "<div>hello</div>" },
1950- })
1948+ toolUIOnly := mockToolWithMeta ("tool_ui_only" , "toolset1" , map [string ]any {
1949+ "ui" : map [string ]any {"html" : "<div>hello</div>" },
1950+ })
19511951
1952- reg := mustBuild (t , NewBuilder ().
1953- SetTools ([]ServerTool {toolUIOnly }).
1954- WithToolsets ([]string {"all" }))
1955- registered := captureRegisteredTools (t , reg , context .Background ())
1952+ reg := mustBuild (t , NewBuilder ().
1953+ SetTools ([]ServerTool {toolUIOnly }).
1954+ WithToolsets ([]string {"all" }))
1955+ registered := captureRegisteredTools (t , reg , context .Background ())
19561956
1957- require .Len (t , registered , 1 )
1958- if registered [0 ].Meta != nil {
1959- t .Errorf ("Expected Meta to be nil after stripping only key, got %v" , registered [0 ].Meta )
1960- }
1957+ require .Len (t , registered , 1 )
1958+ if registered [0 ].Meta != nil {
1959+ t .Errorf ("Expected Meta to be nil after stripping only key, got %v" , registered [0 ].Meta )
1960+ }
19611961}
19621962
19631963func TestStripMetaKeys (t * testing.T ) {
@@ -2240,20 +2240,20 @@ func TestCreateExcludeToolsFilter(t *testing.T) {
22402240// tests can verify what the wire sees, without requiring tools to have real
22412241// handlers (RegisterTools panics on tools without HandlerFunc).
22422242func captureRegisteredTools (t * testing.T , reg * Inventory , ctx context.Context ) []* mcp.Tool {
2243- t .Helper ()
2244- tools := reg .AvailableTools (ctx )
2245- out := make ([]* mcp.Tool , 0 , len (tools ))
2246- for i := range tools {
2247- toolCopy := tools [i ].Tool
2248- out = append (out , & toolCopy )
2249- }
2250- if ! reg .checkFeatureFlag (ctx , mcpAppsFeatureFlag ) {
2251- for _ , tt := range out {
2252- delete (tt .Meta , "ui" )
2253- if len (tt .Meta ) == 0 {
2254- tt .Meta = nil
2255- }
2256- }
2257- }
2258- return out
2243+ t .Helper ()
2244+ tools := reg .AvailableTools (ctx )
2245+ out := make ([]* mcp.Tool , 0 , len (tools ))
2246+ for i := range tools {
2247+ toolCopy := tools [i ].Tool
2248+ out = append (out , & toolCopy )
2249+ }
2250+ if ! reg .checkFeatureFlag (ctx , mcpAppsFeatureFlag ) {
2251+ for _ , tt := range out {
2252+ delete (tt .Meta , "ui" )
2253+ if len (tt .Meta ) == 0 {
2254+ tt .Meta = nil
2255+ }
2256+ }
2257+ }
2258+ return out
22592259}
0 commit comments