Skip to main content
Glama
knishioka

Treasure Data MCP Server

by knishioka

td_analyze_url

Extract and retrieve detailed information from Treasure Data console URLs shared in Slack, email, or documentation for workflows, projects, and jobs.

Instructions

Analyze any Treasure Data console URL to get resource details.

Smart URL parser that extracts IDs and fetches information. Use when someone
shares a console link in Slack, email, or documentation.

Common scenarios:
- Someone shares workflow URL during incident investigation
- Documentation contains console links to resources
- Error message includes console URL reference
- Quick lookup from browser URL copy/paste

Supported formats:
- Workflow: https://console.../app/workflows/12345678/info
- Project: https://console.../app/projects/123456
- Job: https://console.../app/jobs/123456

Automatically detects type and returns full resource information.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
urlYes

Implementation Reference

  • The main asynchronous handler function for the 'td_analyze_url' tool. It parses input URLs for Treasure Data console resources (workflows, projects, jobs), extracts IDs using regex, and fetches details using client APIs or delegates to td_get_workflow for workflows.
    async def td_analyze_url(url: str) -> dict[str, Any]:
        """Analyze any Treasure Data console URL to get resource details.
    
        Smart URL parser that extracts IDs and fetches information. Use when someone
        shares a console link in Slack, email, or documentation.
    
        Common scenarios:
        - Someone shares workflow URL during incident investigation
        - Documentation contains console links to resources
        - Error message includes console URL reference
        - Quick lookup from browser URL copy/paste
    
        Supported formats:
        - Workflow: https://console.../app/workflows/12345678/info
        - Project: https://console.../app/projects/123456
        - Job: https://console.../app/jobs/123456
    
        Automatically detects type and returns full resource information.
        """
        if not url or not url.strip():
            return _format_error_response("URL cannot be empty")
    
        # Parse workflow URL
        workflow_match = re.search(r"/app/workflows/(\d+)", url)
        if workflow_match:
            workflow_id = workflow_match.group(1)
            return await td_get_workflow(workflow_id)
    
        # Parse project URL
        project_match = re.search(r"/app/projects/(\d+)", url)
        if project_match:
            project_id = project_match.group(1)
            client = _create_client(include_workflow=True)
            if isinstance(client, dict):
                return client
    
            try:
                project = client.get_project(project_id)
                if project:
                    return {"type": "project", "project": project.model_dump()}
                else:
                    return _format_error_response(
                        f"Project with ID '{project_id}' not found"
                    )
            except Exception as e:
                return _format_error_response(f"Failed to get project: {str(e)}")
    
        # Parse job URL
        job_match = re.search(r"/app/jobs/(\d+)", url)
        if job_match:
            job_id = job_match.group(1)
            return {
                "type": "job",
                "job_id": job_id,
                "message": "Job information retrieval not yet implemented",
            }
    
        return _format_error_response(
            "Unrecognized URL format. Supported: /app/workflows/ID, /app/projects/ID"
        )
  • The registration function that sets up globals and applies the MCP tool decorator to td_analyze_url (and td_get_workflow), making it available as an MCP tool.
    def register_url_tools(mcp_instance, create_client_func, format_error_func):
        """Register URL tools with the provided MCP instance."""
        global mcp, _create_client, _format_error_response
        mcp = mcp_instance
        _create_client = create_client_func
        _format_error_response = format_error_func
    
        # Register all tools
        mcp.tool()(td_analyze_url)
        mcp.tool()(td_get_workflow)
  • Invocation of the register_url_tools function during MCP server initialization, which triggers the tool registration for td_analyze_url.
    url_tools.register_url_tools(mcp, _create_client, _format_error_response)
  • Supporting helper function called by td_analyze_url for workflow-specific lookups, providing detailed workflow information including project, schedule, sessions, and console URL.
    async def td_get_workflow(workflow_id: str) -> dict[str, Any]:
        """Get workflow details using numeric ID - essential for console URLs.
    
        Direct workflow lookup when you have the ID. Handles large workflow IDs
        that exceed pagination limits. Returns project info and execution history.
    
        Common scenarios:
        - Extracting ID from console URL (../workflows/12345678/info)
        - Looking up workflow from error logs containing ID
        - Getting project context for a known workflow ID
        - Checking execution status by workflow ID
    
        Returns workflow name, project details, schedule, and recent runs.
        Includes console URL for quick browser access.
        """
        if not workflow_id or not workflow_id.strip():
            return _format_error_response("Workflow ID cannot be empty")
    
        # Validate workflow ID format
        if not re.match(r"^\d+$", workflow_id):
            return _format_error_response("Invalid workflow ID format. Must be numeric.")
    
        client = _create_client(include_workflow=True)
        if isinstance(client, dict):
            return client
    
        try:
            # First try the direct API endpoint
            workflow = client.get_workflow_by_id(workflow_id)
    
            if workflow:
                # Found the workflow via direct API
                result: dict[str, Any] = {
                    "type": "workflow",
                    "workflow": {
                        "id": workflow.id,
                        "name": workflow.name,
                        "project": {
                            "id": workflow.project.id,
                            "name": workflow.project.name,
                        },
                        "timezone": workflow.timezone,
                        "scheduled": workflow.schedule is not None,
                    },
                }
    
                # Add schedule info if available
                if workflow.schedule:
                    result["workflow"]["schedule"] = workflow.schedule
    
                # Add latest session info if available
                # Note: Direct API might not include session info
                if workflow.latest_sessions:
                    latest_sessions = []
                    for session in workflow.latest_sessions[:5]:  # Last 5 sessions
                        latest_sessions.append(
                            {
                                "session_time": session.session_time,
                                "status": session.last_attempt.status,
                                "success": session.last_attempt.success,
                            }
                        )
                    result["workflow"]["latest_sessions"] = latest_sessions
    
                # Construct console URL
                result[
                    "console_url"
                ] = f"https://console.treasuredata.com/app/workflows/{workflow_id}/info"
    
                return result
    
            # If not found via direct API, fall back to searching through all workflows
            # This might be needed for workflows accessible via console API only
            workflows = client.get_workflows(count=1000, all_results=True)
    
            for workflow in workflows:
                if workflow.id == workflow_id:
                    # Found the workflow
                    result = {
                        "type": "workflow",
                        "workflow": {
                            "id": workflow.id,
                            "name": workflow.name,
                            "project": {
                                "id": workflow.project.id,
                                "name": workflow.project.name,
                            },
                            "timezone": workflow.timezone,
                            "scheduled": workflow.schedule is not None,
                        },
                    }
    
                    # Add schedule info if available
                    if workflow.schedule:
                        result["workflow"]["schedule"] = workflow.schedule
    
                    # Add latest session info if available
                    if workflow.latest_sessions:
                        latest_sessions = []
                        for session in workflow.latest_sessions[:5]:  # Last 5 sessions
                            latest_sessions.append(
                                {
                                    "session_time": session.session_time,
                                    "status": session.last_attempt.status,
                                    "success": session.last_attempt.success,
                                }
                            )
                        result["workflow"]["latest_sessions"] = latest_sessions
    
                    # Construct console URL
                    result[
                        "console_url"
                    ] = f"https://console.treasuredata.com/app/workflows/{workflow_id}/info"
    
                    return result
    
            return _format_error_response(f"Workflow with ID '{workflow_id}' not found")
    
        except Exception as e:
            return _format_error_response(f"Failed to get workflow: {str(e)}")
