Skip to main content
Glama
emi-dm

ArxivSearcher MCP Server

by emi-dm

analyze_paper_trends

Analyze trends in academic papers to identify patterns in authors, keywords, timeline, or categories for research insights.

Instructions

Analyze trends in a collection of papers.

:param papers: List of papers from search_papers results :param analysis_type: Type of analysis ('authors', 'keywords', 'timeline', 'categories')

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
papersYes
analysis_typeNoauthors

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The primary synchronous handler implementation for the analyze_paper_trends MCP tool. It performs various trend analyses (authors, timeline, categories, keywords) on a list of papers using Counter for counting and TF-IDF for keywords.
    @mcp.tool
    def analyze_paper_trends(
        papers: List[Dict[str, Any]], analysis_type: str = "authors"
    ) -> dict:
        """
        Analyze trends in a collection of papers.
    
        :param papers: List of papers from search_papers results
        :param analysis_type: Type of analysis ('authors', 'keywords', 'timeline', 'categories')
        """
        if not papers or "results" not in papers:
            if isinstance(papers, list):
                results = papers
            else:
                return {
                    "error": "Invalid papers format. Expected list or dict with 'results' key."
                }
        else:
            results = papers["results"]
    
        if not results:
            return {"error": "No papers to analyze"}
    
        analysis = {}
    
        if analysis_type == "authors":
            author_counts = Counter()
            for paper in results:
                for author in paper.get("authors", []):
                    author_counts[author] += 1
    
            analysis = {
                "type": "authors",
                "total_unique_authors": len(author_counts),
                "most_prolific_authors": author_counts.most_common(10),
                "collaboration_stats": {
                    "avg_authors_per_paper": sum(len(p.get("authors", [])) for p in results)
                    / len(results),
                    "single_author_papers": sum(
                        1 for p in results if len(p.get("authors", [])) == 1
                    ),
                    "multi_author_papers": sum(
                        1 for p in results if len(p.get("authors", [])) > 1
                    ),
                },
            }
    
        elif analysis_type == "timeline":
            date_counts = Counter()
            for paper in results:
                date = paper.get("published_date", "")
                if date:
                    year = date.split("-")[0]
                    date_counts[year] += 1
    
            analysis = {
                "type": "timeline",
                "papers_by_year": dict(sorted(date_counts.items())),
                "most_active_year": date_counts.most_common(1)[0] if date_counts else None,
                "total_years_span": len(date_counts),
            }
    
        elif analysis_type == "categories":
            category_counts = Counter()
            for paper in results:
                categories = paper.get("categories", [])
                for cat in categories:
                    category_counts[cat] += 1
    
            analysis = {
                "type": "categories",
                "total_categories": len(category_counts),
                "most_common_categories": category_counts.most_common(10),
                "category_distribution": dict(category_counts),
            }
    
        elif analysis_type == "keywords":
            # Extract keywords from titles and abstracts
            text_content = []
            for paper in results:
                title = paper.get("title", "")
                summary = paper.get("summary", "")
                text_content.append(f"{title} {summary}")
    
            if text_content:
                try:
                    # Use TF-IDF to find important terms
                    vectorizer = TfidfVectorizer(
                        max_features=50, stop_words="english", ngram_range=(1, 2), min_df=2
                    )
                    tfidf_matrix = vectorizer.fit_transform(text_content)
                    feature_names = vectorizer.get_feature_names_out()
                    scores = tfidf_matrix.sum(axis=0).A1
    
                    keyword_scores = list(zip(feature_names, scores))
                    keyword_scores.sort(key=lambda x: x[1], reverse=True)
    
                    analysis = {
                        "type": "keywords",
                        "top_keywords": keyword_scores[:20],
                        "total_unique_terms": len(feature_names),
                    }
                except Exception as e:
                    analysis = {
                        "type": "keywords",
                        "error": f"Could not perform keyword analysis: {str(e)}",
                        "fallback_word_count": Counter(),
                    }
    
        analysis["total_papers_analyzed"] = len(results)
        return analysis
  • The asynchronous version of the analyze_paper_trends handler for remote deployment, identical logic to the primary handler.
    @mcp.tool
    async def analyze_paper_trends(
        papers: List[Dict[str, Any]], analysis_type: str = "authors"
    ) -> dict:
        """
        Analyze trends in a collection of papers.
    
        :param papers: List of papers from search_papers results
        :param analysis_type: Type of analysis ('authors', 'keywords', 'timeline', 'categories')
        """
        if not papers or "results" not in papers:
            if isinstance(papers, list):
                results = papers
            else:
                return {
                    "error": "Invalid papers format. Expected list or dict with 'results' key."
                }
        else:
            results = papers["results"]
    
        if not results:
            return {"error": "No papers to analyze"}
    
        analysis = {}
    
        if analysis_type == "authors":
            author_counts = Counter()
            for paper in results:
                for author in paper.get("authors", []):
                    author_counts[author] += 1
    
            analysis = {
                "type": "authors",
                "total_unique_authors": len(author_counts),
                "most_prolific_authors": author_counts.most_common(10),
                "collaboration_stats": {
                    "avg_authors_per_paper": sum(len(p.get("authors", [])) for p in results)
                    / len(results),
                    "single_author_papers": sum(
                        1 for p in results if len(p.get("authors", [])) == 1
                    ),
                    "multi_author_papers": sum(
                        1 for p in results if len(p.get("authors", [])) > 1
                    ),
                },
            }
    
        elif analysis_type == "timeline":
            date_counts = Counter()
            for paper in results:
                date = paper.get("published_date", "")
                if date:
                    year = date.split("-")[0]
                    date_counts[year] += 1
    
            analysis = {
                "type": "timeline",
                "papers_by_year": dict(sorted(date_counts.items())),
                "most_active_year": date_counts.most_common(1)[0] if date_counts else None,
                "total_years_span": len(date_counts),
            }
    
        elif analysis_type == "categories":
            category_counts = Counter()
            for paper in results:
                categories = paper.get("categories", [])
                for cat in categories:
                    category_counts[cat] += 1
    
            analysis = {
                "type": "categories",
                "total_categories": len(category_counts),
                "most_common_categories": category_counts.most_common(10),
                "category_distribution": dict(category_counts),
            }
    
        elif analysis_type == "keywords":
            # Extract keywords from titles and abstracts
            text_content = []
            for paper in results:
                title = paper.get("title", "")
                summary = paper.get("summary", "")
                text_content.append(f"{title} {summary}")
    
            if text_content:
                try:
                    # Use TF-IDF to find important terms
                    vectorizer = TfidfVectorizer(
                        max_features=50, stop_words="english", ngram_range=(1, 2), min_df=2
                    )
                    tfidf_matrix = vectorizer.fit_transform(text_content)
                    feature_names = vectorizer.get_feature_names_out()
                    scores = tfidf_matrix.sum(axis=0).A1
    
                    keyword_scores = list(zip(feature_names, scores))
                    keyword_scores.sort(key=lambda x: x[1], reverse=True)
    
                    analysis = {
                        "type": "keywords",
                        "top_keywords": keyword_scores[:20],
                        "total_unique_terms": len(feature_names),
                    }
                except Exception as e:
                    analysis = {
                        "type": "keywords",
                        "error": f"Could not perform keyword analysis: {str(e)}",
                        "fallback_word_count": Counter(),
                    }
    
        analysis["total_papers_analyzed"] = len(results)
        return analysis
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 the tool analyzes trends but doesn't describe what the analysis entails, how results are returned, or any constraints like processing limits. This is inadequate for a tool with an output schema, as it leaves key behaviors unspecified.

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 sized and front-loaded, with the main purpose stated first followed by parameter details. Each sentence adds value, such as specifying the source for 'papers' and the analysis options. It avoids redundancy and is efficiently structured, though it could be slightly more polished in formatting.

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, the description doesn't need to explain return values, but it lacks details on behavioral aspects like analysis depth or limitations. With no annotations and low schema coverage, it partially compensates with parameter semantics but falls short in providing a complete operational context, making it minimally adequate.

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?

The description adds significant meaning beyond the input schema, which has 0% description coverage. It explains that 'papers' should be a 'List of papers from search_papers results' and lists the possible values for 'analysis_type' ('authors', 'keywords', 'timeline', 'categories'), clarifying their semantics. This compensates well for the schema's lack of documentation.

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

Purpose3/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description states the tool 'Analyze trends in a collection of papers,' which provides a clear verb ('analyze') and resource ('collection of papers'), but it's vague about what 'trends' specifically means. It doesn't differentiate from siblings like 'search_papers' or 'find_related_papers,' which also involve paper analysis, leaving the purpose somewhat ambiguous.

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 offers no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites, such as needing papers from 'search_papers' results, or compare to siblings like 'export_search_results' or 'search_by_author' for different analysis needs. This lack of context makes it hard for an agent to choose appropriately.

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/emi-dm/Arxiv-MCP'

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