Skip to main content
Glama
burakdirin

mysqldb-mcp-server

connect_database

Connect to a specific MySQL database using the MCP server to enable SQL query execution and database management through Claude.

Instructions

Connect to a specific MySQL database

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
databaseYes

Implementation Reference

  • The connect_database tool handler, decorated with @mcp.tool() for registration. It retrieves the QueryExecutor from context and executes a USE query to switch to the specified database.
    @mcp.tool()
    def connect_database(database: str, ctx: Context) -> str:
        """Connect to a specific MySQL database"""
        try:
            executor = _get_executor(ctx)
            result = executor.execute_single_query(f"USE `{database}`")
            return json.dumps(result, indent=2)
        except (ConnectionError, QueryError) as e:
            return str(e)
  • Helper function used by connect_database to obtain the QueryExecutor instance from the MCP context.
    def _get_executor(ctx: Context) -> QueryExecutor:
        """Helper function to get QueryExecutor from context"""
        mysql_ctx = ctx.request_context.lifespan_context
        return QueryExecutor(mysql_ctx)
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 states the action but doesn't disclose behavioral traits like whether this establishes a persistent connection, requires authentication, has rate limits, or what happens on failure. For a connection tool with zero annotation coverage, this leaves critical operational details unspecified.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, clear sentence with no wasted words, making it easy to parse and front-loaded with essential information. Every word earns its place by specifying the action and target.

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 the tool's complexity (establishing a database connection), lack of annotations, no output schema, and low schema coverage, the description is insufficient. It doesn't cover what the tool returns, error conditions, or dependencies with the sibling 'execute_query' tool, leaving too many gaps for effective use.

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

Parameters2/5

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

Schema description coverage is 0%, and the description adds no parameter information beyond implying a 'database' parameter exists. It doesn't explain what the 'database' parameter represents (e.g., database name, connection string), valid values, or format, failing to compensate for the schema's lack of descriptions.

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 action ('Connect to') and target resource ('a specific MySQL database'), making the purpose immediately understandable. It doesn't explicitly distinguish from the sibling 'execute_query' tool, but the verb 'connect' versus 'execute' implies different operations.

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, prerequisites, or contextual constraints. With a sibling tool 'execute_query' available, there's no indication of whether connection must precede query execution or if they can be used independently.

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

Related 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/burakdirin/mysqldb-mcp-server'

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