@@ -958,6 +958,114 @@ public void testMcpOpenWorldParamSetsOpenWorldHint() throws Exception {
958958 annotations .path ("openWorldHint" ).asBoolean ());
959959 }
960960
961+ // ── B2: mcpAuthScope ─────────────────────────────────────────────────────
962+
963+ public void testMcpAuthScopeParamAppearsAsXAuthScope () throws Exception {
964+ AxisService svc = new AxisService ("PortfolioService" );
965+ AxisOperation op = new InOutAxisOperation ();
966+ op .setName (QName .valueOf ("readPositions" ));
967+ op .addParameter (new org .apache .axis2 .description .Parameter (
968+ "mcpAuthScope" , "read:portfolio" ));
969+ svc .addOperation (op );
970+ axisConfig .addService (svc );
971+
972+ JsonNode tool = getCatalogTools ().get (0 );
973+ assertEquals ("x-authScope must reflect mcpAuthScope param" ,
974+ "read:portfolio" , tool .path ("x-authScope" ).asText ());
975+ }
976+
977+ public void testAbsentMcpAuthScopeProducesNoXAuthScopeField () throws Exception {
978+ addService ("PortfolioService" , "readPositions" );
979+
980+ JsonNode tool = getCatalogTools ().get (0 );
981+ assertTrue ("x-authScope must be absent when mcpAuthScope not set" ,
982+ tool .path ("x-authScope" ).isMissingNode ());
983+ }
984+
985+ public void testServiceLevelMcpAuthScopeAppliedWhenNoOperationLevel () throws Exception {
986+ AxisService svc = new AxisService ("PortfolioService" );
987+ svc .addParameter (new org .apache .axis2 .description .Parameter (
988+ "mcpAuthScope" , "read:global" ));
989+ AxisOperation op = new InOutAxisOperation ();
990+ op .setName (QName .valueOf ("readPositions" ));
991+ svc .addOperation (op );
992+ axisConfig .addService (svc );
993+
994+ JsonNode tool = getCatalogTools ().get (0 );
995+ assertEquals ("service-level mcpAuthScope must apply when op level absent" ,
996+ "read:global" , tool .path ("x-authScope" ).asText ());
997+ }
998+
999+ public void testOperationLevelMcpAuthScopeOverridesServiceLevel () throws Exception {
1000+ AxisService svc = new AxisService ("PortfolioService" );
1001+ svc .addParameter (new org .apache .axis2 .description .Parameter (
1002+ "mcpAuthScope" , "read:global" ));
1003+ AxisOperation op = new InOutAxisOperation ();
1004+ op .setName (QName .valueOf ("writePositions" ));
1005+ op .addParameter (new org .apache .axis2 .description .Parameter (
1006+ "mcpAuthScope" , "write:portfolio" ));
1007+ svc .addOperation (op );
1008+ axisConfig .addService (svc );
1009+
1010+ JsonNode tool = getCatalogTools ().get (0 );
1011+ assertEquals ("operation-level mcpAuthScope must override service level" ,
1012+ "write:portfolio" , tool .path ("x-authScope" ).asText ());
1013+ }
1014+
1015+ // ── B3: mcpStreaming ──────────────────────────────────────────────────────
1016+
1017+ public void testMcpStreamingParamSetsXStreamingTrue () throws Exception {
1018+ AxisService svc = new AxisService ("FeedService" );
1019+ AxisOperation op = new InOutAxisOperation ();
1020+ op .setName (QName .valueOf ("streamPrices" ));
1021+ op .addParameter (new org .apache .axis2 .description .Parameter (
1022+ "mcpStreaming" , "true" ));
1023+ svc .addOperation (op );
1024+ axisConfig .addService (svc );
1025+
1026+ JsonNode tool = getCatalogTools ().get (0 );
1027+ assertTrue ("x-streaming must be true when mcpStreaming=true" ,
1028+ tool .path ("x-streaming" ).asBoolean ());
1029+ }
1030+
1031+ public void testAbsentMcpStreamingProducesNoXStreamingField () throws Exception {
1032+ addService ("FeedService" , "getSnapshot" );
1033+
1034+ JsonNode tool = getCatalogTools ().get (0 );
1035+ assertTrue ("x-streaming field must be absent when mcpStreaming not set" ,
1036+ tool .path ("x-streaming" ).isMissingNode ());
1037+ }
1038+
1039+ public void testMcpStreamingFalseProducesNoXStreamingField () throws Exception {
1040+ // mcpStreaming=false is the default; field must be suppressed (not emitted as false)
1041+ // to keep the catalog compact — clients treat absence as non-streaming.
1042+ AxisService svc = new AxisService ("FeedService" );
1043+ AxisOperation op = new InOutAxisOperation ();
1044+ op .setName (QName .valueOf ("getSnapshot" ));
1045+ op .addParameter (new org .apache .axis2 .description .Parameter (
1046+ "mcpStreaming" , "false" ));
1047+ svc .addOperation (op );
1048+ axisConfig .addService (svc );
1049+
1050+ JsonNode tool = getCatalogTools ().get (0 );
1051+ assertTrue ("x-streaming must be absent when mcpStreaming=false" ,
1052+ tool .path ("x-streaming" ).isMissingNode ());
1053+ }
1054+
1055+ public void testServiceLevelMcpStreamingApplied () throws Exception {
1056+ AxisService svc = new AxisService ("FeedService" );
1057+ svc .addParameter (new org .apache .axis2 .description .Parameter (
1058+ "mcpStreaming" , "true" ));
1059+ AxisOperation op = new InOutAxisOperation ();
1060+ op .setName (QName .valueOf ("streamPrices" ));
1061+ svc .addOperation (op );
1062+ axisConfig .addService (svc );
1063+
1064+ JsonNode tool = getCatalogTools ().get (0 );
1065+ assertTrue ("service-level mcpStreaming must apply when op level absent" ,
1066+ tool .path ("x-streaming" ).asBoolean ());
1067+ }
1068+
9611069 // ── helpers ─────────────────────────────────────────────────────────────
9621070
9631071 private void addService (String serviceName , String operationName ) throws Exception {
0 commit comments