Skip to main content
Glama
liueic

PubChem Chemical Safety MCP Server

by liueic

get_safety_info

Retrieve GHS safety classifications for chemical compounds from PubChem, including hazard statements, pictograms, and signal words using compound IDs.

Instructions

获取GHS安全分类信息

Args: cid: PubChem化合物ID

Returns: 包含信号词、GHS象形图、危害声明等安全信息的字典

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
cidYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The handler function get_safety_info, which is registered as an MCP tool, orchestrates the retrieval of safety data by checking the cache and then querying the PubChem client if necessary.
    async def get_safety_info(ctx: Context, cid: int) -> Dict[str, Any]:
        """
        获取GHS安全分类信息
        
        Args:
            cid: PubChem化合物ID
            
        Returns:
            包含信号词、GHS象形图、危害声明等安全信息的字典
        """
        try:
            # 初始化缓存服务
            cache_service = CacheService()
            await cache_service.initialize()
            
            # 检查缓存
            cached_data = await cache_service.get_safety_info(cid)
            if cached_data:
                await cache_service.close()
                return {"cid": cid, **cached_data}
            
            # 从PubChem获取数据
            async with PubChemClient() as client:
                safety_data = await client.get_safety_info(cid)
                
                if "error" in safety_data:
                    await cache_service.close()
                    return {"cid": cid, "error": safety_data["error"]}
                
                # 缓存结果
                await cache_service.set_safety_info(cid, safety_data)
                await cache_service.close()
                
                return {"cid": cid, **safety_data}
                
        except Exception as e:
            logger.error(f"Error getting safety info for CID {cid}: {e}")
            return {"cid": cid, "error": str(e)}
  • The get_safety_info tool is registered using the @app.tool() decorator.
    @app.tool()
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It states this is a retrieval operation ('获取' - get) which implies read-only behavior, but doesn't explicitly confirm this or mention any side effects, authentication requirements, rate limits, or error conditions. The description provides basic functional information but lacks important behavioral context for a tool with zero annotation coverage.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is appropriately concise with clear sectioning: a purpose statement followed by Args and Returns sections. Each sentence serves a specific purpose - stating what the tool does, explaining the parameter, and describing the return value. There's no redundant information, though the structure could be slightly more polished.

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

Completeness3/5

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

Given the tool has an output schema (which handles return value documentation) and only one parameter, the description provides adequate context for the basic operation. However, with no annotations and sibling tools that appear related, the description should ideally provide more guidance on when to use this specific tool versus alternatives. It covers the essentials but leaves gaps in usage context.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The description adds significant value beyond the input schema, which has 0% description coverage. It explains that 'cid' represents a 'PubChem化合物ID' (PubChem compound ID), providing crucial semantic context that the schema lacks. With only one parameter and the schema providing no descriptions, the tool description effectively compensates for the schema's deficiencies by explaining what the parameter represents.

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

Purpose4/5

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

The description clearly states the tool's purpose: '获取GHS安全分类信息' (Get GHS safety classification information). It specifies the resource (GHS safety classification) and the action (get/retrieve). However, it doesn't explicitly differentiate from sibling tools like 'get_compound_info' or 'get_toxicity_data' - all appear to retrieve chemical information but for different aspects.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus the sibling tools. While it mentions the specific parameter (PubChem compound ID), it doesn't explain when one would need safety information versus general compound information or toxicity data. There's no context about prerequisites, alternatives, or exclusion criteria.

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

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