Skip to main content
Glama
hajifkd

inspirehep-mcp

by hajifkd

inspirehep_search_by_fulltext

Read-onlyIdempotent

Search high-energy physics literature by keyword or phrase within paper content, with options to filter by year, collaboration size, and sort by citations or date.

Instructions

Search INSPIRE-HEP literature by full text.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
paramsYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The inspirehep_search_by_fulltext tool handler function decorated with @mcp.tool. It accepts FulltextSearchInput parameters, builds a fulltext query using build_fulltext_query, and executes the search via run_search.
    @mcp.tool(
        name="inspirehep_search_by_fulltext",
        annotations={
            "title": "Search INSPIRE-HEP papers by full text",
            "readOnlyHint": True,
            "destructiveHint": False,
            "idempotentHint": True,
            "openWorldHint": True,
        },
    )
    async def inspirehep_search_by_fulltext(params: FulltextSearchInput) -> dict[str, Any]:
        """Search INSPIRE-HEP literature by full text."""
    
        query = build_fulltext_query(params.fulltext, params.large_collaboration, params.year)
        return await run_search(
            query=query,
            limit=params.limit,
            sort_by_citation=params.sort_by_citation,
        )
  • FulltextSearchInput schema definition - a Pydantic BaseModel that validates the fulltext parameter (required string, min 1, max 300 chars) and inherits from BaseSearchInput for additional fields like limit, sort_by_citation, year, and large_collaboration.
    class FulltextSearchInput(BaseSearchInput):
        fulltext: str = Field(
            ...,
            min_length=1,
            max_length=300,
            description="Full-text keyword or phrase to search in paper body.",
        )
  • BaseSearchInput schema - base Pydantic BaseModel with common search parameters including large_collaboration (bool), limit (int, 1-50), sort_by_citation (bool), and year (optional int).
    class BaseSearchInput(BaseModel):
        model_config = ConfigDict(str_strip_whitespace=True, extra="forbid")
    
        large_collaboration: bool = Field(
            default=False,
            description="Include large-collaboration papers. Default false excludes very large collaborations.",
        )
        limit: int = Field(
            default=20,
            ge=1,
            le=50,
            description="Maximum number of papers to return (default: 20).",
        )
        sort_by_citation: bool = Field(
            default=True,
            description="If true, sort by citation count. If false, sort by most recent date.",
        )
        year: int | None = Field(
            default=None,
            ge=1900,
            le=2100,
            description="Optional publication year filter (e.g. 2020).",
        )
  • build_fulltext_query helper function that constructs an INSPIRE-HEP fulltext search query string by escaping the input text and applying optional filters for year and collaboration size.
    def build_fulltext_query(fulltext: str, large_collaboration: bool, year: int | None = None) -> str:
        escaped = _escape_quotes(fulltext)
        base_query = f'ft "{escaped}"'
        return _apply_filters(base_query, large_collaboration, year)
  • run_search helper function that executes the actual search request to INSPIRE-HEP API, handles errors, and returns formatted results with count and records.
    async def run_search(
        *,
        query: str,
        limit: int,
        sort_by_citation: bool,
        client: InspireHEPClient | None = None,
    ) -> dict[str, Any]:
        sort = _to_inspire_sort(sort_by_citation)
        try:
            if client is not None:
                search_result = await client.search_literature(query=query, limit=limit, sort=sort)
            else:
                async with InspireHEPClient() as default_client:
                    search_result = await default_client.search_literature(
                        query=query,
                        limit=limit,
                        sort=sort,
                    )
        except httpx.HTTPStatusError as exc:
            status = exc.response.status_code
            message = exc.response.text or "No response body."
            raise RuntimeError(
                f"INSPIRE API error ({status}): {message[:300]}"
            ) from exc
        except httpx.HTTPError as exc:
            raise RuntimeError(f"INSPIRE API request failed: {exc}") from exc
    
        return {
            "count": len(search_result.records),
            "records": search_result.records,
        }
Behavior3/5

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

Annotations already provide readOnlyHint=true, openWorldHint=true, idempotentHint=true, and destructiveHint=false, covering safety and behavior. The description adds no additional behavioral context (e.g., rate limits, auth needs, or what 'full text' search entails), but does not contradict annotations.

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 a single, efficient sentence with no wasted words, clearly front-loaded with the tool's purpose. It earns its place by succinctly conveying the core functionality.

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 has annotations covering safety and behavior, an output schema exists, and the description is concise but clear, it is reasonably complete. However, it could better address parameter usage or search scope to fully compensate for low schema coverage.

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 0%, but the description mentions 'full text' which aligns with the 'fulltext' parameter. However, it does not explain other parameters (e.g., limit, sort_by_citation) or add meaning beyond the schema's property descriptions. With 0% coverage, baseline is lower, but the description partially compensates by hinting at the key parameter.

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 action ('Search') and resource ('INSPIRE-HEP literature') with the method ('by full text'). It distinguishes from sibling tools that search by author or title, though it could be more specific about what 'full text' encompasses (e.g., paper body vs metadata).

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 context through 'by full text' versus siblings' 'by author' or 'by title', but lacks explicit guidance on when to choose this tool over alternatives or any prerequisites. The context is clear but not explicitly stated.

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/hajifkd/inspirehep-mcp'

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