Skip to main content
Glama
JJVvV

SP Database MCP Server

by JJVvV

search_tables

Search database tables using keywords to find schema information and metadata across multiple data sources.

Instructions

根据关键词搜索数据库表

Input Schema

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

Implementation Reference

  • Defines the Tool schema for 'search_tables', including input parameters: keyword (required) and source (optional: database, api, auto).
    Tool( name="search_tables", description="根据关键词搜索数据库表", inputSchema={ "type": "object", "properties": { "keyword": {"type": "string", "description": "搜索关键词"}, "source": { "type": "string", "enum": ["database", "api", "auto"], "description": "数据源类型", "default": "auto", }, }, "required": ["keyword"], }, ),
  • MCP tool handler for 'search_tables': validates input, calls _search_tables, formats results as Markdown list of matching tables with names, comments, and column counts.
    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}' 的表") ]
  • Helper function that routes search_tables call to DatabaseClient or APIClient based on source parameter, preferring database for 'auto'.
    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 implementation of table search in DatabaseClient: lists all tables, filters by keyword in table name (case-insensitive), 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

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