test_table_exists
Check if a specified stable exists in the current TDengine database configuration. Verify table presence before performing database operations.
Instructions
Important: Check if the stable exists in the current Taos database(涛思数据库) configuration.
Args:
stable_name (str): The name of the stable.
Returns:
Dict: The `stable_name` exists or not in the current Taos configuration. If the `stable_name` does not exist, an empty dictionary is returned.
The key of the dictionary is the `stable_name` name, and the value is a boolean indicating whether the `stable_name` exists.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| stable_name | Yes | The name of the stable |
Implementation Reference
- Implementation of the "test_table_exists" tool, which checks for the existence of a stable in the TDengine database by executing a SHOW STABLES LIKE query.
@mcp.tool(name="test_table_exists") def test_table_exists( ctx: Context, stable_name: str = Field(description="The name of the stable"), ) -> Dict[str, bool]: """**Important**: Check if the `stable` exists in the current `Taos database(涛思数据库)` configuration. Args: stable_name (str): The name of the stable. Returns: Dict: The `stable_name` exists or not in the current Taos configuration. If the `stable_name` does not exist, an empty dictionary is returned. The key of the dictionary is the `stable_name` name, and the value is a boolean indicating whether the `stable_name` exists. """ taos = ctx.request_context.lifespan_context.client query = f"SHOW STABLES LIKE '{stable_name}'" result = taos.execute_sql(query) return {stable_name: bool(result)}