Behavior4/5

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

With no annotations provided, the description carries full burden and does well: it explains the smart parsing behavior, automatic type detection, and returns full resource information. However, it doesn't mention error handling for invalid URLs or rate limits. No contradiction exists since annotations are absent.

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?

Well-structured with purpose first, usage guidelines, scenarios, supported formats, and behavioral note. Every sentence adds value: no repetition, no fluff. The bullet points enhance readability without wasting space.

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?

For a single-parameter tool with no annotations or output schema, the description is quite complete: purpose, usage, scenarios, supported formats, and behavior. It could improve by detailing the output structure or error cases, but it's sufficient for the tool's complexity.

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?

Schema description coverage is 0% (parameter 'url' has no description in schema), but the description compensates well by explaining what the URL should be: 'Treasure Data console URL' with three specific format examples. It adds meaning beyond the bare schema, though it could specify URL validation rules.

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: 'Analyze any Treasure Data console URL to get resource details' with specific verbs (analyze, extracts IDs, fetches information). It distinguishes from siblings by focusing on URL parsing rather than direct resource lookup (e.g., td_get_project, td_get_workflow).

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?

Explicit guidance is provided: 'Use when someone shares a console link in Slack, email, or documentation' with four specific scenarios listed. It clearly indicates when this tool is appropriate versus using direct resource-fetching siblings like td_get_project or td_get_workflow.

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