Skip to main content
Glama
james-livefront

Poetry MCP Server

get_poems_for_enrichment

Retrieve poems requiring theme analysis to enhance their metadata classification. Provides poems with minimal tags for systematic theme identification and enrichment.

Instructions

Get batch of poems needing theme enrichment for agent analysis.

Returns poems with minimal or no tags for YOU (the agent) to analyze. YOU suggest which themes apply to each poem.

Args: poem_ids: List of poem IDs (None = all untagged/lightly-tagged poems) max_poems: Maximum poems to return (default 50)

Returns: Dictionary with: - poems: List of poem data (id, title, content, current_tags) - available_themes: Theme options with descriptions - instructions: Batch analysis guidance

Example workflow: ``` # 1. Get poems needing enrichment data = await get_poems_for_enrichment(max_poems=10)

# 2. YOU analyze data['poems'] against data['available_themes']
# 3. YOU suggest 1-3 themes for each poem with confidence scores
# 4. User applies high-confidence tags with link_poem_to_nexus()
```

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
poem_idsNo
max_poemsNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Core implementation of get_poems_for_enrichment. Selects untagged or lightly-tagged poems from catalog, loads and truncates their content, prepares list of available themes with brief descriptions, and returns structured data including analysis instructions for batch agent processing.
    async def get_poems_for_enrichment(
        poem_ids: Optional[List[str]] = None,
        max_poems: int = 50,
    ) -> dict:
        """Get list of poems needing theme enrichment for agent analysis.
    
        Returns poems with minimal or no tags for the agent to analyze and suggest themes.
        The agent can analyze multiple poems and suggest which themes to apply.
    
        Args:
            poem_ids: List of poem IDs to include (None = all untagged poems)
            max_poems: Maximum poems to return (default 50)
    
        Returns:
            Dictionary with:
            - poems: List of poem data (id, title, content, current_tags, state)
            - available_themes: Theme options with descriptions
            - total_count: Total poems returned
            - instructions: Guidance for batch analysis
    
        Example:
            >>> result = await get_poems_for_enrichment(max_poems=10)
            >>> # Agent analyzes result['poems'] against result['available_themes']
            >>> # Agent suggests themes for each poem
            >>> # User applies tags with link_poem_to_nexus()
        """
        if _catalog is None or _nexus_registry is None:
            raise RuntimeError("Enrichment tools not initialized.")
    
        # Determine which poems to return
        if poem_ids is None:
            # Default: all poems with no tags or very few tags
            poems_to_return = [
                poem for poem in _catalog.index.all_poems
                if not poem.tags or len(poem.tags) < 2
            ]
        else:
            # Specific poem IDs
            poems_to_return = []
            for pid in poem_ids:
                poem = _catalog.index.get_poem(pid)
                if poem:
                    poems_to_return.append(poem)
    
        # Limit to max_poems
        poems_to_return = poems_to_return[:max_poems]
    
        # Format poems data
        poems_data = []
        for poem in poems_to_return:
            # Load content if needed
            content = poem.content
            if not content:
                try:
                    poem_path = Path(poem.file_path)
                    full_content = poem_path.read_text(encoding='utf-8')
                    if '---' in full_content:
                        parts = full_content.split('---', 2)
                        if len(parts) >= 3:
                            content = parts[2].strip()
                        else:
                            content = full_content
                    else:
                        content = full_content
                except Exception:
                    content = "[Content unavailable]"
    
            poems_data.append({
                "id": poem.id,
                "title": poem.title,
                "content": content[:500] + "..." if len(content) > 500 else content,  # Truncate for efficiency
                "current_tags": poem.tags or [],
                "state": poem.state,
            })
    
        # Format available themes
        themes_data = []
        for nexus in _nexus_registry.themes:
            desc_lines = nexus.description.split('\n')
            brief_desc = []
            for line in desc_lines:
                if line.strip() and not line.startswith('#'):
                    brief_desc.append(line.strip())
                    if len(brief_desc) >= 2:
                        break
            brief_text = ' '.join(brief_desc)[:150]
    
            themes_data.append({
                "name": nexus.name,
                "canonical_tag": nexus.canonical_tag,
                "description": brief_text,
            })
    
        instructions = """Analyze these poems and suggest themes for each.
    
    For each poem, provide 1-3 most relevant themes with:
    - **name**: Theme name (exactly as listed)
    - **canonical_tag**: Tag to use
    - **confidence**: Float 0.0-1.0
    - **evidence**: Brief reasoning
    
    After analysis, user can apply tags with link_poem_to_nexus(poem_id, nexus_name, "theme")"""
    
        logger.info(f"Prepared {len(poems_data)} poems for batch enrichment")
    
        return {
            "success": True,
            "poems": poems_data,
            "available_themes": themes_data,
            "total_count": len(poems_data),
            "instructions": instructions,
        }
  • MCP server registration of the tool using @mcp.tool() decorator. Provides the official tool interface and docstring for MCP clients/agents, delegating execution to the underlying _get_poems_for_enrichment imported from enrichment_tools.py.
    @mcp.tool()
    async def get_poems_for_enrichment(
        poem_ids: Optional[List[str]] = None,
        max_poems: int = 50,
    ) -> dict:
        """
        Get batch of poems needing theme enrichment for agent analysis.
    
        Returns poems with minimal or no tags for YOU (the agent) to analyze.
        YOU suggest which themes apply to each poem.
    
        Args:
            poem_ids: List of poem IDs (None = all untagged/lightly-tagged poems)
            max_poems: Maximum poems to return (default 50)
    
        Returns:
            Dictionary with:
            - poems: List of poem data (id, title, content, current_tags)
            - available_themes: Theme options with descriptions
            - instructions: Batch analysis guidance
    
        Example workflow:
            ```
            # 1. Get poems needing enrichment
            data = await get_poems_for_enrichment(max_poems=10)
    
            # 2. YOU analyze data['poems'] against data['available_themes']
            # 3. YOU suggest 1-3 themes for each poem with confidence scores
            # 4. User applies high-confidence tags with link_poem_to_nexus()
            ```
        """
        return await _get_poems_for_enrichment(poem_ids, max_poems)
  • Import of the underlying handler from enrichment_tools.py with alias _get_poems_for_enrichment, enabling the server.py wrapper to delegate tool execution.
    from .tools.enrichment_tools import (
        initialize_enrichment_tools,
        get_all_nexuses as _get_all_nexuses,
        link_poem_to_nexus as _link_poem_to_nexus,
        find_nexuses_for_poem as _find_nexuses_for_poem,
        get_poems_for_enrichment as _get_poems_for_enrichment,
        sync_nexus_tags as _sync_nexus_tags,
        move_poem_to_state as _move_poem_to_state,
        grade_poem_quality as _grade_poem_quality,
    )
