SCP-ElementKG 2.0

Chemistry

|

@ZJU

|

2026.02.06

ElementKG 2.0 is a chemistry knowledge graph that spans the entire chain from “elements–functional groups–molecules–reactions–experiments,” aiming to model the full lifecycle of chemical reactions.

ElementKG SCP Server

🧪 ElementKG 2.0 is a chemistry knowledge graph that spans the entire chain from “elements–functional groups–molecules–reactions–experiments,” aiming to model the full lifecycle of chemical reactions. Its node types include atoms, functional groups, molecular categories, specific compounds, reaction types, experimental steps, reagents, and instruments. It supports tasks such as molecular classification (e.g., by functional groups), tautomerism, reaction condition inference, and experiment-procedure reasoning. The graph currently integrates more than 10 million molecular entities and incorporates structural, property, and reaction data from sources such as PubChem and the Open Reaction Database. It can be used to train knowledge-enhanced chemical large models or agents, improving interpretability and reliability in tasks including reaction prediction, retrosynthesis planning, and experimental protocol generation.

🛠️ Tool List

Tool NameFunctional Description
query_cypherExecute any Cypher query statement, supporting flexible graph database operations
get_kg_statisticsObtain statistical information such as nodes, relationships, and type distribution of the knowledge graph
get_entity_detailsObtain detailed information and relationships of entities based on entity identifiers
get_experiment_workflowObtain the complete workflow of chemical experiments

🚀 Quick Start

1. Dependence

It is recommended to use Python 3.10+ and only need to install mcp :

				
					pip install mcp

				
			
2. Configuration

Please refer to the following code to define the Server client:

				
					# Python
----------
import asyncio
import json
from mcp.client.streamable_http import streamablehttp_client
from mcp.client.session import ClientSession

class MultiDomainKGClient:
    
    def __init__(self, server_url: str = "https://scp.intern-ai.org.cn/api/v1/mcp/37/SciGraph"):
        self.server_url = server_url
        self.session = None
        
    async def connect(self):
        """建立连接并初始化会话"""
        print(f"\n{'='*80}")
        print("连接到 SciGraph SCP Server")
        print(f"{'='*80}")
        print(f"服务器地址: {self.server_url}")
        
        try:
            self.transport = streamablehttp_client(
                url=self.server_url,
                headers={"SCP-HUB-API-KEY": "sk-xxx"}
            )
            self.read, self.write, self.get_session_id = await self.transport.__aenter__()
            
            self.session_ctx = ClientSession(self.read, self.write)
            self.session = await self.session_ctx.__aenter__()
            
            await self.session.initialize()
            session_id = self.get_session_id()
            
            print(f"✓ 连接成功")
            print(f"✓ 会话ID: {session_id}")
            print(f"{'='*80}\n")
            return True
            
        except Exception as e:
            print(f"✗ 连接失败: {e}")
            import traceback
            traceback.print_exc()
            return False
    
    async def disconnect(self):
        """断开连接"""
        try:
            if self.session:
                await self.session_ctx.__aexit__(None, None, None)
            if hasattr(self, 'transport'):
                await self.transport.__aexit__(None, None, None)
            print("\n✓ 已断开连接\n")
        except Exception as e:
            print(f"✗ 断开连接时出错: {e}")
    
    async def list_tools(self):
        """列出所有可用工具"""
        tools_list = await self.session.list_tools()
        print(f"\n可用工具 (共{len(tools_list.tools)}个):\n")
        for i, tool in enumerate(tools_list.tools, 1):
            print(f"{i:2d}. {tool.name}")
            if tool.description:
                desc_line = tool.description.split('\n')[0]
                print(f"    {desc_line}")
        return tools_list.tools
    
    def parse_result(self, result):
        """解析 MCP 工具调用结果"""
        try:
            if hasattr(result, 'content') and result.content:
                content = result.content[0]
                if hasattr(content, 'text'):
                    return json.loads(content.text)
            return str(result)
        except Exception as e:
            return {"error": f"解析结果失败: {e}", "raw": str(result)}

				
			

📊 Usage

Taking ElementKG 2.0 (Chemical Knowledge Graph 2.0) as an example, the query method is demonstrated as follows:

				
					# Python
----------
async def main():
    ## 客户端创建和连接
    client = MultiDomainKGClient()
    if not await client.connect():
        print("连接失败")
        return
    
    ## 示例1:获取知识图谱统计信息
    result = await client.session.call_tool(
        "get_kg_statistics",
        arguments={"kg_name": "ElementKG 2.0"}  # 不指定 kg_name,返回所有图谱统计
    )
    stats = client.parse_result(result)
    print(stats)
    
    ## 示例2:查询 ElementKG 2.0 实验的完整工作流
    result = await client.session.call_tool(
        "get_experiment_workflow",
        arguments={"experiment_id": "experiment_1"}
    )
    workflow = client.parse_result(result)
    print(workflow)
    
    ## 示例3:使用 Cypher 查询 ElementKG 2.0 相关信息
    result = await client.session.call_tool(
        "query_cypher",
        arguments={
            "cypher": "MATCH (e:Experiment:ElementKG 2.0) RETURN e.id as experiment_id",
            "kg_name": "ElementKG 2.0",
            "limit": 5
        }
    )
    experiment_id = client.parse_result(result)
    print(experiment_id)
    ## 示例4:获取 ElementKG 2.0 实体详情
    result = await client.session.call_tool(
        "get_entity_details",
        arguments={
            "entity_identifier": "experiment_1",
            "kg_name": "ElementKG 2.0"
        }
    )
    entity = client.parse_result(result)
    print(entity)
    ## 客户端断开
    await client.disconnect()

