@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.
42 lines • 2.11 kB
TypeScript
/**
* @fileoverview Unpaywall service. Resolves a DOI to an open-access location
* and fetches the raw content (HTML or PDF) for downstream extraction. Enabled
* only when `UNPAYWALL_EMAIL` is set — absence leaves the fallback disabled.
*
* Philosophy: best-effort. Upstream 404s and non-OA DOIs return a `no-oa`
* resolution; only genuine service failures (5xx, network, timeout) throw.
* @module src/services/unpaywall/unpaywall-service
*/
import { type UnpaywallContent, type UnpaywallLocation, type UnpaywallResolution } from './types.js';
/**
* Resolves a DOI to an open-access copy via Unpaywall and fetches its bytes.
* Constructed only when `UNPAYWALL_EMAIL` is present; absent config → no service.
*/
export declare class UnpaywallService {
private readonly email;
private readonly timeoutMs;
constructor(email: string, timeoutMs: number);
/**
* Look up a DOI in Unpaywall. Returns a structured outcome — never throws
* for a DOI that simply has no OA copy or that Unpaywall doesn't know.
* Throws `McpError(ServiceUnavailable)` only for network/server failures.
*/
resolve(doi: string, signal?: AbortSignal): Promise<UnpaywallResolution>;
/**
* Fetch the content at an Unpaywall location. Prefers `url_for_pdf` when
* present (direct PDF bytes) and falls back to `url` (HTML landing page).
* Throws `McpError(ServiceUnavailable)` on network/server failures or
* unreadable responses — caller handles partial failures.
*/
fetchContent(location: UnpaywallLocation, signal?: AbortSignal): Promise<UnpaywallContent>;
private fetchAs;
}
/**
* Initialize the Unpaywall service if `UNPAYWALL_EMAIL` is configured.
* Safe to call regardless — absence of the env var leaves the service unset,
* and `getUnpaywallService()` returns `undefined`.
*/
export declare function initUnpaywallService(): void;
/** Returns the initialized service, or `undefined` when the fallback is disabled. */
export declare function getUnpaywallService(): UnpaywallService | undefined;
//# sourceMappingURL=unpaywall-service.d.ts.map