Skip to main content
Glama

collect_evidence

Search academic literature for evidence on a specific topic, optionally focusing on particular sections like methodology or findings, to support research and analysis.

Instructions

收集特定主题的文献证据

搜索与主题相关的文献片段,可选择聚焦于特定章节类型。

Args: topic: 搜索主题 section_focus: 聚焦的章节类型(如 "methodology", "findings") k: 返回结果数量

Returns: 按文献聚合的证据列表

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
topicYes
section_focusNo
kNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The core handler implementation for the 'collect_evidence' tool. It adjusts the query based on optional section_focus, performs a hybrid search using hybrid_search, aggregates evidence chunks by document with metadata, sorts by evidence count per doc, and returns a structured dictionary.
    @mcp.tool()
    async def collect_evidence(
        topic: str,
        section_focus: str | None = None,
        k: int = 20,
    ) -> dict[str, Any]:
        """收集特定主题的文献证据
        
        搜索与主题相关的文献片段,可选择聚焦于特定章节类型。
        
        Args:
            topic: 搜索主题
            section_focus: 聚焦的章节类型(如 "methodology", "findings")
            k: 返回结果数量
            
        Returns:
            按文献聚合的证据列表
        """
        try:
            # 如果有章节聚焦,调整查询
            query = topic
            if section_focus:
                focus_keywords = {
                    "methodology": "method approach model estimation identification",
                    "findings": "result finding evidence show demonstrate",
                    "theory": "theory framework hypothesis prediction",
                    "data": "data sample variable measure",
                }
                if section_focus in focus_keywords:
                    query = f"{topic} {focus_keywords[section_focus]}"
            
            # 搜索
            search_result = await hybrid_search(query, k=k, alpha=0.6, per_doc_limit=5)
            
            # 按文档聚合
            evidence_by_doc: dict[str, dict] = {}
            
            for result in search_result.results:
                doc_id = result.doc_id
                
                if doc_id not in evidence_by_doc:
                    # 获取文档信息
                    doc = query_one(
                        "SELECT title, authors, year FROM documents WHERE doc_id = %s",
                        (doc_id,)
                    )
                    evidence_by_doc[doc_id] = {
                        "doc_id": doc_id,
                        "title": doc["title"] if doc else "Unknown",
                        "authors": doc["authors"] if doc else "Unknown",
                        "year": doc["year"] if doc else None,
                        "evidence": [],
                    }
                
                evidence_by_doc[doc_id]["evidence"].append({
                    "chunk_id": result.chunk_id,
                    "page_start": result.page_start,
                    "page_end": result.page_end,
                    "text": result.snippet,
                    "relevance_score": result.score_total,
                })
            
            # 按证据数量排序
            sorted_evidence = sorted(
                evidence_by_doc.values(),
                key=lambda x: len(x["evidence"]),
                reverse=True
            )
            
            return {
                "topic": topic,
                "section_focus": section_focus,
                "total_chunks": len(search_result.results),
                "unique_documents": len(sorted_evidence),
                "evidence": sorted_evidence,
            }
            
        except Exception as e:
            return {
                "error": str(e),
                "topic": topic,
                "evidence": [],
            }
  • Registers the writing tools module (including collect_evidence) by calling register_writing_tools on the FastMCP instance in the main server file.
    register_writing_tools(mcp)
  • The @mcp.tool() decorator directly registers the collect_evidence function as an MCP tool within the register_writing_tools function.
    @mcp.tool()
Behavior2/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 states the tool searches and returns evidence aggregated by literature, but doesn't describe important behavioral aspects: what sources are searched, whether this is a read-only operation, performance characteristics, error conditions, authentication requirements, or rate limits. For a search tool with no annotation coverage, this leaves significant gaps in understanding how the tool behaves.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is appropriately concise with clear structure: purpose statement followed by Args and Returns sections. Each sentence earns its place, though the purpose statement could be slightly more specific. The information is front-loaded with the core functionality stated first.

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

Completeness3/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) but no annotations and 0% schema description coverage, the description is moderately complete. It covers the basic purpose and parameters but lacks behavioral context, usage guidelines, and detailed parameter constraints. For a search tool with 3 parameters in a server with multiple search alternatives, more contextual information would be helpful.

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?

The description provides basic semantic information for all three parameters (topic, section_focus, k) in the Args section, explaining what each parameter represents. However, with 0% schema description coverage, the schema provides no additional documentation. The description compensates somewhat by explaining parameter purposes but doesn't provide format details, constraints, or examples (e.g., what values section_focus accepts beyond 'methodology' and 'findings' examples).

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: '收集特定主题的文献证据' (collect literature evidence on a specific topic) and specifies it searches for literature fragments related to the topic with optional section focus. It uses specific verbs (收集, 搜索) and identifies the resource (文献证据). However, it doesn't explicitly distinguish this tool from sibling tools like 'search_fts_only', 'search_hybrid', or 'search_vector_only' which appear to be related search tools.

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. While it mentions optional section focus, it doesn't explain when to use section_focus versus not, nor does it reference any of the sibling search tools (search_fts_only, search_hybrid, search_vector_only) that might serve similar purposes. There's no context about prerequisites, limitations, or typical use cases.

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