markdown_template_get
Retrieve raw markdown content for specific templates to access structured documentation and configuration guides within Microsoft Sentinel environments.
Instructions
Get the raw markdown content for a specific template by name.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| kwargs | Yes |
Implementation Reference
- tools/markdown_templates_tool.py:83-146 (handler)The MarkdownTemplateGetTool class implements the core handler logic for the 'markdown_template_get' tool. The 'run' method handles input validation, reads the specified markdown template file from the resources/markdown_templates directory, and returns its content or appropriate error messages.class MarkdownTemplateGetTool(MCPToolBase): """ Tool for retrieving the raw markdown content for a specific template by name. """ name = "markdown_template_get" description = "Get the raw markdown content for a specific template by name." async def run(self, ctx, **kwargs) -> Any: """ Get the raw markdown content for a specific template by name. Args: ctx: The context object (unused). **kwargs: Arguments containing 'name' (str), the template name (without extension). Returns: dict: A dictionary containing the template content, or an error message if not found or unreadable. """ if isinstance(kwargs, str): try: kwargs = json.loads(kwargs) except Exception: kwargs = {} elif kwargs is None: kwargs = {} elif not isinstance(kwargs, dict): kwargs = dict(kwargs) # Extract name parameter using the centralized parameter extraction from MCPToolBase name = self._extract_param(kwargs, "name") if not name or not isinstance(name, str): return {"error": "Missing or invalid required parameter: name"} try: if not TEMPLATE_DIR.exists() or not TEMPLATE_DIR.is_dir(): return { "error": f"Markdown templates directory does not exist: {TEMPLATE_DIR}" } path = TEMPLATE_DIR / f"{name}.md" path.resolve().relative_to(TEMPLATE_DIR.resolve()) if not path.exists(): try: available = [ os.path.splitext(f)[0] for f in os.listdir(TEMPLATE_DIR) if f.endswith(".md") ] except Exception as list_exc: self.logger.error("Failed to list templates: %s", list_exc) available = [] return { "error": f"Markdown template not found: {name}", "available_templates": available, } try: content = path.read_text(encoding="utf-8") except Exception as file_exc: self.logger.error("Failed to read template %s: %s", name, file_exc) return {"error": f"Failed to read markdown template: {file_exc}"} return {"content": content} except Exception as e: self.logger.error("Failed to get markdown template '%s': %s", name, e) return {"error": f"Failed to get markdown template: {e}"}
- tools/markdown_templates_tool.py:149-157 (registration)The register_tools function registers the MarkdownTemplateGetTool with the MCP server by calling its register method.def register_tools(mcp): """ Register the markdown templates tools with the MCP server. Args: mcp: The MCP server or registry to register the tools with. """ MarkdownTemplatesListTool.register(mcp) MarkdownTemplateGetTool.register(mcp)
- Constant defining the path to the markdown_templates directory used by the tool to locate template files.TEMPLATE_DIR = Path(__file__).parent.parent / "resources" / "markdown_templates"