Skip to main content
Glama

search_fts_only

Search academic papers using PostgreSQL full-text search for precise keyword matching with Boolean operators.

Instructions

纯全文搜索

仅使用 PostgreSQL 全文搜索,适合精确关键词匹配的场景。

Args: query: 搜索查询字符串(支持布尔运算符) k: 返回结果数量,默认 10

Returns: 搜索结果列表

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYes
kNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The handler function for 'search_fts_only' tool. It performs pure full-text search using PostgreSQL FTS, formats results, and handles errors. Registered via @mcp.tool() decorator.
    def search_fts_only(
        query: str,
        k: int = 10,
    ) -> dict[str, Any]:
        """纯全文搜索
        
        仅使用 PostgreSQL 全文搜索,适合精确关键词匹配的场景。
        
        Args:
            query: 搜索查询字符串(支持布尔运算符)
            k: 返回结果数量,默认 10
            
        Returns:
            搜索结果列表
        """
        try:
            results = search_fts(query, k)
            
            formatted_results = []
            for r in results:
                text = r["text"]
                snippet = text[:200] + "..." if len(text) > 200 else text
                formatted_results.append({
                    "chunk_id": r["chunk_id"],
                    "doc_id": r["doc_id"],
                    "page_start": r["page_start"],
                    "page_end": r["page_end"],
                    "snippet": snippet,
                    "rank": r["rank"],
                })
            
            return {
                "query": query,
                "k": k,
                "results": formatted_results,
            }
        except Exception as e:
            return {
                "error": str(e),
                "query": query,
                "k": k,
                "results": [],
            }
  • Helper function 'search_fts' that executes the raw SQL query for full-text search, called by the search_fts_only handler.
    def search_fts(query: str, limit: int = 50) -> list[dict[str, Any]]:
        """全文搜索
        
        Args:
            query: 搜索查询
            limit: 返回结果数量
            
        Returns:
            搜索结果列表,包含 chunk_id, doc_id, page_start, page_end, text, rank
        """
        sql = """
        SELECT 
            c.chunk_id,
            c.doc_id,
            c.page_start,
            c.page_end,
            c.text,
            ts_rank(c.tsv, websearch_to_tsquery('english', %s)) as rank
        FROM chunks c
        WHERE c.tsv @@ websearch_to_tsquery('english', %s)
        ORDER BY rank DESC
        LIMIT %s
        """
        return query_all(sql, (query, query, limit))
  • Call to register_search_tools(mcp) which defines and registers the search_fts_only tool among others in the main MCP server.
    register_search_tools(mcp)
Behavior3/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions the search method (PostgreSQL full-text search) and that it returns a results list, which is helpful. However, it doesn't disclose important behavioral traits like whether this is a read-only operation, performance characteristics, error conditions, or authentication requirements. The description adds some value but leaves significant gaps.

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 efficiently structured with a clear purpose statement, usage context, and parameter documentation in separate sections. Every sentence earns its place, with no redundant information. The bilingual presentation (Chinese purpose/context, English parameter labels) is compact and functional.

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

Completeness4/5

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

Given the tool has an output schema (which handles return value documentation) and only 2 parameters, the description provides adequate context. It covers the purpose, usage scenario, and parameter semantics reasonably well. For a search tool with output schema support, this description is mostly complete, though it could benefit from more behavioral transparency.

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 0%, so the schema provides no parameter documentation. The description adds meaningful semantics for both parameters: 'query' is explained as a search query string supporting Boolean operators, and 'k' as the number of results to return with a default of 10. This compensates somewhat for the schema gap, but doesn't provide exhaustive details about query syntax or k constraints.

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 performs '纯全文搜索' (pure full-text search) using PostgreSQL full-text search, which is a specific verb+resource combination. It distinguishes itself from sibling tools like 'search_hybrid' and 'search_vector_only' by specifying it's for exact keyword matching scenarios. However, it doesn't explicitly name these siblings for comparison.

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

Usage Guidelines4/5

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

The description provides clear context about when to use this tool: '适合精确关键词匹配的场景' (suitable for exact keyword matching scenarios). This implicitly suggests when not to use it (non-exact keyword scenarios) and hints at alternatives like vector-based search. However, it doesn't explicitly name alternative tools or provide explicit exclusion criteria.

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/h-lu/paperlib-mcp'

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