Skip to main content
Glama

move_article_to_trash

Move articles to trash on Joomla websites for temporary deletion with recovery option. Specify article ID to manage content removal.

Instructions

Delete an article by moving to the trashed state on the Joomla website, allowing recovery.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
article_idYes
expected_titleNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • main.py:265-267 (registration)
    Registers the 'move_article_to_trash' tool with the FastMCP server using the @mcp.tool decorator, providing a description.
    @mcp.tool(
        description="Delete an article by moving to the trashed state on the Joomla website, allowing recovery."
    )
  • main.py:268-315 (handler)
    The main handler function for the 'move_article_to_trash' tool. It verifies the article exists, optionally checks the title matches, ensures it's not already trashed, and delegates to manage_article_state(article_id, -2) to update the state to trashed.
    async def move_article_to_trash(article_id: int, expected_title: str = None) -> str:
        """
        Delete an article by moving it to the trashed state (-2) on the Joomla website via its API.
        Verifies article existence and optionally checks the title to prevent moving the wrong article.
        The article remains in the database for potential recovery.
    
        Args:
            article_id(int): The ID of the article to move to trash.
            expected_title: Optional title to verify the correct article (case-insensitive partial match).
    
        Returns:
            Result string indicating success or failure.
        """
        try:
            if not isinstance(article_id, int):
                return "Error: Article ID must be an integer."
            headers = {
                "Accept": "application/vnd.api+json",
                "Content-Type": "application/json",
                "User-Agent": "JoomlaArticlesMCP/1.0",
                "Authorization": f"Bearer {BEARER_TOKEN}",
            }
            async with httpx.AsyncClient() as client:
                response = await client.get(
                    f"{JOOMLA_ARTICLES_API_URL}/{article_id}", headers=headers
                )
            if response.status_code != 200:
                return (
                    f"Failed to find article: HTTP {response.status_code} - {response.text}"
                )
            try:
                data = json.loads(response.text)
                article_data = data.get("data", {}).get("attributes", {})
                title = article_data.get("title", "Unknown")
                current_state = article_data.get("state", 0)
            except json.JSONDecodeError:
                return f"Failed to parse article data: Invalid JSON - {response.text}"
            if expected_title:
                if not title.lower().find(expected_title.lower()) >= 0:
                    return f"Error: Article ID {article_id} has title '{title}', which does not match expected title '{expected_title}'."
            if current_state == -2:
                return f"Article '{title}' (ID: {article_id}) is already in trashed state."
            return await manage_article_state(article_id, -2)
        except httpx.HTTPError as e:
            return f"Error moving article to trash: {str(e)}. Please check network connectivity or Joomla API availability."
        except Exception as e:
            return f"Unexpected error: {str(e)}. Please try again or contact support."
  • Supporting function 'manage_article_state' used by move_article_to_trash to perform the actual state update to trashed (-2). This is a shared utility for managing article states.
    async def manage_article_state(article_id: int, target_state: int) -> str:
        """
        Manage the state of an existing article on the Joomla website via its API. Updates the article to the
        user-specified state (published=1, unpublished=0, archived=2, trashed=-2) if it differs from the current state.
    
        Args:
            article_id(int): The ID of the existing article to check and update.
            target_state: The desired state for the article (1=published, 0=unpublished, 2=archived, -2=trashed).
    
        Returns:
            Success message with article title, ID, and state change, or an error message if the request fails.
        """
        try:
            if not isinstance(article_id, int):
                return "Error: Article ID must be an integer."
            valid_states = {1, 0, 2, -2}
            if target_state not in valid_states:
                return f"Error: Invalid target state {target_state}. Valid states are 1 (published), 0 (unpublished), 2 (archived), -2 (trashed)."
            headers = {
                "Accept": "application/vnd.api+json",
                "Content-Type": "application/json",
                "User-Agent": "JoomlaArticlesMCP/1.0",
                "Authorization": f"Bearer {BEARER_TOKEN}",
            }
            async with httpx.AsyncClient() as client:
                response = await client.get(
                    f"{JOOMLA_ARTICLES_API_URL}/{article_id}", headers=headers
                )
            if response.status_code != 200:
                return f"Failed to fetch article: HTTP {response.status_code} - {response.text}"
            try:
                data = json.loads(response.text)
                article_data = data.get("data", {}).get("attributes", {})
                current_state = article_data.get("state", 0)
                title = article_data.get("title", "Unknown")
            except json.JSONDecodeError:
                return f"Failed to parse article data: Invalid JSON - {response.text}"
            state_map = {1: "published", 0: "unpublished", 2: "archived", -2: "trashed"}
            current_state_name = state_map.get(current_state, "unknown")
            target_state_name = state_map.get(target_state, "unknown")
            if current_state == target_state:
                return f"Article '{title}' (ID: {article_id}) is already in {current_state_name} state."
            payload = {"state": target_state}
            async with httpx.AsyncClient() as client:
                response = await client.patch(
                    f"{JOOMLA_ARTICLES_API_URL}/{article_id}", json=payload, headers=headers
                )
            if response.status_code in (200, 204):
                return f"Successfully updated article '{title}' (ID: {article_id}) from {current_state_name} to {target_state_name} state."
            else:
                return f"Failed to update article state: HTTP {response.status_code} - {response.text}"
        except httpx.HTTPError as e:
            return f"Error updating article state: {str(e)}"
        except Exception as e:
            return f"Unexpected error: {str(e)}"
Behavior3/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 effectively describes the action as moving to a trashed state with recovery, which clarifies it's a soft delete. However, it lacks details on permissions, side effects, or error handling, leaving gaps in behavioral understanding.

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 a single, efficient sentence that front-loads the key action and includes essential context ('allowing recovery') without any wasted words, making it highly concise and well-structured.

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

Completeness4/5

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

Given the tool's complexity (soft deletion with 2 parameters) and the presence of an output schema (which handles return values), the description is mostly complete. It covers the core purpose and behavioral trait (recovery), but lacks parameter explanations and detailed usage guidelines, slightly reducing 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?

Schema description coverage is 0%, so the description must compensate for undocumented parameters. It doesn't mention any parameters, failing to explain 'article_id' or 'expected_title' beyond what the schema provides. Baseline is 3 due to the schema doing the heavy lifting, but no additional semantic value is added.

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 specific action ('Delete an article by moving to the trashed state') and resource ('on the Joomla website'), distinguishing it from siblings like 'create_article' or 'update_article' by focusing on deletion with recovery capability.

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

Usage Guidelines4/5

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

The description implies usage context by mentioning 'allowing recovery,' which suggests this is for soft deletion rather than permanent removal. However, it doesn't explicitly state when to use this versus alternatives like 'manage_article_state' or other deletion methods, leaving some ambiguity.

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/nasoma/joomla-mcp-server'

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