Skip to main content
Glama
chrismannina

PubMed MCP Server

by chrismannina

analyze_research_trends

Analyze publication trends for research topics over time to identify patterns and growth in scientific literature.

Instructions

Analyze publication trends for a research topic over time

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
topicYesResearch topic to analyze
years_backNoNumber of years to analyze
include_subtopicsNoInclude analysis of related subtopics

Implementation Reference

  • Main handler function that performs yearly PubMed searches for the given topic over the specified number of years, calculates publication counts, growth rates, and formats a trend analysis response including recent notable articles.
    async def _handle_analyze_research_trends(self, arguments: Dict[str, Any]) -> MCPResponse:
        """Handle research trend analysis."""
        try:
            topic = arguments.get("topic", "")
            if not topic:
                return MCPResponse(
                    content=[{"type": "text", "text": "Topic is required"}], is_error=True
                )
    
            years_back = arguments.get("years_back", 5)
            # include_subtopics parameter is available but not currently used
            # include_subtopics = arguments.get("include_subtopics", False)
    
            # Analyze trends year by year
            current_year = datetime.now().year
            yearly_data = []
    
            for year in range(current_year - years_back, current_year + 1):
                search_result = await self.pubmed_client.search_articles(
                    query=topic,
                    max_results=200,  # Get more results for trend analysis
                    date_from=f"{year}/01/01",
                    date_to=f"{year}/12/31",
                    cache=self.cache,
                )
                yearly_data.append(
                    {
                        "year": year,
                        "count": search_result.total_results,
                        "articles": search_result.articles[:5],  # Top 5 articles
                    }
                )
    
            content = []
            content.append(
                {
                    "type": "text",
                    "text": f"**Research Trends for: {topic}**\n\n"
                    f"Analysis Period: {current_year - years_back} - {current_year}\n",
                }
            )
    
            # Show yearly trends
            trend_text = "**Publication Counts by Year:**\n"
            for data in yearly_data:
                trend_text += f"{data['year']}: {data['count']:,} articles\n"
    
            content.append({"type": "text", "text": trend_text})
    
            # Calculate growth
            if len(yearly_data) >= 2:
                recent_avg = sum([d["count"] for d in yearly_data[-2:]]) / 2
                early_avg = sum([d["count"] for d in yearly_data[:2]]) / 2
                growth_rate = ((recent_avg - early_avg) / early_avg * 100) if early_avg > 0 else 0
    
                content.append(
                    {
                        "type": "text",
                        "text": f"\n**Growth Analysis:**\n"
                        f"Recent average: {recent_avg:.0f} articles/year\n"
                        f"Early average: {early_avg:.0f} articles/year\n"
                        f"Growth rate: {growth_rate:+.1f}%\n",
                    }
                )
    
            # Show recent notable articles
            recent_articles = yearly_data[-1]["articles"] if yearly_data else []
            if recent_articles:
                content.append(
                    {"type": "text", "text": f"\n**Recent Notable Articles ({current_year}):**\n"}
                )
    
                for i, article_data in enumerate(recent_articles[:3], 1):
                    article_text = self._format_article_summary(article_data, i)
                    content.append({"type": "text", "text": article_text})
    
            return MCPResponse(content=content)
    
        except Exception as e:
            logger.error(f"Error in analyze_research_trends: {e}")
            return MCPResponse(
                content=[{"type": "text", "text": f"Error: {str(e)}"}], is_error=True
            )
  • JSON schema defining the input parameters for the analyze_research_trends tool, including required 'topic' and optional 'years_back' and 'include_subtopics'.
    {
        "name": "analyze_research_trends",
        "description": ("Analyze publication trends for a research topic over time"),
        "inputSchema": {
            "type": "object",
            "properties": {
                "topic": {"type": "string", "description": "Research topic to analyze"},
                "years_back": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 20,
                    "default": 5,
                    "description": "Number of years to analyze",
                },
                "include_subtopics": {
                    "type": "boolean",
                    "default": False,
                    "description": "Include analysis of related subtopics",
                },
            },
            "required": ["topic"],
        },
    },
  • Tool registration mapping in handle_tool_call method, associating the 'analyze_research_trends' tool name with its handler _handle_analyze_research_trends.
    handler_map = {
        "search_pubmed": self._handle_search_pubmed,
        "get_article_details": self._handle_get_article_details,
        "search_by_author": self._handle_search_by_author,
        "find_related_articles": self._handle_find_related_articles,
        "export_citations": self._handle_export_citations,
        "search_mesh_terms": self._handle_search_mesh_terms,
        "search_by_journal": self._handle_search_by_journal,
        "get_trending_topics": self._handle_get_trending_topics,
        "analyze_research_trends": self._handle_analyze_research_trends,
        "compare_articles": self._handle_compare_articles,
        "get_journal_metrics": self._handle_get_journal_metrics,
        "advanced_search": self._handle_advanced_search,
    }
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure but offers minimal information. It mentions analyzing trends over time but doesn't describe what the analysis includes (e.g., publication counts, citation trends, visualizations), how results are returned, data sources, rate limits, or authentication requirements. For a tool with 3 parameters and no output schema, 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.

Conciseness5/5

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

The description is extremely concise at just one sentence with zero wasted words. It front-loads the core functionality and uses efficient language. Every word earns its place by communicating the essential purpose without unnecessary elaboration.

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

Completeness2/5

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

Given the tool's complexity (analyzing trends over time with subtopic options), lack of annotations, and absence of an output schema, the description is insufficiently complete. It doesn't explain what kind of analysis is performed, what format results take, data sources, limitations, or how this differs from similar tools. The single sentence leaves too many operational questions unanswered.

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 100%, so the schema already fully documents all three parameters. The description adds no additional parameter semantics beyond what's in the schema - it doesn't explain how 'topic' should be formatted, what constitutes 'related subtopics', or how the time range affects analysis. The baseline score of 3 reflects adequate but unenhanced parameter documentation.

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 as analyzing publication trends for a research topic over time, specifying both the action (analyze) and resource (publication trends). It distinguishes from siblings like 'get_trending_topics' (which likely shows current trends) and 'compare_articles' (which compares specific articles), but doesn't explicitly differentiate from all alternatives.

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. It doesn't mention when this analysis tool is preferable to 'get_trending_topics' for trend discovery or 'advanced_search' for detailed filtering. There's no context about prerequisites, limitations, or appropriate use cases beyond the basic functionality.

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/chrismannina/pubmed-mcp'

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