Behavior4/5

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

With no annotations provided, the description carries the full burden and does well: it explains the tool returns poems for agent analysis, specifies the return structure (poems, available_themes, instructions), and mentions the default behavior (max_poems=50). However, it doesn't cover potential rate limits, authentication needs, or error conditions, leaving some behavioral aspects unspecified.

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

Conciseness5/5

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

The description is well-structured and front-loaded: the first sentence states the purpose, followed by key details (returns, args, returns), and ends with a practical example workflow. Every sentence adds value, with no redundancy or fluff, making it efficient for agent comprehension.

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

Completeness5/5

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

Given the tool's complexity (batch retrieval for analysis), no annotations, and an output schema (which covers return values), the description is complete: it explains purpose, usage, parameters, return structure, and provides an example workflow. This adequately guides the agent without needing to repeat output schema details.

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

Parameters5/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 fully. It does: it explains poem_ids as 'List of poem IDs (None = all untagged/lightly-tagged poems)' and max_poems as 'Maximum poems to return (default 50)', adding crucial meaning beyond the bare schema. The example workflow further clarifies usage.

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

Purpose5/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: 'Get batch of poems needing theme enrichment for agent analysis.' It specifies the verb ('Get'), resource ('poems'), and qualifying condition ('needing theme enrichment'), distinguishing it from siblings like get_poem (single poem) or find_poems_by_tag (already tagged).

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

Usage Guidelines5/5

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

The description explicitly states when to use this tool: for poems with 'minimal or no tags' that need theme analysis by the agent. It provides an example workflow showing this tool as step 1, followed by agent analysis and linking with link_poem_to_nexus, clearly differentiating it from sibling tools that retrieve already-tagged poems or manage states.

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