Class MCPServerFeaturesFilter

  • All Implemented Interfaces:
    org.forgerock.http.Filter

    public class MCPServerFeaturesFilter
    extends Object
    implements org.forgerock.http.Filter
    MCPServerFeaturesFilter
    This filter enforces allow/deny policies for MCP (Management & Control Protocol) features exchanged as JSON-RPC payloads with an MCP server. It inspects both incoming requests and outgoing responses and removes or rejects features according to the configured rules.

    Policy enforcement logic:

    • Deny lists take precedence over allow lists
    • Empty allow list means all features are allowed (unless denied)
    • Non-empty allow list means only listed features are allowed
    • Denied features are always blocked, regardless of allow list
    
     {
         "type": "MCPFeaturesFilter",
         "config": {
             "allow": {
                 "tools": ["get_weather", "tool2"],
                 "prompts": ["code_review", "prompt2"]
             },
             "deny": {
                 "resources": ["file:///project/src/main.rs"],
                 "resources/templates": ["file:///{path}"]
             }
         }
     }
     
     
    • Constructor Detail

      • MCPServerFeaturesFilter

        public MCPServerFeaturesFilter()
    • Method Detail

      • filter

        public org.forgerock.util.promise.Promise<org.forgerock.http.protocol.Response,​org.forgerock.util.promise.NeverThrowsException> filter​(org.forgerock.services.context.Context context,
                                                                                                                                                     org.forgerock.http.protocol.Request request,
                                                                                                                                                     org.forgerock.http.Handler next)
        Specified by:
        filter in interface org.forgerock.http.Filter
      • filterResponseFeature

        public List<org.forgerock.json.JsonValue> filterResponseFeature​(MCPServerFeaturesFilter.MCPFeature mcpFeature,
                                                                        List<org.forgerock.json.JsonValue> featuresList,
                                                                        List<String> allowed,
                                                                        List<String> denied)
        Filter a list of feature objects.
        Parameters:
        featuresList - the original feature JSON objects
        allowed - allowed names (empty == no allow constraint)
        denied - denied names (empty == no deny constraint)
        Returns:
        filtered list (new list instance)