Skip to main content
Glama
truaxki
by truaxki

create_table

Create new SQLite database tables to log statistical variations in conversation structure for anomaly detection.

Instructions

Create a new table in the SQLite database

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesCREATE TABLE SQL statement

Implementation Reference

  • Handler for the 'create_table' tool: validates that the query starts with 'CREATE TABLE' and executes it using the database helper.
    elif name == "create_table":
        if not arguments["query"].strip().upper().startswith("CREATE TABLE"):
            raise ValueError("Only CREATE TABLE statements are allowed")
        db._execute_query(arguments["query"])
        return [types.TextContent(type="text", text="Table created successfully")]
  • Registration of the 'create_table' tool in the list_tools handler, including input schema.
    types.Tool(
        name="create_table",
        description="Create a new table in the SQLite database",
        inputSchema={
            "type": "object",
            "properties": {
                "query": {"type": "string", "description": "CREATE TABLE SQL statement"},
            },
            "required": ["query"],
        },
    ),
  • _execute_query method in LogDatabase class: generic SQL executor that handles CREATE statements by committing and returning affected rows count. Used by the create_table handler.
    def _execute_query(self, query: str, params: dict[str, Any] | None = None) -> list[dict[str, Any]]:
        """Execute a SQL query and return results as a list of dictionaries"""
        logger.debug(f"Executing query: {query}")
        try:
            with closing(sqlite3.connect(self.db_path)) as conn:
                conn.row_factory = sqlite3.Row
                with closing(conn.cursor()) as cursor:
                    if params:
                        cursor.execute(query, params)
                    else:
                        cursor.execute(query)
    
                    if query.strip().upper().startswith(('INSERT', 'UPDATE', 'DELETE', 'CREATE', 'DROP', 'ALTER')):
                        conn.commit()
                        affected = cursor.rowcount
                        logger.debug(f"Write query affected {affected} rows")
                        return [{"affected_rows": affected}]
    
                    results = [dict(row) for row in cursor.fetchall()]
                    logger.debug(f"Read query returned {len(results)} rows")
                    return results
        except Exception as e:
            logger.error(f"Database error executing query: {e}")
            raise

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

C2.6/5.0
Behavior2/5

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

No annotations are provided, so the description carries full burden. It only says 'Create a new table' without disclosing behavioral traits: whether it fully executes the query, whether confirmation is shown, effects on existing data, or error handling. The word 'Create' implies mutation but no safety details are given.

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 a single short sentence, concise and to the point. However, it could add more value in a sentence or two without being verbose.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given one parameter and no annotations or output schema, the description is insufficient. It doesn't address return value, error conditions, or how it differs from similar sibling tools. The agent lacks context to decide when to call this tool safely.

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

Parameters3/5

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

Schema coverage is 100%, so the parameter 'query' is already documented with description 'CREATE TABLE SQL statement'. The description adds no additional meaning beyond the schema. Baseline 3 is appropriate.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose3/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description states 'Create a new table in the SQLite database', which is clear but generic. It does not distinguish this tool from siblings like 'write_query' that could also create tables, especially since SQLite allows table creation via arbitrary SQL.

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

Usage Guidelines2/5

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

The description gives no guidance on when to use this tool versus alternatives such as 'write_query' or 'read_query'. It does not mention prerequisites (e.g., database must already exist) or limitations (e.g., no support for temporary tables).

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.