Skip to main content
Glama
knishioka

Treasure Data MCP Server

by knishioka

td_download_project_archive

Download a Treasure Data workflow project archive containing SQL queries, Digdag files, Python scripts, and resources. Retrieve the complete project bundle for backup or migration purposes.

Instructions

Download a project's archive (tar.gz) and return information about the download.

This tool downloads the complete archive of a Treasure Data workflow project,
which contains all SQL queries, Digdag (.dig) files, Python scripts, and other
resources. The file is temporarily stored on the server.

Args:
    project_id: The ID of the workflow project to download

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
project_idYes

Implementation Reference

  • The @mcp.tool()-decorated handler function that implements the td_download_project_archive tool. It validates input, creates a TreasureDataClient, downloads the project archive to a secure temporary location, and returns metadata including the archive path.
    @mcp.tool()
    async def td_download_project_archive(project_id: str) -> dict[str, Any]:
        """Download a project's archive (tar.gz) and return information about the download.
    
        This tool downloads the complete archive of a Treasure Data workflow project,
        which contains all SQL queries, Digdag (.dig) files, Python scripts, and other
        resources. The file is temporarily stored on the server.
    
        Args:
            project_id: The ID of the workflow project to download
        """
        # Input validation - prevent path traversal
        if not _validate_project_id(project_id):
            return _format_error_response("Invalid project ID format")
    
        client = _create_client(include_workflow=True)
        if isinstance(client, dict):
            return client
    
        try:
            # Create temporary directory with secure permissions
            temp_dir = tempfile.mkdtemp(prefix="td_project_")
            os.chmod(temp_dir, TEMP_DIR_PERMISSIONS)
            # Use sanitized project_id for filename
            safe_filename = re.sub(r"[^a-zA-Z0-9_-]", "_", project_id)
            output_path = os.path.join(temp_dir, f"project_{safe_filename}.tar.gz")
    
            # Check that project exists before attempting download
            project = client.get_project(project_id)
            if not project:
                return {"error": f"Project with ID '{project_id}' not found"}
    
            # Download the archive
            success = client.download_project_archive(project_id, output_path)
    
            if not success:
                return {"error": f"Failed to download archive for project '{project_id}'"}
    
            return {
                "success": True,
                "project_id": project_id,
                "project_name": project.name,
                "archive_path": output_path,
                "temp_dir": temp_dir,
                "message": f"Successfully downloaded archive for project '{project.name}'",
            }
        except (ValueError, requests.RequestException, OSError) as e:
            return _format_error_response(f"Failed to download project archive: {str(e)}")
        except Exception as e:
            return _format_error_response(
                f"Unexpected error while downloading project archive: {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. It discloses that the file is 'temporarily stored on the server,' which is useful behavioral context beyond basic functionality. However, it doesn't mention authentication requirements, rate limits, file size constraints, or how long the temporary storage lasts, leaving gaps for a download operation.

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 well-structured and front-loaded with the core purpose, followed by details and parameter explanation. It avoids redundancy, but could be slightly more concise by integrating the parameter note into the main flow rather than a separate 'Args' section.

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 no annotations, no output schema, and low schema coverage, the description provides a solid foundation but lacks details on return values (only mentions 'return information about the download' vaguely), error handling, or operational constraints. It's minimally viable but has clear gaps for a tool that involves file downloads and server-side storage.

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

Parameters4/5

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

The description adds meaningful context for the single parameter 'project_id' by explaining it refers to 'the ID of the workflow project to download,' which clarifies its purpose beyond the schema's minimal title 'Project Id.' With 0% schema description coverage and only one parameter, this compensation is adequate, though not exhaustive.

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 ('download a project's archive') and resource ('Treasure Data workflow project'), distinguishing it from sibling tools like td_list_project_files or td_read_project_file. It specifies the output format (tar.gz) and content (SQL queries, Digdag files, Python scripts, resources).

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

Usage Guidelines3/5

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

The description implies usage by mentioning it downloads 'the complete archive' for a project, suggesting it's for bulk retrieval rather than individual file access. However, it doesn't explicitly state when to use this tool versus alternatives like td_list_project_files or td_read_project_file, nor does it mention prerequisites 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/knishioka/td-mcp-server'

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