Skip to main content
Glama

get_compound_info

Retrieve detailed compound information by PubChem CID, including structure, properties, and bioassay data. Supports multiple output formats like JSON, SDF, and XML for flexible data access.

Instructions

Get detailed information for a specific compound by PubChem CID

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
cidYesPubChem Compound ID (CID)
formatNoOutput format (default: json)

Implementation Reference

  • The main handler function that validates input, fetches compound information from PubChem API using the provided CID, and returns the data in the specified format.
    private async handleGetCompoundInfo(args: any) { if (!isValidCidArgs(args)) { throw new McpError(ErrorCode.InvalidParams, 'Invalid CID arguments'); } try { const format = args.format || 'json'; const response = await this.apiClient.get(`/compound/cid/${args.cid}/${format === 'json' ? 'JSON' : format}`); return { content: [ { type: 'text', text: format === 'json' ? JSON.stringify(response.data, null, 2) : String(response.data), }, ], }; } catch (error) { throw new McpError( ErrorCode.InternalError, `Failed to get compound info: ${error instanceof Error ? error.message : 'Unknown error'}` ); } }
  • The input schema definition for the get_compound_info tool, specifying parameters cid (required) and optional format.
    { name: 'get_compound_info', description: 'Get detailed information for a specific compound by PubChem CID', inputSchema: { type: 'object', properties: { cid: { type: ['number', 'string'], description: 'PubChem Compound ID (CID)' }, format: { type: 'string', enum: ['json', 'sdf', 'xml', 'asnt', 'asnb'], description: 'Output format (default: json)' }, }, required: ['cid'], },
  • src/index.ts:742-743 (registration)
    The switch case in CallToolRequestSchema handler that routes calls to get_compound_info to its handler function.
    case 'get_compound_info': return await this.handleGetCompoundInfo(args);
  • Type guard function to validate arguments for CID-based tools like get_compound_info.
    const isValidCidArgs = ( args: any ): args is { cid: number | string; format?: string } => { return ( typeof args === 'object' && args !== null && (typeof args.cid === 'number' || typeof args.cid === 'string') && (args.format === undefined || ['json', 'sdf', 'xml', 'asnt', 'asnb'].includes(args.format)) ); };

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/Augmented-Nature/PubChem-MCP-Server'

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