Skip to main content
Glama
james-livefront

Poetry MCP Server

find_poems_by_tag

Search for poems using specific tags with flexible matching options to filter poetry collections by themes, subjects, or characteristics.

Instructions

Find poems by tags.

Args: tags: List of tags to match match_mode: "all" (poems must have all tags) or "any" (at least one tag) states: Optional filter by states limit: Maximum number of results

Returns: List of matching poems

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
tagsYes
match_modeNoall
statesNo
limitNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The primary handler function for the find_poems_by_tag tool. It is registered via the @mcp.tool() decorator. Retrieves matching poems from the catalog index, applies state filtering if provided, limits the results, strips poem content for efficiency, and returns the list of Poem objects.
    @mcp.tool()
    async def find_poems_by_tag(
        tags: List[str],
        match_mode: str = "all",
        states: Optional[List[str]] = None,
        limit: int = 20
    ) -> List[Poem]:
        """
        Find poems by tags.
    
        Args:
            tags: List of tags to match
            match_mode: "all" (poems must have all tags) or "any" (at least one tag)
            states: Optional filter by states
            limit: Maximum number of results
    
        Returns:
            List of matching poems
        """
        cat = get_catalog()
    
        # Get poems matching tags
        poems = cat.index.get_by_tags(tags, match_mode=match_mode)
    
        # Apply state filter
        if states:
            poems = [p for p in poems if p.state in states]
    
        # Limit results
        poems = poems[:limit]
    
        # Remove content for efficiency
        poems = [
            Poem(**{**p.model_dump(), 'content': None})
            for p in poems
        ]
    
        return poems
  • Core helper method in CatalogIndex that implements the tag matching logic using set intersection (for 'all') or union (for 'any') on the pre-built tag index to find matching poem IDs efficiently.
    def get_by_tags(
        self,
        tags: list[str],
        match_mode: str = "all"
    ) -> list[Poem]:
        """
        Get poems matching tag criteria.
    
        Args:
            tags: List of tags to match
            match_mode: "all" (AND) or "any" (OR)
    
        Returns:
            List of matching poems
        """
        if not tags:
            return []
    
        tag_sets = [self.by_tag.get(tag.lower(), set()) for tag in tags]
    
        if match_mode == "all":
            # Intersection: poems must have all tags
            matching_ids = set.intersection(*tag_sets) if tag_sets else set()
        else:  # "any"
            # Union: poems must have at least one tag
            matching_ids = set.union(*tag_sets) if tag_sets else set()
    
        return [self.by_id[pid] for pid in matching_ids if pid in self.by_id]
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It mentions the tool 'Returns: List of matching poems' but lacks critical details: whether this is a read-only operation (implied by 'Find' but not explicit), pagination behavior (only 'limit' is mentioned), error handling, or performance characteristics like rate limits. For a tool with 4 parameters and no annotation coverage, this is insufficient.

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 well-structured: it starts with a clear purpose statement, followed by an 'Args:' section listing parameters with brief semantics, and ends with a 'Returns:' statement. Each sentence earns its place, though the 'Args:' and 'Returns:' labels add minor redundancy. It could be slightly more front-loaded by integrating parameter hints into the opening sentence.

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

Completeness3/5

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

Given the tool's moderate complexity (4 parameters, no annotations, but with an output schema), the description is partially complete. The output schema exists, so the description doesn't need to detail return values. However, it lacks behavioral context (e.g., safety, performance) and usage guidelines compared to siblings. With 0% schema description coverage, the parameter explanations help but don't fully compensate for missing behavioral transparency.

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 lists all 4 parameters with brief explanations: 'tags: List of tags to match', 'match_mode: "all" (poems must have all tags) or "any" (at least one tag)', 'states: Optional filter by states', and 'limit: Maximum number of results'. This adds meaning beyond the bare schema (e.g., clarifying match_mode options), but it doesn't explain parameter interactions, constraints (e.g., tag format), or default behaviors beyond what's in the schema.

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

Purpose4/5

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

The description clearly states the tool's purpose: 'Find poems by tags' specifies both the verb ('Find') and resource ('poems'), with the mechanism ('by tags') providing additional specificity. It distinguishes from siblings like 'list_poems_by_state' (which filters by state rather than tags) and 'search_poems' (which likely uses different search criteria). However, it doesn't explicitly contrast with all siblings, preventing a perfect score.

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. It doesn't mention siblings like 'list_poems_by_state' (for state-based filtering) or 'search_poems' (which might support broader search capabilities), nor does it specify prerequisites or exclusions. The only implied usage is tag-based poem retrieval, but this is already covered in purpose clarity.

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/james-livefront/poetry-mcp'

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