Skip to main content
Glama
dstreefkerk

ms-sentinel-mcp-server

by dstreefkerk

markdown_templates_list

Discover and browse available markdown templates with descriptions to streamline documentation creation in Microsoft Sentinel environments.

Instructions

List available markdown templates and their descriptions.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
kwargsYes

Implementation Reference

  • The MarkdownTemplatesListTool class defines the tool 'markdown_templates_list'. It includes the name, description, and the async run() method which scans the markdown_templates directory, reads each .md file, extracts description from the first line if it's a header, constructs URI, and returns a list of templates with their content.
    class MarkdownTemplatesListTool(MCPToolBase): """ Tool for listing available markdown templates and their descriptions. """ name = "markdown_templates_list" description = "List available markdown templates and their descriptions." async def run(self, ctx, **kwargs) -> Any: """ List available markdown templates and their descriptions. Args: ctx: The context object (unused). **kwargs: Optional arguments (unused). Returns: dict: A dictionary containing a list of templates (with name, uri, description, and content), or an error message if the directory cannot be read. """ 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) try: if not TEMPLATE_DIR.exists() or not TEMPLATE_DIR.is_dir(): return { "error": f"Markdown templates directory does not exist: {TEMPLATE_DIR}" } templates = [] for fname in os.listdir(TEMPLATE_DIR): if fname.endswith(".md"): template_name = os.path.splitext(fname)[0] path = TEMPLATE_DIR / fname try: with open(path, encoding="utf-8") as f: first_line = f.readline().strip() f.seek(0) content = f.read() except Exception as file_exc: self.logger.error( "Failed to read template %s: %s", fname, file_exc ) continue templates.append( { "name": template_name, "uri": f"markdown://templates/{template_name}", "description": ( first_line if first_line.startswith("#") else "Markdown template" ), "content": content, } ) return {"templates": templates} except Exception as e: self.logger.error("Failed to list markdown templates: %s", e) return {"error": f"Failed to list markdown templates: {e}"}
  • The register_tools function registers the MarkdownTemplatesListTool (and the related get tool) with the MCP instance.
    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)
  • Defines the path to the markdown_templates directory used by the tool.
    TEMPLATE_DIR = Path(__file__).parent.parent / "resources" / "markdown_templates"

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