Skip to main content
Glama
ajkeast

My Coding Buddy MCP Server

by ajkeast

search_tables

Search for database tables and views matching a name pattern using wildcards.

Instructions

Search for tables and views matching a pattern.

Args: pattern (str): Search text or wildcard expression

Returns: str: Matching table and view names, one per line

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
patternYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The handler function for the search_tables MCP tool. Connects to a MySQL database and executes 'SHOW TABLES LIKE %s' with the given pattern, returning matching table/view names.
    def search_tables(self, pattern: str) -> str:
        """Search for tables and views matching a pattern.
        
        Args:
            pattern (str): Search text or wildcard expression
        
        Returns:
            str: Matching table and view names, one per line
        """
        with self.get_connection() as conn:
            cursor = conn.cursor()
            cursor.execute("SHOW TABLES LIKE %s", (pattern,))
            matches = [row[0] for row in cursor.fetchall()]
            return "\n".join(matches) if matches else f"No tables or views match '{pattern}'"
  • server.py:14-14 (registration)
    Registers the search_tables method as an MCP tool using FastMCP's decorator pattern.
    mcp.tool()(sql_tools.search_tables)
  • Helper context manager that provides a MySQL database connection used by the search_tables handler.
    @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()
  • Test case for the search_tables tool, verifying it returns a string when given a wildcard pattern.
    def test_search_tables(sql_tools: SQLTools):
        result = sql_tools.search_tables("%")
        assert isinstance(result, str)
Behavior3/5

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

No annotations provided, so description carries full burden. It states return format ('one per line') but lacks details on pattern syntax, case sensitivity, or edge cases like no matches.

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?

Description is concise (one sentence + args/returns) with clear structure. Every part adds value, though the Args/Returns section could be integrated more seamlessly.

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?

Covers basic purpose and return format, but lacks guidance on pattern syntax and when to prefer this over list_tables. With many siblings, more context would help.

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

Parameters4/5

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

The pattern parameter has no schema description, but the tool description adds 'Search text or wildcard expression', providing useful semantic context beyond type and name.

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?

Description clearly states 'Search for tables and views matching a pattern', specifying the verb (search) and resource (tables and views), and the pattern matching distinguishes it from sibling tools like list_tables.

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

Usage Guidelines3/5

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

No explicit guidance on when to use vs alternatives like list_tables or list_views. The description implies usage for pattern-based search but does not provide when-not scenarios or comparisons.

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