Skip to main content
Glama
JJVvV

SP Database MCP Server

by JJVvV

search_tables

Search database tables using keywords to locate relevant data within the SP Database MCP Server. Specify source type (database, API, or auto) to streamline queries for schema or metadata information.

Instructions

根据关键词搜索数据库表

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
keywordYes搜索关键词
sourceNo数据源类型auto

Implementation Reference

  • MCP tool handler for 'search_tables': extracts parameters, calls internal _search_tables, formats results as markdown list of matching tables.
    elif name == "search_tables": keyword = arguments.get("keyword") source = arguments.get("source", "auto") if not keyword: return [TextContent(type="text", text="错误:缺少搜索关键词")] tables = await _search_tables(keyword, source) if tables: output = f"找到 {len(tables)} 个匹配的表:\n\n" for table in tables: output += f"## {table.name}\n" if table.comment: output += f"**说明**: {table.comment}\n" output += f"**字段数**: {len(table.columns)}\n\n" return [TextContent(type="text", text=output)] else: return [ TextContent(type="text", text=f"未找到包含关键词 '{keyword}' 的表") ]
  • Registration of 'search_tables' tool in @server.list_tools(), including name, description, and input schema.
    name="search_tables", description="根据关键词搜索数据库表", inputSchema={ "type": "object", "properties": { "keyword": {"type": "string", "description": "搜索关键词"}, "source": { "type": "string", "enum": ["database", "api", "auto"], "description": "数据源类型", "default": "auto", }, }, "required": ["keyword"], }, ),
  • Helper function _search_tables that routes search request to appropriate client (db_client or api_client) based on source.
    async def _search_tables(keyword: str, source: str) -> List[TableInfo]: """搜索表的内部方法""" if source == "database" and db_client: return db_client.search_tables(keyword) elif source == "api" and api_client: return await api_client.search_tables(keyword) elif source == "auto": # 优先使用数据库直连 if db_client: result = db_client.search_tables(keyword) if result: return result if api_client: return await api_client.search_tables(keyword) return []
  • Core DatabaseClient.search_tables method: filters table names by keyword, retrieves full TableInfo for matches.
    def search_tables(self, keyword: str) -> List[TableInfo]: """根据关键词搜索表""" all_tables = self.get_all_tables() matching_tables = [ table for table in all_tables if keyword.lower() in table.lower() ] result = [] for table_name in matching_tables: table_info = self.get_table_info(table_name) if table_info: result.append(table_info) return result

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