Skip to main content
Glama
knishioka

Treasure Data MCP Server

by knishioka

td_list_databases

Retrieve available databases to discover data sources and verify access permissions. Shows database names for quick overview or detailed information like table counts.

Instructions

List available databases to find data sources and check access.

Shows all databases you can access. Returns just names for quick overview,
or set verbose=True for details like table count and permissions.

Common scenarios:
- Discover what databases are available in your account
- Check permissions on specific databases
- Get database list for documentation or auditing

Use pagination (limit/offset) for large lists or all_results=True for everything.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
verboseNo
limitNo
offsetNo
all_resultsNo

Implementation Reference

  • The primary handler function td_list_databases decorated with @mcp.tool(). It creates a TreasureDataClient, calls get_databases on it, and returns either database names or full details based on verbose flag.
    @mcp.tool()
    async def td_list_databases(
        verbose: bool = False,
        limit: int = DEFAULT_LIMIT,
        offset: int = 0,
        all_results: bool = False,
    ) -> dict[str, Any]:
        """List available databases to find data sources and check access.
    
        Shows all databases you can access. Returns just names for quick overview,
        or set verbose=True for details like table count and permissions.
    
        Common scenarios:
        - Discover what databases are available in your account
        - Check permissions on specific databases
        - Get database list for documentation or auditing
    
        Use pagination (limit/offset) for large lists or all_results=True for everything.
        """
        client = _create_client()
        if isinstance(client, dict):
            return client
    
        try:
            databases = client.get_databases(
                limit=limit, offset=offset, all_results=all_results
            )
    
            if verbose:
                # Return full database details
                return {"databases": [db.model_dump() for db in databases]}
            else:
                # Return only database names
                return {"databases": [db.name for db in databases]}
        except (ValueError, requests.RequestException) as e:
            return _format_error_response(f"Failed to retrieve databases: {str(e)}")
        except Exception as e:
            return _format_error_response(
                f"Unexpected error while retrieving databases: {str(e)}"
            )
  • Pydantic model Database used to parse and validate the database information returned from the Treasure Data API.
    class Database(BaseModel):
        """Model representing a Treasure Data database."""
    
        name: str
        created_at: str
        updated_at: str
        count: int
        organization: str | None = None
        permission: str
        delete_protected: bool
  • Helper method in TreasureDataClient that fetches the list of databases from the TD API endpoint '/database/list' and applies pagination.
    def get_databases(
        self, limit: int = 30, offset: int = 0, all_results: bool = False
    ) -> list[Database]:
        """
        Retrieve a list of databases with pagination support.
    
        Args:
            limit: Maximum number of databases to retrieve (defaults to 30)
            offset: Index to start retrieving from (defaults to 0)
            all_results: If True, retrieves all databases ignoring limit and offset
    
        Returns:
            A list of Database objects
    
        Raises:
            requests.HTTPError: If the API returns an error response
        """
        response = self._make_request("GET", "database/list")
        all_databases = [Database(**db) for db in response.get("databases", [])]
    
        if all_results:
            return all_databases
        else:
            end_index = (
                offset + limit
                if offset + limit <= len(all_databases)
                else len(all_databases)
            )
            return all_databases[offset:end_index]
  • Helper function to create the TreasureDataClient instance from environment variables, used by td_list_databases.
    def _create_client(
        include_workflow: bool = False,
    ) -> TreasureDataClient | dict[str, str]:
        """Create TreasureDataClient with environment credentials.
    
        Args:
            include_workflow: Whether to include workflow endpoint
    
        Returns:
            TreasureDataClient instance or error dict if API key missing
        """
        api_key, endpoint, workflow_endpoint = _get_api_credentials()
    
        if not api_key:
            return _format_error_response("TD_API_KEY environment variable is not set")
    
        kwargs = {"api_key": api_key, "endpoint": endpoint}
        if include_workflow and workflow_endpoint:
            kwargs["workflow_endpoint"] = workflow_endpoint
    
        return TreasureDataClient(**kwargs)
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 of behavioral disclosure. It effectively describes key behaviors: it's a read operation (implied by 'List'), returns names or details based on verbose flag, supports pagination, and can fetch all results. However, it doesn't mention rate limits, authentication needs, or error handling, leaving some gaps.

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 with the core purpose. Each sentence earns its place: the first states the action, the second explains output options, the third lists usage scenarios, and the fourth covers pagination. There is no wasted text, making it efficient and clear.

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 moderate complexity (4 parameters, no output schema, no annotations), the description is largely complete. It covers purpose, usage, parameters, and behavior. However, it lacks details on output format (e.g., structure of returned data) and error cases, which would enhance completeness for a tool with no output schema.

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. It adds significant meaning beyond the schema: explains that verbose=True returns details like 'table count and permissions,' and clarifies that pagination (limit/offset) is for 'large lists' while all_results=True fetches 'everything.' This provides essential context not in the schema.

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 ('List available databases') and resource ('databases'), distinguishing it from siblings like td_list_tables or td_list_projects. It explicitly mentions the purpose is to 'find data sources and check access,' providing clear differentiation.

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 provides explicit guidance on when to use this tool through 'Common scenarios' (e.g., 'Discover what databases are available,' 'Check permissions,' 'Get database list for documentation'). It also mentions usage patterns like pagination for large lists, offering clear context without 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