Skip to main content
Glama
dstreefkerk

ms-sentinel-mcp-server

by dstreefkerk

sentinel_watchlist_items_list

Retrieve all items from a Microsoft Sentinel watchlist to monitor security threats and manage detection rules.

Instructions

List all items in a Sentinel watchlist

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
kwargsYes

Implementation Reference

  • The SentinelWatchlistItemsListTool class defines and implements the 'sentinel_watchlist_items_list' tool. It includes the name, description, and the async run() method that handles the tool execution logic: extracts watchlist_alias, gets Azure client, lists watchlist items using SecurityInsights SDK, processes and returns item details.
    class SentinelWatchlistItemsListTool(MCPToolBase):
        """
        Tool for listing all items in a specified Microsoft Sentinel watchlist.
        """
    
        name = "sentinel_watchlist_items_list"
        description = "List all items in a Sentinel watchlist"
    
        async def run(self, ctx: Context, **kwargs):
            logger = self.logger
    
            # Extract parameters using the base class method
            watchlist_alias = self._extract_param(kwargs, "watchlist_alias")
            if not watchlist_alias:
                return {"error": "watchlist_alias parameter is required"}
    
            # Get Azure context
            workspace_name, resource_group, subscription_id = self.get_azure_context(ctx)
    
            # Get security insights client
            client = None
            try:
                client = self.get_securityinsight_client(subscription_id)
            except Exception as e:
                logger.error("Error initializing Azure SecurityInsights client: %s", e)
                return {
                    "error": (
                        "Azure SecurityInsights client initialization failed: %s" % str(e)
                    )
                }
    
            if client is None:
                return {"error": "Azure SecurityInsights client is not initialized"}
    
            try:
                # List all items in the watchlist
                watchlist_items = await run_in_thread(
                    client.watchlist_items.list,
                    resource_group_name=resource_group,
                    workspace_name=workspace_name,
                    watchlist_alias=watchlist_alias,
                )
    
                result = []
                for item in watchlist_items:
                    # Log the item object to understand its structure
                    logger.debug("Watchlist item object: %s", item)
    
                    # Create a basic info dictionary with guaranteed attributes
                    item_info = {
                        "id": item.id if hasattr(item, "id") else None,
                        "name": item.name if hasattr(item, "name") else None,
                    }
    
                    # Try to access properties directly from the item object first
                    try:
                        # Check for direct properties on the item object
                        if hasattr(item, "items_key_value"):
                            item_info["itemsKeyValue"] = item.items_key_value
                        if hasattr(item, "properties") and isinstance(item.properties, dict):
                            item_info["properties"] = item.properties
                        
                        # If we couldn't find any direct properties, try the nested properties approach
                        if len(item_info) <= 2 and hasattr(item, "properties") and not isinstance(item.properties, dict):
                            props = item.properties
                            if hasattr(props, "items_key_value"):
                                item_info["itemsKeyValue"] = props.items_key_value
                            if hasattr(props, "properties"):
                                item_info["properties"] = props.properties
                    except Exception as prop_error:
                        # Log the property access error but continue with basic details
                        logger.error("Error accessing watchlist item properties: %s", prop_error)
    
                    result.append(item_info)
    
                return {
                    "watchlistItems": result,
                    "count": len(result),
                    "watchlistAlias": watchlist_alias,
                    "valid": True,
                }
            except Exception as e:
                logger.error(
                    "Error retrieving watchlist items for alias %s: %s", watchlist_alias, e
                )
                return {
                    "error": "Error retrieving watchlist items for alias %s: %s"
                    % (watchlist_alias, e)
                }
  • The register_tools function registers all watchlist-related tools with the MCP server, including a call to SentinelWatchlistItemsListTool.register(mcp) at line 391.
    def register_tools(mcp: FastMCP):
        """
        Register all Sentinel watchlist tools with the MCP server instance.
    
        Args:
            mcp (FastMCP): The MCP server instance to register tools with.
        """
        SentinelWatchlistsListTool.register(mcp)
        SentinelWatchlistGetTool.register(mcp)
        SentinelWatchlistItemsListTool.register(mcp)
        SentinelWatchlistItemGetTool.register(mcp)
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It states it's a list operation, implying read-only behavior, but doesn't mention any constraints like pagination, rate limits, authentication requirements, or what 'all items' entails (e.g., if there are limits). This leaves significant gaps for a tool with one parameter.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, clear sentence with no wasted words. It's front-loaded with the core action and resource, making it efficient and easy to parse.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a tool with no annotations, no output schema, and a parameter with 0% schema coverage, the description is incomplete. It covers the basic purpose but lacks details on usage, parameters, behavioral traits, or return values, which are critical for effective tool invocation.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 1 parameter ('kwargs') with 0% description coverage, and the tool description provides no information about parameters. The description doesn't explain what 'kwargs' should contain (e.g., watchlist identifier, filters) or its format, failing to compensate for the lack of schema documentation.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb ('List') and resource ('items in a Sentinel watchlist'), making the purpose unambiguous. It doesn't explicitly differentiate from sibling tools like 'sentinel_watchlist_get' or 'sentinel_watchlist_item_get', but the focus on 'items' provides some implicit distinction.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided on when to use this tool versus alternatives like 'sentinel_watchlist_get' (which might retrieve watchlist metadata) or 'sentinel_watchlist_item_get' (which might retrieve a specific item). The description lacks context about prerequisites or exclusions.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/dstreefkerk/ms-sentinel-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server