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
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure but only states the basic action. It doesn't mention whether this is a read-only operation, what permissions might be required, how results are returned (format, pagination), or any rate limits. The description is minimal and lacks important behavioral context.

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 extremely concise - a single sentence that directly states the tool's purpose without any wasted words. It's appropriately sized for a simple search tool and front-loaded with the core functionality.

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

Completeness2/5

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

For a search tool with no annotations and no output schema, the description is insufficient. It doesn't explain what constitutes a 'match' (partial/full text?), what fields are searched, the format of returned results, or error conditions. Given the complexity of search operations and lack of structured metadata, more context is needed.

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?

Schema description coverage is 100%, so the schema already documents both parameters thoroughly. The description adds no additional meaning about parameters beyond what's in the schema (keyword for search, source with enum values). Baseline 3 is appropriate when the schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/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 as 'search database tables by keyword' (根据关键词搜索数据库表), which is a specific verb+resource combination. However, it doesn't distinguish this from sibling tools like 'list_all_tables' or 'get_table_info', which might also involve table retrieval but with different approaches.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives like 'list_all_tables' or 'get_table_info'. It doesn't mention any prerequisites, exclusions, or comparative contexts that would help an agent choose between these sibling tools.

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