Skip to main content
Glama
JJVvV

SP Database MCP Server

by JJVvV

list_all_tables

Retrieve all database tables to understand schema structure and available data sources for query planning and analysis.

Instructions

列出所有数据库表

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sourceNo数据源类型auto

Implementation Reference

  • Handler logic in the main call_tool function for the list_all_tables tool: parses arguments, delegates to _list_all_tables helper, formats and returns markdown list of table names.
    elif name == "list_all_tables":
        source = arguments.get("source", "auto")
    
        tables = await _list_all_tables(source)
        if tables:
            output = f"数据库中共有 {len(tables)} 个表:\n\n"
            for table_name in sorted(tables):
                output += f"- {table_name}\n"
            return [TextContent(type="text", text=output)]
        else:
            return [TextContent(type="text", text="未找到任何表")]
  • Registration of the list_all_tables tool in list_tools(), including description and input schema allowing optional 'source' parameter.
    Tool(
        name="list_all_tables",
        description="列出所有数据库表",
        inputSchema={
            "type": "object",
            "properties": {
                "source": {
                    "type": "string",
                    "enum": ["database", "api", "auto"],
                    "description": "数据源类型",
                    "default": "auto",
                }
            },
        },
    ),
  • Server-level helper function that dispatches list_all_tables request to appropriate client (database or API) based on source parameter, prioritizing database for 'auto'.
    async def _list_all_tables(source: str) -> List[str]:
        """列出所有表的内部方法"""
        if source == "database" and db_client:
            return db_client.get_all_tables()
        elif source == "api" and api_client:
            return await api_client.get_all_tables()
        elif source == "auto":
            # 优先使用数据库直连
            if db_client:
                result = db_client.get_all_tables()
                if result:
                    return result
            if api_client:
                return await api_client.get_all_tables()
    
        return []
  • DatabaseClient.get_all_tables(): Core implementation for direct database connection using SQLAlchemy's metadata.reflect() to retrieve all table names.
    def get_all_tables(self) -> List[str]:
        """获取所有表名"""
        if not self.engine:
            return []
    
        try:
            metadata = MetaData()
            metadata.reflect(bind=self.engine)
            return list(metadata.tables.keys())
        except SQLAlchemyError as e:
            print(f"Error getting table list: {e}")
            return []
  • APIClient.get_all_tables(): Asynchronous HTTP client call to backend API endpoint /api/database/tables to fetch list of all table names.
    async def get_all_tables(self) -> List[str]:
        """通过 API 获取所有表名"""
        try:
            async with httpx.AsyncClient() as client:
                response = await client.get(
                    f"{self.base_url}/api/database/tables",
                    headers=self.headers,
                    timeout=30.0,
                )
    
                if response.status_code == 200:
                    data = response.json()
                    if isinstance(data, dict) and "tables" in data:
                        return data["tables"]
                    elif isinstance(data, list):
                        return data
                    else:
                        return []
                else:
                    print(
                        f"API request failed: {response.status_code} - {response.text}"
                    )
                    return []
    
        except httpx.RequestError as e:
            print(f"API request error: {e}")
            return []
Behavior2/5

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

No annotations are provided, so the description carries the full burden. It states the action ('列出所有' - list all) but doesn't disclose behavioral traits such as whether it's read-only, if it requires authentication, rate limits, or what the output format might be. For a tool with no annotations, this is a significant gap in transparency.

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, efficient sentence in Chinese ('列出所有数据库表'), which is appropriately sized and front-loaded with the core action. There's no wasted text, making it concise, though it could benefit from slight elaboration for better clarity.

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 no annotations and no output schema, the description is incomplete. It doesn't explain what 'all' entails (e.g., scope, pagination), behavioral aspects, or return values. For a tool that likely returns a list of tables, more context is needed to guide the agent effectively.

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?

The input schema has 100% description coverage, with one parameter 'source' fully documented in the schema (including enum values and default). The description adds no additional meaning beyond the schema, so it meets the baseline of 3 where the schema does the heavy lifting. No compensation is needed.

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 '列出所有数据库表' (List all database tables) clearly states the verb and resource, making the purpose understandable. However, it doesn't differentiate from sibling tools like 'search_tables' or 'get_table_info', which likely have overlapping functionality. The description is adequate but lacks specificity about scope or filtering.

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?

No guidance is provided on when to use this tool versus alternatives like 'search_tables' or 'get_table_info'. The description implies a comprehensive listing, but without explicit context or exclusions, the agent must infer usage. This leaves ambiguity in tool selection.

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/JJVvV/sp-enterprise-mcp'

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