Skip to main content
Glama

get_by_slug_or_url

Retrieve a specific post by its slug or URL from a Markdown knowledge base. Provide the slug or URL as input to extract content quickly and accurately.

Instructions

Get a post by its slug or URL.

Args: identifier: the slug, URL, or path fragment to search for

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
identifierYes

Implementation Reference

  • main.py:503-520 (handler)
    MCP tool handler: decorated with @mcp.tool(), calls the content_manager helper, handles errors and formats output using format_content_for_output.
    @mcp.tool() async def get_by_slug_or_url(identifier: str) -> str: """Get a post by its slug or URL. Args: identifier: the slug, URL, or path fragment to search for """ if content_manager is None: return "Content has not been loaded. Please ensure the server is properly initialized." post = content_manager.get_by_slug_or_url(identifier) if post is None: return f"No post found with slug or URL matching '{identifier}'." # Format as a list to reuse format_content_for_output return format_content_for_output([post])
  • Core implementation in HugoContentManager: searches path_to_content dict for exact URL match, then slug match (case-insensitive), then partial path match, returns ContentFile or None.
    def get_by_slug_or_url(self, identifier: str) -> Optional[ContentFile]: """Find a post by its slug or URL""" identifier_lower = identifier.lower() debug_print(f"Searching for post with slug or URL: '{identifier}'") # First check for exact URL match (case insensitive) for _, content_file in self.path_to_content.items(): url = content_file.url if url and url.lower() == identifier_lower: debug_print(f"Found exact URL match: {url}") return content_file # Then check for exact slug match (case insensitive) for _, content_file in self.path_to_content.items(): slug = content_file.slug if slug.lower() == identifier_lower: debug_print(f"Found exact slug match: {slug}") return content_file # Try partial path match if no exact matches found for path, content_file in self.path_to_content.items(): if identifier_lower in path.lower(): debug_print(f"Found partial path match: {path}") return content_file debug_print(f"No post found for '{identifier}'") return None
  • main.py:503-503 (registration)
    Tool registration decorator @mcp.tool() applied to the handler function.
    @mcp.tool()

Other Tools

Related 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/lethain/library-mcp'

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