Skip to main content
Glama

ShallowCodeResearch_agent_citation_formatter

Format citations from URLs in text blocks into APA-style references using a citation formatter agent.

Instructions

Wrapper for CitationFormatterAgent to format citations. Returns: Formatted citations result with APA-style references

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
text_blockNoThe text containing URLs to cite

Implementation Reference

  • app.py:1008-1015 (registration)
    Gradio Interface registration for the citation formatter tool, exposing it as an MCP tool with api_name 'agent_citation_formatter_service' which likely corresponds to the queried tool name in the ShallowCodeResearch context.
    gr.Interface(
        fn=agent_citation_formatter,
        inputs=[gr.Textbox(label="Text Block with Citations", lines=12, placeholder="Enter text to format citations…")],
        outputs=gr.JSON(label="Formatted Citations", height=305),
        title="Citation Formatter Agent",
        description="Extracts and formats APA-style citations from text blocks.",
        api_name="agent_citation_formatter_service",
    )
  • app.py:764-774 (handler)
    Wrapper handler function in app.py that calls the CitationFormatterAgent's format_citations method, serving as the direct MCP tool handler.
    def agent_citation_formatter(text_block: str) -> dict:
        """
        Wrapper for CitationFormatterAgent to format citations.
    
        Args:
            text_block (str): The text containing URLs to cite
    
        Returns:
            dict: Formatted citations result with APA-style references
        """
        return citation_formatter.format_citations(text_block)
  • Core implementation of the citation formatting logic in CitationFormatterAgent.format_citations, extracting URLs and generating APA citations.
    @with_performance_tracking("citation_formatting")
    def format_citations(self, text_block: str) -> Dict[str, Any]:
        """
        Extract URLs from text and produce APA-style citations.
    
        Analyzes the provided text block to identify URLs and automatically
        generates properly formatted academic citations following APA style
        guidelines for web sources.
    
        Args:
            text_block (str): The text content containing URLs to be cited
    
        Returns:
            Dict[str, Any]: A dictionary containing formatted citations array
                           or error information if extraction fails
        """
        try:
            validate_non_empty_string(text_block, "Text block")
            logger.info("Formatting citations from text block")
            
            urls = extract_urls_from_text(text_block)
            if not urls:
                return {"error": "No URLs found to cite.", "formatted_citations": []}
            
            citations = []
            for url in urls:
                citation = create_apa_citation(url)
                citations.append(citation)
            
            logger.info(f"Successfully formatted {len(citations)} citations")
            return {"formatted_citations": citations, "error": None}
            
        except ValidationError as e:
            logger.error(f"Citation formatting validation failed: {str(e)}")
            return {"error": str(e), "formatted_citations": []}
        except Exception as e:
            logger.error(f"Citation formatting failed: {str(e)}")
            return {"error": f"Unexpected error: {str(e)}", "formatted_citations": []}
  • Helper function to create individual APA-style citations from URLs, used by the citation formatter.
    def create_apa_citation(url: str, year: str = None) -> str:
        """Create a simple APA-style citation from a URL."""
        if not year:
            year = api_config.current_year
        
        try:
            domain = url.split("/")[2]
            title = domain.replace("www.", "").split(".")[0].capitalize()
            return f"{title}. ({year}). Retrieved from {url}"
        except (IndexError, AttributeError):
            return f"Unknown Source. ({year}). Retrieved from {url}"
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions the tool is a 'wrapper for CitationFormatterAgent' and returns formatted citations, but doesn't describe what 'wrapper' means operationally, whether it makes external API calls, has rate limits, requires specific permissions, or what happens with malformed input. For a tool with zero 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 concise with two sentences that directly state the tool's function and output format. It's front-loaded with the core purpose and avoids unnecessary elaboration. However, it could be slightly more structured by explicitly separating purpose from output details.

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 has no annotations, no output schema, and a simple single parameter with good schema coverage, the description provides basic completeness about what the tool does and its output format. However, for a tool that presumably processes text and returns formatted citations, more detail about behavioral characteristics (like error handling or processing constraints) would improve completeness.

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?

The input schema has 100% description coverage, with the single parameter 'text_block' clearly documented as 'The text containing URLs to cite'. The description adds that it formats citations and returns APA-style references, which provides context about what the parameter should contain, but doesn't add significant semantic value beyond what the schema already provides. Baseline 3 is appropriate when schema coverage is high.

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 as 'format citations' and specifies it returns 'APA-style references', which provides specific verb+resource information. However, it doesn't explicitly differentiate from sibling tools like 'ShallowCodeResearch_agent_question_enhancer' or 'ShallowCodeResearch_agent_research_request' that might also handle citation-related tasks.

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 when to choose this citation formatter over other tools in the server or what specific scenarios it's designed for. The only implied usage is formatting citations, but no explicit context or exclusions are provided.

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/CodeHalwell/gradio-mcp-agent-hack'

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