Skip to main content
Glama
JJVvV

SP Database MCP Server

by JJVvV

list_all_tables

Retrieve a comprehensive list of all database tables using SP Database MCP Server. Specify data source (database, API, or auto) to view schema information for efficient system querying.

Instructions

列出所有数据库表

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sourceNo数据源类型auto

Implementation Reference

  • Registration of the list_all_tables tool with input schema definition.
    Tool( name="list_all_tables", description="列出所有数据库表", inputSchema={ "type": "object", "properties": { "source": { "type": "string", "enum": ["database", "api", "auto"], "description": "数据源类型", "default": "auto", } }, }, ),
  • Specific handler branch in @server.call_tool() that extracts parameters, calls _list_all_tables, and formats the list of tables as markdown output.
    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="未找到任何表")]
  • Core internal handler function that routes the request to the appropriate data source client (database or API) based on the 'source' parameter.
    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() method: Uses SQLAlchemy MetaData.reflect() to introspect and return all table names from the database.
    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 []

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