markdown_template_get
Retrieve raw markdown content for specific templates to access documentation or configuration details 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:91-146 (handler)The async run method of MarkdownTemplateGetTool that implements the core logic: parses kwargs for 'name' parameter, constructs path to resources/markdown_templates/{name}.md, reads and returns content or errors if missing/invalid.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}"}
- Class definition including tool name 'markdown_template_get', description, and docstring outlining input ('name': str) and output (dict with 'content' or 'error').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."
- tools/markdown_templates_tool.py:149-158 (registration)Function that registers the MarkdownTemplateGetTool (and list tool) with the MCP server.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 directory path where markdown templates are stored, used by the tool.TEMPLATE_DIR = Path(__file__).parent.parent / "resources" / "markdown_templates"