Skip to main content
Glama
lethain

Library MCP

by lethain

get_by_text

Retrieve blog content from local markdown files by searching for exact text matches within the content. Specify text to find and limit results as needed.

Instructions

Get blog content by text in content.

Args: query: text for an exact match limit: the number of results to include

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYes
limitNo

Implementation Reference

  • main.py:443-456 (handler)
    MCP tool handler for 'get_by_text'. Calls the content manager's method and formats the output.
    @mcp.tool()
    async def get_by_text(query: str, limit: int = 50) -> str:
        """Get blog content by text in content.
        
        Args:
            query: text for an exact match
            limit: the number of results to include
        """
        if content_manager is None:
            return "Content has not been loaded. Please ensure the server is properly initialized."
        
        matching_content = content_manager.get_by_text(query, limit)
        return format_content_for_output(matching_content)
  • Implementation of text search in HugoContentManager class. Searches content files for exact substring match (case-insensitive), sorts by date descending, limits results.
    def get_by_text(self, query: str, limit: int = 50) -> List[ContentFile]:
        """Find all files containing the specified text"""
        matches = []
        query_lower = query.lower()
        
        debug_print(f"Searching for text: '{query}'")
        for file_path, content_file in self.path_to_content.items():
            if query_lower in content_file.data.lower():
                matches.append(content_file)
        
        debug_print(f"Found {len(matches)} files containing '{query}'")
        
        # Sort by date (most recent first)
        def get_sort_key(content_file):
            date = content_file.date
            if date is None:
                return datetime.min
            # Make date naive if it has timezone info
            if hasattr(date, 'tzinfo') and date.tzinfo is not None:
                date = date.replace(tzinfo=None)
            return date
            
        matches.sort(key=get_sort_key, reverse=True)
        
        return matches[:limit]
  • Input schema defined in the tool's docstring.
    """Get blog content by text in content.
    
    Args:
        query: text for an exact match
        limit: the number of results to include
    """
  • Helper function to format search results into a readable string output.
    def format_content_for_output(content_files: List[ContentFile]) -> str:
        """Format the content files for output"""
        if not content_files:
            return "No matching content found."
        
        result = []
        
        for i, file in enumerate(content_files):
            result.append(f"File: {file.path}")
            result.append("Metadata:")
            for key, value in file.meta.items():
                result.append(f"  {key}: {value}")
            
            # Include the full content
            result.append("Content:")
            result.append(file.data.strip())
            
            # Add separator between entries, but not after the last one
            if i < len(content_files) - 1:
                result.append("-" * 50)
        
        return "\n".join(result)
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries full burden. It mentions 'exact match' for the query parameter, which hints at behavior, but doesn't disclose critical traits like whether this is a read-only operation, potential rate limits, authentication needs, error conditions, or what happens when no matches are found. For a retrieval tool with no annotation coverage, this leaves significant behavioral gaps.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is appropriately sized and front-loaded with the core purpose in the first sentence. The Args section is clear and directly relevant. There's no unnecessary fluff, though the structure could be slightly improved by integrating the Args details more seamlessly rather than as a separate block.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given 2 parameters with 0% schema coverage, no annotations, and no output schema, the description is incomplete. It covers basic parameter purposes but lacks details on return values (e.g., format of blog content), error handling, or performance considerations. For a tool with siblings offering similar functionality, more context is needed to guide effective use.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the description must compensate. It adds meaning by specifying that 'query' is for 'text for an exact match' and 'limit' is for 'the number of results to include', which clarifies basic semantics beyond the schema's titles. However, it doesn't explain format constraints (e.g., query length, limit bounds) or provide examples, leaving some ambiguity.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose3/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description states 'Get blog content by text in content' which provides a basic purpose (retrieving blog content using text matching), but it's vague about the matching mechanism ('exact match' is only mentioned in the Args section). It doesn't distinguish this tool from siblings like 'search_tags' or 'get_by_tag' which might also involve text-based retrieval. The purpose is understandable but lacks specificity about what makes this tool unique.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. With siblings like 'get_by_date_range', 'get_by_slug_or_url', 'get_by_tag', and 'search_tags', there's no indication of when text-based content retrieval is preferred over other filtering methods. The Args section mentions 'exact match' but doesn't clarify use cases or exclusions.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other 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