td_get_database
Retrieve database details including table count, permissions, and metadata from Treasure Data to verify properties, check access levels, and audit database information.
Instructions
Get specific database details like table count, permissions, and metadata.
Shows detailed information about a named database. Use when you need to check
database properties, understand access permissions, or get table statistics.
Common scenarios:
- Verify database exists before running queries
- Check permission level (administrator, read-only, etc.)
- Get table count and creation/update timestamps
- Audit database properties for documentation
Returns creation time, table count, permissions, and protection status.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| database_name | Yes |
Implementation Reference
- td_mcp_server/mcp_impl.py:192-229 (handler)The primary handler function for the 'td_get_database' tool. It is decorated with @mcp.tool(), which registers it with the FastMCP server. The function validates the database_name input, creates a TreasureDataClient instance, retrieves the database details using client.get_database(), and returns the database information as a dictionary or an error message.@mcp.tool() async def td_get_database(database_name: str) -> dict[str, Any]: """Get specific database details like table count, permissions, and metadata. Shows detailed information about a named database. Use when you need to check database properties, understand access permissions, or get table statistics. Common scenarios: - Verify database exists before running queries - Check permission level (administrator, read-only, etc.) - Get table count and creation/update timestamps - Audit database properties for documentation Returns creation time, table count, permissions, and protection status. """ # Input validation if not database_name or not database_name.strip(): return _format_error_response("Database name cannot be empty") client = _create_client() if isinstance(client, dict): return client try: database = client.get_database(database_name) if database: return {"database": database.model_dump()} else: return _format_error_response(f"Database '{database_name}' not found") except (ValueError, requests.RequestException) as e: return _format_error_response( f"Failed to retrieve database '{database_name}': {str(e)}" ) except Exception as e: return _format_error_response( f"Unexpected error while retrieving database '{database_name}': {str(e)}" )
- td_mcp_server/mcp_impl.py:193-193 (schema)The function signature defines the input schema (database_name: str) and output type (dict[str, Any]), which serves as the tool's parameter schema in FastMCP.async def td_get_database(database_name: str) -> dict[str, Any]:
- td_mcp_server/mcp_impl.py:192-192 (registration)The @mcp.tool() decorator registers the td_get_database function as an MCP tool with the FastMCP server instance 'mcp'.@mcp.tool()