Skip to main content
Glama
zouxy111

literature-agent-mcp

by zouxy111

search_and_merge

Execute multi-source literature searches and merge results using predefined query plans to consolidate biomedical research findings.

Instructions

Run multi-source search and merge using the existing query plan.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
task_idYes
per_queryNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The search_and_merge tool handler function. Takes task_id and per_query parameters, runs the backend CLI command 'step2-search-and-merge', and returns search results including paths to master_results.jsonl, screening_table.csv, and source statistics.
    @mcp.tool
    def search_and_merge(task_id: str, per_query: int = 30) -> dict[str, Any]:
        """Run multi-source search and merge using the existing query plan."""
        root = task_root(task_id)
        plan_path = root / "query_plan.json"
        out_dir = root / "search"
        result = ensure_success(
            run_backend(
                [
                    "step2-search-and-merge",
                    "--plan",
                    str(plan_path),
                    "--out",
                    str(out_dir),
                    "--per-query",
                    str(per_query),
                ]
            )
        )
        stats_path = out_dir / "source_stats.json"
        stats = json.loads(stats_path.read_text()) if stats_path.exists() else {}
        return {
            **result,
            "task_id": task_id,
            "search_dir": str(out_dir),
            "master_results_path": str(out_dir / "master_results.jsonl"),
            "screening_table_csv": str(out_dir / "screening_table.csv"),
            "screening_table_xlsx": str(out_dir / "screening_table.xlsx"),
            "oa_candidates_path": str(out_dir / "oa_candidates.jsonl"),
            "source_stats": stats,
        }
  • FastMCP tool registration decorator. The @mcp.tool decorator registers search_and_merge as an MCP tool, making it available to the MCP server.
    @mcp.tool
  • Helper functions that support search_and_merge execution. run_backend() executes CLI commands in the literature-agent environment, ensure_success() validates command exit codes, and task_root() resolves task directories.
    def run_backend(args: list[str]) -> dict[str, Any]:
        root = literature_agent_root()
        if not root.exists():
            raise FileNotFoundError(f"literature-agent root not found: {root}")
        cmd = [backend_python(root), "-m", "litagent.cli", *args]
        proc = subprocess.run(
            cmd,
            cwd=root,
            capture_output=True,
            text=True,
            check=False,
        )
        return {
            "cwd": str(root),
            "command": cmd,
            "returncode": proc.returncode,
            "stdout": proc.stdout,
            "stderr": proc.stderr,
        }
    
    
    def task_root(task_id: str) -> Path:
        return literature_agent_root() / "work" / task_id
    
    
    def ensure_success(result: dict[str, Any]) -> dict[str, Any]:
        if result["returncode"] != 0:
            raise RuntimeError(
                f"backend command failed ({result['returncode']}):\nSTDOUT:\n{result['stdout']}\nSTDERR:\n{result['stderr']}"
            )
        return result
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It fails to explain what 'merge' means (deduplication, concatenation, ranking), whether the operation is idempotent, or what side effects occur. Only the basic action type is conveyed.

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 single sentence is front-loaded and efficient, with no redundant words. However, given the lack of annotations and schema descriptions, the description may be overly terse rather than appropriately sized for the information deficit.

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?

While the core purpose is stated and an output schema exists (reducing the need for return value description), the description inadequately covers the two parameters given 0% schema coverage. It meets minimum viability but leaves significant gaps in operational context.

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?

With 0% schema description coverage, the description partially compensates by implying 'task_id' references the 'existing query plan'. However, 'per_query' is completely undocumented, and the description does not specify data types, constraints, or defaults beyond what the schema structurally implies.

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 uses specific verbs ('Run', 'search', 'merge') and identifies the resource ('multi-source', 'query plan'). It implicitly distinguishes from sibling 'plan_query' by specifying 'existing query plan' versus creating one, though it could be more explicit about what 'merge' entails.

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

Usage Guidelines3/5

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

The phrase 'using the existing query plan' implies a workflow sequence (use after creating a plan) but does not explicitly state prerequisites, alternatives, or when NOT to use the tool. The agent must infer the dependency on 'plan_query'.

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/zouxy111/mcp'

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