Skip to main content
Glama
hajifkd

inspirehep-mcp

by hajifkd

inspirehep_search_by_title

Read-onlyIdempotent

Search high-energy physics literature on INSPIRE-HEP using title keywords to find relevant papers with citation counts, abstracts, and arXiv links.

Instructions

Search INSPIRE-HEP literature by title.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
paramsYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The main handler function 'inspirehep_search_by_title' decorated with @mcp.tool(). It takes TitleSearchInput params, builds a query using build_title_query, and executes the search via run_search().
    @mcp.tool(
        name="inspirehep_search_by_title",
        annotations={
            "title": "Search INSPIRE-HEP papers by title",
            "readOnlyHint": True,
            "destructiveHint": False,
            "idempotentHint": True,
            "openWorldHint": True,
        },
    )
    async def inspirehep_search_by_title(params: TitleSearchInput) -> dict[str, Any]:
        """Search INSPIRE-HEP literature by title."""
    
        query = build_title_query(params.title, params.large_collaboration, params.year)
        return await run_search(
            query=query,
            limit=params.limit,
            sort_by_citation=params.sort_by_citation,
        )
  • TitleSearchInput Pydantic model defining the input schema with title field (required, 1-300 chars) and inheriting common search parameters from BaseSearchInput (large_collaboration, limit, sort_by_citation, year).
    class TitleSearchInput(BaseSearchInput):
        title: str = Field(
            ...,
            min_length=1,
            max_length=300,
            description="Title keyword or phrase to search.",
        )
  • run_search async helper function that executes the literature search using InspireHEPClient, handles HTTP 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,
        }
  • build_title_query function that constructs an INSPIRE-HEP title search query by escaping the title and applying optional filters (large_collaboration, year).
    def build_title_query(title: str, large_collaboration: bool, year: int | None = None) -> str:
        escaped = _escape_quotes(title)
        base_query = f'title "{escaped}"'
        return _apply_filters(base_query, large_collaboration, year)
  • Helper functions _escape_quotes (line 184-185) and _apply_filters (line 188-194) that sanitize input and add year/author-count filters to the search query.
    def _escape_quotes(value: str) -> str:
        return value.replace("\\", "\\\\").replace('"', '\\"')
    
    
    def _apply_filters(base_query: str, large_collaboration: bool, year: int | None) -> str:
        clauses = [base_query]
        if year is not None:
            clauses.append(f"year {year}")
        if not large_collaboration:
            clauses.append(f"ac 1->{DEFAULT_NON_COLLAB_MAX_AUTHORS}")
        return " and ".join(clauses)
Behavior3/5

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

Annotations already provide readOnlyHint=true, destructiveHint=false, openWorldHint=true, and idempotentHint=true, covering safety and idempotency. The description adds no behavioral context beyond this, such as rate limits, authentication needs, or result format details. However, it doesn't 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. It's front-loaded with the core functionality ('Search INSPIRE-HEP literature by title'), making it easy to parse and understand immediately.

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 rich input schema with full parameter descriptions, annotations covering key behavioral traits, and the presence of an output schema (which handles return values), the description is reasonably complete. It could improve by adding usage guidelines relative to sibling tools, but overall it provides adequate context for a search operation.

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 input schema includes detailed descriptions for all parameters (title, year, limit, sort_by_citation, large_collaboration). The description adds no parameter semantics beyond the schema, but the schema provides comprehensive documentation, establishing a baseline of 3.

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'), specifying the search field ('by title'). It distinguishes from sibling tools that search by author or fulltext, though it doesn't explicitly contrast them in the description text itself.

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 inspirehep_search_by_author or inspirehep_search_by_fulltext. It lacks context about appropriate use cases, prerequisites, or exclusions, offering only basic functional information.

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