if __name__ == '__main__':
    asyncio.run(main())

				
			

🙏 Acknowledgements

We would like to express our gratitude to Zhejiang University and Shanghai Artificial Intelligence Laboratory for their strong support in the organization, deployment, and release of the ElementKG SCP Server.

query_cypher

Execute Cypher query and return results. Arguments: cypher: Cypher query statement. kg_name: Knowledge graph name (optional). If not specified, queries on all graphs. Supported: ElementKG, InstructProteinKG. limit: Maximum number of returned results (default 100). Returns: JSON format query results. Examples: # Query ElementKG experiment nodes query_cypher(“MATCH (e:Experiment:ElementKG) RETURN e LIMIT 10”) # Query InstructProteinKG protein nodes query_cypher(“MATCH (p:Protein:InstructProteinKG) RETURN p LIMIT 10”) # Cross-graph statistics query_cypher(“MATCH (n) RETURN labels(n), count(n) GROUP BY labels(n)”)
				
					{
    "properties": {
        "cypher": {
            "type": "string"
        },
        "kg_name": {
            "anyOf": [
                {
                    "type": "string"
                },
                {
                    "type": "null"
                }
            ],
            "default": null
        },
        "limit": {
            "default": 100,
            "type": "integer"
        }
    },
    "required": [
        "cypher"
    ],
    "type": "object"
}
				
			

get_kg_statistics

Obtain statistical information of the knowledge graph. Arguments: kg_name: Name of the knowledge graph (optional). If not specified, statistical information of all graphs will be returned. Supported: ElementKG, InstructProteinKG. Returns: Statistical information in JSON format. Examples: # Obtain statistical information of all graphs get_kg_statistics() # Obtain statistical information of ElementKG get_kg_statistics(“ElementKG”) # Obtain statistical information of InstructProteinKG get_kg_statistics(“InstructProteinKG”)
				
					{
    "properties": {
        "kg_name": {
            "anyOf": [
                {
                    "type": "string"
                },
                {
                    "type": "null"
                }
            ],
            "default": null
        }
    },
    "type": "object"
}
				
			

get_entity_details

Retrieve detailed information of an entity (support all knowledge graphs)Args:- entity_identifier: entity identifier- ElementKG: entity ID (e.g., “experiment_1”)- InstructProteinKG: protein sequence or hashkg_name: knowledge graph name (optional). If not specified, search across all graphs. Supports: ElementKG, InstructProteinKGReturns: detailed information of the entity in JSON formatExamples:# query ElementKG experimentget_entity_details(“experiment_1″, kg_name=”ElementKG”)# query InstructProteinKG proteinget_entity_details(“MAFSAEDVLKEY…”, kg_name=”InstructProteinKG”)# cross-graph queryget_entity_details(“some_identifier”)
				
					{
    "properties": {
        "entity_identifier": {
            "type": "string"
        },
        "kg_name": {
            "anyOf": [
                {
                    "type": "string"
                },
                {
                    "type": "null"
                }
            ],
            "default": null
        }
    },
    "required": [
        "entity_identifier"
    ],
    "type": "object"
}
				
			

get_experiment_workflow

Get the complete workflow of the experiment (exclusive for ElementKG)
Args: experiment_id: experiment ID
Returns: JSON-formatted experiment workflow (including steps and reagents)
Example: get_experiment_workflow(“experiment_1”)
				
					{
    "properties": {
        "experiment_id": {
            "type": "string"
        }
    },
    "required": [
        "experiment_id"
    ],
    "type": "object"
}
				
			
How to use?

1.Install MCP SDK

				
					pip install mcp
				
			

2.Apply for an API Key

3.Configuration Information

				
					https://scp.intern-ai.org.cn/api/v1/mcp/37/SciGraph
				
			
				
					{
  "mcpServers": {
    "SciGraph": {
      "type": "streamableHttp",
      "description": "这是一款面向科学研究的统一知识查询服务,集成了化学、生物等多个学科领域的知识图谱数据,支持跨学科知识检索、实体关系查询、领域知识问答等操作",
      "url": "https://scp.intern-ai.org.cn/api/v1/mcp/37/SciGraph",
      "headers": {
        "SCP-HUB-API-KEY": "{API-KEY}"
      }
    }
  }
}
				
			
Scroll to Top