@cyanheads/pubmed-mcp-server
Version:
Search PubMed/Europe PMC, fetch articles and full text (PMC/EPMC/Unpaywall), citations, MeSH terms via MCP. STDIO or Streamable HTTP.
47 lines • 1.86 kB
TypeScript
/**
* @fileoverview Low-level HTTP client for Europe PMC's REST API. Builds URLs,
* injects the optional contact email, and exposes single-attempt search and
* fullTextXML calls. Retry logic lives in `EuropePmcService`.
* @module src/services/europe-pmc/api-client
*/
import { type EuropePmcSearchParams } from './types.js';
export interface EuropePmcApiClientConfig {
email?: string;
timeoutMs: number;
}
/**
* Outcome of a fullTextXML fetch attempt. Wraps the typed contract so service
* callers don't need to inspect raw `Response` objects.
*/
export type EuropePmcFullTextFetchResult = {
kind: 'found';
xml: string;
} | {
kind: 'not-available';
reason: string;
};
/** Low-level HTTP client for Europe PMC. Single-attempt — retries upstream. */
export declare class EuropePmcApiClient {
private readonly config;
constructor(config: EuropePmcApiClientConfig);
/**
* Execute a search. Returns the raw JSON response body as a string so
* `EuropePmcService` can parse and surface SerializationError consistently
* when the body is malformed.
*/
search(params: EuropePmcSearchParams): Promise<string>;
/**
* Fetch the JATS full-text XML for an EPMC record by its internal id.
* Returns `{ kind: 'not-available' }` for 404 — EPMC has the record but
* doesn't publish a full-text XML for it (very common for preprints).
*/
fullTextXml(epmcId: string, signal?: AbortSignal): Promise<EuropePmcFullTextFetchResult>;
private buildSearchUrl;
/**
* Combine the caller's query with an optional source filter. EPMC's query
* syntax supports `SRC:"X"` field tokens — we OR-join the requested sources
* into a parenthesized clause and AND it with the user's query.
*/
private buildQueryString;
}
//# sourceMappingURL=api-client.d.ts.map