Skip to main content
Glama

summarize_all_communities

Generate summaries for academic communities in bulk or parallel processing. Specify community levels, control concurrency, and optionally target specific communities for automated literature review generation.

Instructions

批量/并行生成社区摘要

Args: level: 社区层级,"macro" 或 "micro"(或整数 1/2) concurrency: 并发数,默认 5 comm_ids: 指定社区 ID 列表 force: 是否强制重新生成

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
levelNo
concurrencyNo
comm_idsNo
forceNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Core implementation of the summarize_all_communities tool. Normalizes input level, queries target community IDs (filtering by level and whether already summarized unless force), limits concurrency with semaphore, processes each community by calling summarize_community_v1_run in parallel using asyncio.gather, and returns summary statistics.
    async def summarize_all_communities_run(
        level: str | int | None = None,
        concurrency: int = 5,
        comm_ids: list[int] | None = None,
        force: bool = False,
    ) -> dict[str, Any]:
        """批量/并行生成社区摘要 (Core Implementation)"""
        # Normalize level to string "macro" or "micro" to match DB column type (TEXT)
        level_str: str | None = None
        if level is not None:
            l_lower = str(level).lower()
            if l_lower in ["macro", "1"]:
                level_str = "macro"
            elif l_lower in ["micro", "2"]:
                level_str = "micro"
            else:
                level_str = l_lower
        
        # 1. 确定要处理的 communities
        if comm_ids:
            target_ids = comm_ids
        else:
            query = "SELECT comm_id FROM communities WHERE 1=1"
            params = []
            if level_str is not None:
                query += " AND level = %s"
                params.append(level_str)
            
            if not force:
                query += " AND NOT EXISTS (SELECT 1 FROM community_summaries s WHERE s.comm_id = communities.comm_id)"
                
            rows = query_all(query, tuple(params))
            target_ids = [r["comm_id"] for r in rows]
            
        if not target_ids:
            return {"message": "No communities to summarize", "count": 0}
            
        # 2. 并行执行
        sem = asyncio.Semaphore(concurrency)
        
        async def process_one(cid):
            async with sem:
                res = await summarize_community_v1_run(comm_id=cid)
                return {
                    "comm_id": cid, 
                    "success": not res.get("error"), 
                    "error": res.get("error")
                }
                
        tasks = [process_one(cid) for cid in target_ids]
        results = await asyncio.gather(*tasks)
        
        success_count = sum(1 for r in results if r["success"])
        failed_count = len(results) - success_count
        
        return {
            "total": len(target_ids),
            "success": success_count,
            "failed": failed_count,
            "details": results[:20]  # 返回前 20 个结果
        }
  • MCP tool registration via @mcp.tool() decorator. Defines the tool interface with type-hinted parameters and docstring, acting as a thin wrapper that delegates execution to summarize_all_communities_run.
    @mcp.tool()
    async def summarize_all_communities(
        level: str | None = None,
        concurrency: int = 5,
        comm_ids: list[int] | None = None,
        force: bool = False,
    ) -> dict[str, Any]:
        """批量/并行生成社区摘要
        
        Args:
            level: 社区层级,"macro" 或 "micro"(或整数 1/2)
            concurrency: 并发数,默认 5
            comm_ids: 指定社区 ID 列表
            force: 是否强制重新生成
        """
        return await summarize_all_communities_run(
            level=level,
            concurrency=concurrency,
            comm_ids=comm_ids,
            force=force
        )
  • Top-level registration call in the main MCP server setup that invokes the module's register function to add the summarize_all_communities tool (among others) to the FastMCP instance.
    register_graph_summarize_tools(mcp)
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 mentions 'batch/parallel' processing and 'force re-generation,' which hints at performance characteristics and idempotency, but doesn't describe what the tool actually does (e.g., what a 'community summary' contains, whether it's stored or returned, error handling, or side effects). For a tool with 4 parameters and batch operations, this is inadequate.

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

Conciseness3/5

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

The description is brief and structured with a purpose statement followed by an 'Args:' section. However, the 'Args:' formatting is somewhat informal for MCP, and the purpose statement could be more front-loaded with key details. It's concise but could be more polished for clarity.

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 4 parameters with 0% schema coverage, an output schema exists (which helps), but no annotations, the description partially compensates by explaining parameters. However, it fails to describe the tool's core behavior (what summaries are, how they're used), making it incomplete for a batch processing tool. The output schema mitigates some gaps, but overall context is lacking.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the description must compensate. It provides meaningful semantics for all 4 parameters: 'level' (community hierarchy with 'macro'/'micro' or 1/2), 'concurrency' (parallelism count with default 5), 'comm_ids' (specific community ID list), and 'force' (force re-generation). This adds crucial context beyond the bare schema types, though it lacks examples or constraints (e.g., valid ID ranges).

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: '批量/并行生成社区摘要' translates to 'batch/parallel generate community summaries.' This specifies the verb (generate summaries) and resource (communities), and distinguishes it from sibling 'summarize_community_v1' by indicating batch/parallel processing. However, it doesn't explicitly differentiate scope or granularity from the sibling beyond the 'all' in the name.

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 'summarize_community_v1' (which appears to summarize a single community). It mentions parameters like 'level' and 'comm_ids' but doesn't explain when batch summarization is preferred over individual summarization or what 'force' re-generation implies for usage decisions.

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