tool_docs_search
Search Microsoft Sentinel documentation to find relevant content and return matching file paths for quick access.
Instructions
Full-text search across documentation; returns matching paths.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| kwargs | Yes |
Implementation Reference
- tools/tool_docs_tools.py:114-151 (handler)The `run` method of `ToolDocsSearchTool` class, which executes the tool logic: extracts query and optional k parameters, searches documentation markdown files using case-insensitive regex, and returns matching paths (up to k).async def run(self, ctx, **kwargs) -> Any: """ Full-text search across documentation; returns matching paths. Args: ctx: The tool context (unused). **kwargs: Should include: - query (str): Regex or text to search for in docs. - k (int, optional): Max number of results to return (default 10). Returns: dict: { 'hits': list of relative doc paths containing a match, 'error': error message if search fails } """ # Defensive: handle string, None, or dict for kwargs # Extract parameters using the centralized parameter extraction from MCPToolBase query = self._extract_param(kwargs, "query") k = self._extract_param(kwargs, "k") if not query: return {"error": "Missing required parameter: query"} try: candidates = [str(p.relative_to(DOC_ROOT)) for p in DOC_ROOT.rglob("*.md")] pat = re.compile(query, re.I) hits = [] for p in candidates: content = (DOC_ROOT / p).read_text(encoding="utf-8") if pat.search(content): hits.append(p) if k and len(hits) >= int(k): break return {"hits": hits} except Exception as e: return {"error": f"Failed to search docs: {e}"}
- tools/tool_docs_tools.py:108-113 (schema)Class definition of `ToolDocsSearchTool` inheriting from `MCPToolBase`, including `name`, `description`, and docstring that define the tool's schema for MCP (inputs: query (str), k (int optional); outputs: dict with 'hits' list or 'error').class ToolDocsSearchTool(MCPToolBase): """Tool for full-text search across documentation; returns matching paths.""" name = "tool_docs_search" description = "Full-text search across documentation; returns matching paths."
- tools/tool_docs_tools.py:190-196 (registration)The `register_tools` function that registers the `ToolDocsSearchTool` (and other doc tools) with the MCP server instance via `ToolDocsSearchTool.register(mcp)`. This module is loaded by server.py.def register_tools(mcp): """Register all documentation tools with the given MCP server instance.""" ToolDocsListTool.register(mcp) ToolDocsGetTool.register(mcp) ToolDocsSearchTool.register(mcp) LLMInstructionsGetTool.register(mcp)