Skip to main content
Glama
Augmented-Nature

Unofficial PubChem MCP Server

get_compound_properties

Retrieve molecular properties like molecular weight, logP, and TPSA for chemical compounds using PubChem Compound IDs to support chemical analysis and research.

Instructions

Get molecular properties (MW, logP, TPSA, etc.)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
cidYesPubChem Compound ID (CID)
propertiesNoSpecific properties to retrieve (optional)

Implementation Reference

  • The main handler function that validates input arguments using isValidPropertiesArgs, determines the list of properties to fetch (defaults to common molecular descriptors if not specified), queries the PubChem PUG REST API, and returns the properties as formatted JSON text content.
    private async handleGetCompoundProperties(args: any) { if (!isValidPropertiesArgs(args)) { throw new McpError(ErrorCode.InvalidParams, 'Invalid compound properties arguments'); } try { const properties = args.properties || [ 'MolecularWeight', 'XLogP', 'TPSA', 'HBondDonorCount', 'HBondAcceptorCount', 'RotatableBondCount', 'Complexity', 'HeavyAtomCount', 'Charge' ]; const response = await this.apiClient.get(`/compound/cid/${args.cid}/property/${properties.join(',')}/JSON`); return { content: [ { type: 'text', text: JSON.stringify(response.data, null, 2), }, ], }; } catch (error) { throw new McpError( ErrorCode.InternalError, `Failed to get compound properties: ${error instanceof Error ? error.message : 'Unknown error'}` ); } }
  • src/index.ts:503-514 (registration)
    Tool registration entry in the ListTools response, defining the tool name, description, and input schema for parameter validation.
    { name: 'get_compound_properties', description: 'Get molecular properties (MW, logP, TPSA, etc.)', inputSchema: { type: 'object', properties: { cid: { type: ['number', 'string'], description: 'PubChem Compound ID (CID)' }, properties: { type: 'array', items: { type: 'string' }, description: 'Specific properties to retrieve (optional)' }, }, required: ['cid'], }, },
  • Type guard function for validating input arguments to the get_compound_properties tool, ensuring cid is provided and properties is an optional string array.
    const isValidPropertiesArgs = ( args: any ): args is { cid: number | string; properties?: string[] } => { return ( typeof args === 'object' && args !== null && (typeof args.cid === 'number' || typeof args.cid === 'string') && (args.properties === undefined || (Array.isArray(args.properties) && args.properties.every((p: any) => typeof p === 'string'))) ); };
  • src/index.ts:766-767 (registration)
    Dispatch case in the CallToolRequest handler that routes the tool call to the specific handleGetCompoundProperties method.
    case 'get_compound_properties': return await this.handleGetCompoundProperties(args);

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

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