Skip to main content
Glama
ajkeast

My Coding Buddy MCP Server

by ajkeast

get_table_row_count

Get the approximate row count for a specified table to quickly assess data volume and table size.

Instructions

Get the approximate row count for a table.

Args: table_name (str): Table name to inspect

Returns: str: Row count information

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
table_nameYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The `get_table_row_count` method on the `SQLTools` class — executes `SELECT COUNT(*) FROM` for a given table and returns a formatted string with the row count.
    def get_table_row_count(self, table_name: str) -> str:
        """Get the approximate row count for a table.
        
        Args:
            table_name (str): Table name to inspect
        
        Returns:
            str: Row count information
        """
        with self.get_connection() as conn:
            cursor = conn.cursor()
            cursor.execute(f"SELECT COUNT(*) FROM `{table_name}`")
            row_count = cursor.fetchone()
    
            if row_count is None:
                return f"Unable to retrieve row count for '{table_name}'"
    
            return f"{table_name} row count: {row_count[0]}"
  • server.py:19-19 (registration)
    Registration of `get_table_row_count` as an MCP tool via `mcp.tool()` decorator.
    mcp.tool()(sql_tools.get_table_row_count)
  • The method signature `def get_table_row_count(self, table_name: str) -> str:` defines the input (table_name: str) and output (str) types.
    def get_table_row_count(self, table_name: str) -> str:
  • The `get_connection` context manager helper used by `get_table_row_count` to obtain a database connection.
    @contextmanager
    def get_connection(self):
        """Context manager for database connections.
        
        Yields:
            mysql.connector.connection: Database connection object
            
        Raises:
            Error: If connection to the database fails
        """
        connection = None
        try:
            connection = mysql.connector.connect(
                host=self.host,
                user=self.user,
                password=self.password,
                database=self.database
            )
            yield connection
        except Error as e:
            print(f"Error connecting to MySQL database: {e}")
            raise
        finally:
            if connection and connection.is_connected():
                connection.close()
Behavior2/5

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

With no annotations provided, the description bears full responsibility for behavioral disclosure. It only mentions 'approximate', but does not explain side effects (e.g., locking, performance), or what 'approximate' implies (e.g., stale statistics). The return format is vague ('Row count information').

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 concise with one sentence plus a structured Args/Returns block. The key purpose is front-loaded. It could be even tighter without the args section, but it's efficient overall.

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

Completeness3/5

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

Given the tool's simplicity (one parameter, output schema exists), the description covers the basic action. However, it omits details about the return string format, error conditions, and why one would choose this over execute_query. The output schema might provide format info, but the description doesn't leverage it.

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 0%, so the description must compensate. It adds a minimal description for table_name ('Table name to inspect'), which is slightly more informative than the schema's title 'Table Name'. However, for a single string parameter, this is adequate but not exceptional.

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

Purpose4/5

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

The description clearly states the verb 'Get' and the resource 'approximate row count for a table'. It distinguishes from sibling tools like get_table_schema or execute_query by specifying 'approximate', hinting at a distinct purpose. However, it could be more explicit about why the count is approximate.

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 provides no guidance on when to use this tool versus alternatives such as execute_query for exact counts or list_tables. It lacks any 'when' or 'when-not' context, leaving the agent without decision support.

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/ajkeast/Coding-Buddy-MCP-Server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server