Skip to main content
Glama
biocontext-ai

BioContextAI Knowledgebase MCP

Official

bc_get_europepmc_articles

Search biomedical literature in Europe PMC by query, title, abstract, or author using logical operators to find relevant scientific articles with metadata.

Instructions

Search Europe PMC articles by query, title, abstract, or author. Combine search terms with 'and'/'or' logic.

Returns: dict: Search results with resultList containing articles (title, authors, abstract, journal, PMC/DOI IDs) or error message.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryNoGeneral search query
titleNoSearch in article titles
abstractNoSearch in abstracts
authorNoAuthor name (e.g., 'lastname,firstname')
search_typeNo'and' or 'or' (default: 'or')or
sort_byNo'recent' or 'cited' (default: none)
page_sizeNoResults per page (1-1000)

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The main handler function that implements the logic to search and retrieve articles from Europe PMC using their REST API. Decorated with @core_mcp.tool() to register it as an MCP tool named 'get_europepmc_articles'.
    @core_mcp.tool()
    def get_europepmc_articles(
        query: Annotated[Optional[str], Field(description="General search query")] = None,
        title: Annotated[Optional[str], Field(description="Search in article titles")] = None,
        abstract: Annotated[Optional[str], Field(description="Search in abstracts")] = None,
        author: Annotated[Optional[str], Field(description="Author name (e.g., 'lastname,firstname')")] = None,
        search_type: Annotated[str, Field(description="'and' or 'or' (default: 'or')")] = "or",
        sort_by: Annotated[
            Optional[str],
            Field(description="'recent' or 'cited' (default: none)"),
        ] = None,
        page_size: Annotated[int, Field(description="Results per page (1-1000)", ge=1, le=1000)] = 25,
    ) -> dict:
        """Search Europe PMC articles by query, title, abstract, or author. Combine search terms with 'and'/'or' logic.
    
        Returns:
            dict: Search results with resultList containing articles (title, authors, abstract, journal, PMC/DOI IDs) or error message.
        """
        # Ensure at least one search parameter was provided
        if not any([query, title, abstract, author]):
            return {"error": "At least one of query, title, abstract, or author must be provided"}
    
        # Build query components
        query_parts = []
    
        if query:
            query_parts.append(query)
    
        if title:
            query_parts.append(f"title:{title}")
    
        if abstract:
            query_parts.append(f"abstract:{abstract}")
    
        if author:
            query_parts.append(f"auth:{author}")
    
        # Join query parts based on search type
        query = " AND ".join(query_parts) if search_type.lower() == "and" else " OR ".join(query_parts)
    
        # If multiple parts and not explicitly AND, wrap in parentheses for OR
        if len(query_parts) > 1 and search_type.lower() == "or":
            query = f"({query})"
    
        # Add sort parameter
        if sort_by is not None:
            if sort_by.lower() == "cited":
                query += " sort_cited:y"
            else:  # default to recent
                query += " sort_date:y"
    
        # URL encode the query
        encoded_query = quote(query)
    
        url = f"https://www.ebi.ac.uk/europepmc/webservices/rest/search?query={encoded_query}&format=json&resultType=core&pageSize={page_size}"
    
        try:
            response = requests.get(url)
            response.raise_for_status()
            return response.json()
        except requests.exceptions.RequestException as e:
            return {"error": f"Failed to fetch Europe PMC articles: {e!s}"}
  • Registers the core_mcp server (containing the get_europepmc_articles tool) into the main MCP app with a prefix 'bc' (slugify('BC')), making the tool available as 'bc_get_europepmc_articles'.
    for mcp in [core_mcp, *(await get_openapi_mcps())]:
        await mcp_app.import_server(
            mcp,
            slugify(mcp.name),
        )
    logger.info("MCP server setup complete.")
  • Imports all tools from the europepmc module, which triggers the execution of decorators and registers get_europepmc_articles on core_mcp.
    from .europepmc import *
  • Pydantic schema defined via Annotated type hints and Field descriptions for input parameters and return type.
    def get_europepmc_articles(
        query: Annotated[Optional[str], Field(description="General search query")] = None,
        title: Annotated[Optional[str], Field(description="Search in article titles")] = None,
        abstract: Annotated[Optional[str], Field(description="Search in abstracts")] = None,
        author: Annotated[Optional[str], Field(description="Author name (e.g., 'lastname,firstname')")] = None,
        search_type: Annotated[str, Field(description="'and' or 'or' (default: 'or')")] = "or",
        sort_by: Annotated[
            Optional[str],
            Field(description="'recent' or 'cited' (default: none)"),
        ] = None,
        page_size: Annotated[int, Field(description="Results per page (1-1000)", ge=1, le=1000)] = 25,
    ) -> dict:
  • Imports the get_europepmc_articles function into the europepmc package namespace.
    from ._get_europepmc_articles import get_europepmc_articles
Behavior3/5

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

With no annotations provided, the description carries the full burden. It discloses the return type (dict with resultList containing articles or error) and search logic, but lacks details on rate limits, authentication needs, pagination behavior beyond page_size, or what constitutes an error. It adds some context but leaves key behavioral traits 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 with two sentences: the first states the purpose and parameters, the second specifies the return format. It's front-loaded with essential information and avoids redundancy, though it could be slightly more structured (e.g., bullet points for parameters).

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

Completeness4/5

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

Given the tool's moderate complexity (7 parameters, search functionality), 100% schema coverage, and an output schema (implied by 'Returns: dict'), the description is reasonably complete. It covers the core purpose and return format, though it lacks behavioral details like error handling or performance considerations that would be helpful without annotations.

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 documents all 7 parameters thoroughly. The description adds minimal value by mentioning the combinable search fields and 'and'/'or' logic, but doesn't provide additional syntax, examples, or constraints beyond what's in the schema. Baseline 3 is appropriate when schema does the heavy lifting.

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 searches Europe PMC articles by specific fields (query, title, abstract, author) with logical operators, distinguishing it from siblings like 'bc_get_europepmc_fulltext' which likely retrieves full text. However, it doesn't explicitly differentiate from other search tools like 'bc_search_google_scholar_publications' beyond the data source.

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 description implies usage for searching Europe PMC articles with combinable terms, but provides no explicit guidance on when to use this versus alternatives like 'bc_search_google_scholar_publications' or 'bc_get_europepmc_fulltext'. It mentions 'and'/'or' logic but doesn't specify when to choose which operator.

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/biocontext-ai/knowledgebase-mcp'

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