Skip to main content
Glama
JJVvV

SP Database MCP Server

by JJVvV

get_table_info

Retrieve detailed database table structure information, including field definitions, types, and comments, using either low-code system schema queries or traditional database metadata methods.

Instructions

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

Input Schema

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

Implementation Reference

  • Handler logic within call_tool that processes the get_table_info tool call, retrieves table data from MOCK_TABLES, formats it, and returns the response.
    if name == "get_table_info": table_name = arguments.get("table_name") if not table_name: return [TextContent(type="text", text="错误:缺少表名参数")] if table_name in MOCK_TABLES: table_info = MOCK_TABLES[table_name] output = format_table_info(table_info) return [TextContent(type="text", text=output)] else: available_tables = ", ".join(MOCK_TABLES.keys()) return [TextContent(type="text", text=f"未找到表 '{table_name}'。可用的表有: {available_tables}")]
  • Input schema definition for the get_table_info tool, specifying the required 'table_name' parameter.
    inputSchema={ "type": "object", "properties": { "table_name": { "type": "string", "description": "要查询的表名,如:activity_node, scene_activity, da_asset_object" } }, "required": ["table_name"] }
  • Registration of the get_table_info tool in the list_tools handler, including name, description, and schema.
    name="get_table_info", description="获取指定数据库表的结构信息,包括字段定义、类型、注释等", inputSchema={ "type": "object", "properties": { "table_name": { "type": "string", "description": "要查询的表名,如:activity_node, scene_activity, da_asset_object" } }, "required": ["table_name"] } ),
  • Helper function to format the table information into a markdown table for the tool response.
    def format_table_info(table_info: Dict[str, Any]) -> str: """格式化表信息输出""" output = f"# {table_info['name']} 表结构信息\n\n" if table_info.get("comment"): output += f"**表说明**: {table_info['comment']}\n\n" output += "## 字段信息\n\n" output += "| 字段名 | 类型 | 可空 | 主键 | 说明 |\n" output += "|--------|------|------|------|------|\n" for column in table_info["columns"]: nullable = "是" if column.get("nullable", True) else "否" primary_key = "是" if column.get("is_primary_key", False) else "否" comment = column.get("comment", "-") output += f"| {column['name']} | {column['type']} | {nullable} | {primary_key} | {comment} |\n" return output

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

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