Skip to main content
Glama
JJVvV

SP Database MCP Server

by JJVvV

get_table_info

Retrieve database table structure information including field definitions, types, and comments. Supports both low-code system schema queries and traditional database metadata queries for comprehensive table analysis.

Instructions

获取指定数据库表的结构信息,包括字段定义、类型、注释等。支持两种查询方式:1) 低代码系统schema查询(通过da_logic_entity和da_entity_attribute表);2) 传统数据库元数据查询。优先使用低代码系统方式获取更详细的字段信息。

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
table_nameYes要查询的表名
sourceNo数据源类型:database(直连数据库)、api(通过API)、auto(自动选择)auto

Implementation Reference

  • MCP tool registration for 'get_table_info' with input schema defining table_name (required) and optional source.
    Tool(
        name="get_table_info",
        description="获取指定数据库表的结构信息,包括字段定义、类型、注释等。支持两种查询方式:1) 低代码系统schema查询(通过da_logic_entity和da_entity_attribute表);2) 传统数据库元数据查询。优先使用低代码系统方式获取更详细的字段信息。",
        inputSchema={
            "type": "object",
            "properties": {
                "table_name": {"type": "string", "description": "要查询的表名"},
                "source": {
                    "type": "string",
                    "enum": ["database", "api", "auto"],
                    "description": "数据源类型:database(直连数据库)、api(通过API)、auto(自动选择)",
                    "default": "auto",
                },
            },
            "required": ["table_name"],
        },
    ),
  • Primary MCP handler logic for get_table_info tool: extracts parameters, fetches table info via helper, formats and returns as TextContent.
    if name == "get_table_info":
        table_name = arguments.get("table_name")
        source = arguments.get("source", "auto")
    
        if not table_name:
            return [TextContent(type="text", text="错误:缺少表名参数")]
    
        table_info = await _get_table_info(table_name, source)
        if table_info:
            # 格式化输出
            output = _format_table_info(table_info)
            return [TextContent(type="text", text=output)]
        else:
            return [
                TextContent(type="text", text=f"未找到表 '{table_name}' 的信息")
            ]
  • Helper function dispatching get_table_info calls to DatabaseClient or APIClient based on source parameter, preferring database.
    async def _get_table_info(table_name: str, source: str) -> Optional[TableInfo]:
        """获取表信息的内部方法"""
        if source == "database" and db_client:
            return db_client.get_table_info(table_name)
        elif source == "api" and api_client:
            return await api_client.get_table_info(table_name)
        elif source == "auto":
            # 优先使用数据库直连,然后是 API
            if db_client:
                result = db_client.get_table_info(table_name)
                if result:
                    return result
            if api_client:
                return await api_client.get_table_info(table_name)
    
        return None
  • Core handler in DatabaseClient for get_table_info: prioritizes low-code schema query, falls back to database metadata.
    def get_table_info(self, table_name: str) -> Optional[TableInfo]:
        """获取指定表的结构信息"""
        if not self.engine:
            return None
    
        # 首先尝试通过低代码系统的 schema 表获取信息
        schema_info = self._get_table_info_from_schema(table_name)
        if schema_info:
            return schema_info
    
        # 如果低代码系统查询失败,回退到传统的数据库元数据查询
        return self._get_table_info_from_metadata(table_name)
  • Pydantic schema/model for TableInfo, defining the structure of table information returned by the tool.
    class TableInfo(BaseModel):
        """数据库表信息"""
    
        name: str
        comment: Optional[str] = None
        columns: List[ColumnInfo]
        indexes: List[Dict[str, Any]] = []
        foreign_keys: List[Dict[str, Any]] = []
Behavior4/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It successfully describes key behavioral traits: the tool retrieves (not modifies) information, supports two distinct query approaches with different characteristics, and has a preference hierarchy (优先使用低代码系统方式 - 'prefer using the low-code system approach'). It doesn't mention error conditions, performance characteristics, or authentication requirements, but provides substantial operational context beyond basic purpose.

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 efficiently structured in two sentences: the first states the core purpose and what information is retrieved, the second explains the two query approaches and their relative merits. Every phrase adds value, with no redundant information or unnecessary elaboration. The information is appropriately front-loaded with the main purpose first.

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

Completeness4/5

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

For a tool with 2 parameters, 100% schema coverage, no annotations, and no output schema, the description provides good contextual completeness. It explains the tool's purpose, what information it retrieves, and the operational approaches. The main gap is the lack of information about return format or output structure, which would be helpful given no output schema exists. However, it covers most other important aspects well.

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?

With 100% schema description coverage, the schema already documents both parameters thoroughly. The description adds some context by implying that 'table_name' is used for both query approaches and that 'source' parameter relates to the described data source types, but doesn't provide additional semantic meaning beyond what's in the schema descriptions. This meets the baseline for high schema coverage.

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?

The description clearly states the tool's purpose with specific verbs ('获取' meaning 'retrieve') and resources ('数据库表的结构信息' meaning 'database table structure information'), explicitly listing what information is included (字段定义、类型、注释 - field definitions, types, comments). It distinguishes from siblings by focusing on structural metadata rather than documentation (get_table_documentation), listing (list_all_tables), or searching (search_tables).

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

Usage Guidelines4/5

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

The description provides clear context about when to use this tool by explaining the two query approaches (low-code system schema vs traditional database metadata) and stating a preference for the low-code approach to get more detailed field information. However, it doesn't explicitly mention when NOT to use it or name specific alternatives among the sibling tools, which prevents a perfect score.

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