Skip to main content
Glama

Pubmed Convert Ids

pubmed_convert_ids
Read-only

Convert DOI, PMID, and PMCID article identifiers between formats. Process up to 50 PubMed Central IDs per request to standardize biomedical citations using NCBI's converter.

Instructions

Convert between article identifiers (DOI, PMID, PMCID). Accepts up to 50 IDs of a single type per request. Uses the NCBI PMC ID Converter API — only resolves articles indexed in PubMed Central. For articles not in PMC, use pubmed_search_articles instead.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idsYesArticle identifiers to convert. All IDs must be the same type. DOIs: "10.1093/nar/gks1195", PMIDs: "23193287", PMCIDs: "PMC3531190".
idtypeYesThe type of IDs being submitted. Required so the API can unambiguously resolve them.

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
recordsYesConversion results, one per input ID
totalConvertedYesNumber of IDs successfully converted
totalSubmittedYesNumber of IDs submitted

Implementation Reference

  • The main handler function that executes the pubmed_convert_ids tool. It calls getNcbiService().idConvert() to convert article IDs and transforms the response into a consistent format with requestedId, pmid, pmcid, doi, and errmsg fields.
    async handler(input, ctx) {
      ctx.log.info('Executing pubmed_convert_ids', {
        count: input.ids.length,
        idtype: input.idtype,
      });
    
      const raw = await getNcbiService().idConvert(input.ids, input.idtype);
    
      // NCBI returns pmid as a number in JSON — coerce all ID fields to strings
      const records = raw.map((r) => ({
        requestedId: String(r['requested-id']),
        ...(r.pmid !== undefined && { pmid: String(r.pmid) }),
        ...(r.pmcid !== undefined && { pmcid: String(r.pmcid) }),
        ...(r.doi !== undefined && { doi: String(r.doi) }),
        ...(r.errmsg !== undefined && { errmsg: String(r.errmsg) }),
      }));
    
      const totalConverted = records.filter((r) => !r.errmsg).length;
      ctx.log.info('pubmed_convert_ids completed', {
        totalConverted,
        totalSubmitted: input.ids.length,
      });
    
      return { records, totalConverted, totalSubmitted: input.ids.length };
    },
  • Input and output Zod schemas for the pubmed_convert_ids tool. The input schema validates the 'ids' array (1-50 items) and 'idtype' enum ('pmcid', 'pmid', 'doi'). The output schema defines the structure of conversion results including records array and conversion counts.
    input: z.object({
      ids: z
        .array(z.string().min(1))
        .min(1)
        .max(50)
        .describe(
          'Article identifiers to convert. All IDs must be the same type. ' +
            'DOIs: "10.1093/nar/gks1195", PMIDs: "23193287", PMCIDs: "PMC3531190".',
        ),
      idtype: z
        .enum(['pmcid', 'pmid', 'doi'])
        .describe(
          'The type of IDs being submitted. Required so the API can unambiguously resolve them.',
        ),
    }),
    
    output: z.object({
      records: z
        .array(
          z.object({
            requestedId: z.string().describe('The ID that was submitted'),
            pmid: z.string().optional().describe('PubMed ID'),
            pmcid: z.string().optional().describe('PubMed Central ID'),
            doi: z.string().optional().describe('Digital Object Identifier'),
            errmsg: z.string().optional().describe('Error message if conversion failed'),
          }),
        )
        .describe('Conversion results, one per input ID'),
      totalConverted: z.number().describe('Number of IDs successfully converted'),
      totalSubmitted: z.number().describe('Number of IDs submitted'),
    }),
  • src/index.ts:10-31 (registration)
    The pubmed_convert_ids tool is registered in the MCP server. The convertIdsTool is imported from convert-ids.tool.ts and added to the tools array in createApp().
    import { convertIdsTool } from './mcp-server/tools/definitions/convert-ids.tool.js';
    import { fetchArticlesTool } from './mcp-server/tools/definitions/fetch-articles.tool.js';
    import { fetchFulltextTool } from './mcp-server/tools/definitions/fetch-fulltext.tool.js';
    import { findRelatedTool } from './mcp-server/tools/definitions/find-related.tool.js';
    import { formatCitationsTool } from './mcp-server/tools/definitions/format-citations.tool.js';
    import { lookupCitationTool } from './mcp-server/tools/definitions/lookup-citation.tool.js';
    import { lookupMeshTool } from './mcp-server/tools/definitions/lookup-mesh.tool.js';
    import { searchArticlesTool } from './mcp-server/tools/definitions/search-articles.tool.js';
    import { spellCheckTool } from './mcp-server/tools/definitions/spell-check.tool.js';
    import { initNcbiService } from './services/ncbi/ncbi-service.js';
    
    await createApp({
      tools: [
        searchArticlesTool,
        fetchArticlesTool,
        fetchFulltextTool,
        formatCitationsTool,
        findRelatedTool,
        spellCheckTool,
        lookupMeshTool,
        lookupCitationTool,
        convertIdsTool,
  • The idConvert helper method in NcbiService that makes the actual API call to the NCBI PMC ID Converter API. It joins the IDs, makes an external request through the API client, parses the JSON response, and returns the conversion records.
    async idConvert(ids: string[], idtype?: string): Promise<IdConvertRecord[]> {
      const params: NcbiRequestParams = {
        ids: ids.join(','),
        format: 'json',
        ...(idtype && { idtype }),
      };
    
      const text = await this.queue.enqueue(
        () =>
          this.withRetry(
            () => this.apiClient.makeExternalRequest(NCBI_PMC_IDCONV_URL, params),
            'idconv',
          ),
        'idconv',
        params,
      );
    
      let parsed: unknown;
      try {
        parsed = JSON.parse(text);
      } catch {
        throw new McpError(
          JsonRpcErrorCode.SerializationError,
          'Failed to parse ID Converter JSON response.',
          { responseSnippet: text.substring(0, 200) },
        );
      }
    
      return (parsed as IdConvertResponse).records ?? [];
    }
Behavior4/5

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

Annotations indicate read-only and open-world behavior. Description adds critical context: the specific API used (NCBI PMC ID Converter), the 50-ID limit, and the crucial limitation that it only works for PMC-indexed articles—information not available in structured fields.

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?

Four sentences with zero waste. Front-loaded with core purpose, followed by operational limits, data source constraints, and alternative routing. Every sentence provides distinct, essential information.

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

Completeness5/5

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

Given the presence of an output schema and annotations, the description provides complete contextual coverage including API source, scope limitations, batch constraints, and sibling alternatives. No critical gaps remain.

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 coverage is 100% with detailed parameter descriptions and examples. Description reinforces constraints (50 IDs, single type) but does not add semantic meaning beyond what the schema already provides, warranting the baseline score.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

States specific action (convert) + resource (article identifiers) + specific formats (DOI, PMID, PMCID). Distinguishes from siblings by specifying it uses the 'NCBI PMC ID Converter API' rather than general PubMed search.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Explicitly states the scope limitation ('only resolves articles indexed in PubMed Central') and provides the exact alternative tool name for out-of-scope cases ('use pubmed_search_articles instead'). Also clarifies batch constraints.

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/cyanheads/pubmed-mcp-server'

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