富士通社交数字孪生 MCP 服务器
该项目将富士通的社交数字孪生和数字排练 API与模型上下文协议 (MCP)相集成,允许大型语言模型 (LLM) 通过自然语言访问富士通的数字排练 API。
概述
富士通的“社会数字孪生”不仅能够基于现实世界的数据,在数字空间中重现人和物体的状态,还能重现整个经济和社会活动。其核心功能“数字演练”使用户能够在现实世界采取措施之前,在数字空间中模拟人类和社会行为,从而提前验证其效果和影响。
该项目使用 MCP 来弥合 LLM 和数字排演 API 之间的差距,使用户能够运行模拟并使用自然语言分析结果。
主要特点
- 检索并显示模拟列表
- 开始模拟
- 检索和分析模拟结果
- 管理模拟数据
- 分析交通模拟
- 比较场景
- 从自然语言生成模拟配置
先决条件
- Python 3.13 或更高版本
- 访问富士通 API 网关(API 密钥)
- MCP 兼容的 LLM 客户端(例如 Claude Desktop)
安装
通过 Smithery 安装
要通过Smithery自动为 Claude Desktop 安装 Fujitsu Social Digital Twin Server:
npx -y @smithery/cli install @3a3/fujitsu-sdt-mcp --client claude
1.克隆存储库
git clone https://github.com/3a3/fujitsu-sdt-mcp.git
cd fujitsu-sdt-mcp
2. 设置环境
使用 uv (推荐) :
首先,安装uv:
# Install uv using pip
pip install uv
# Or using curl (Linux/macOS)
curl -sSf https://astral.sh/uv/install.sh | sh
然后,使用 uv 设置你的环境:
# Create virtual environment
uv venv
# Activate virtual environment
# Windows:
.venv\Scripts\activate
# Unix/MacOS:
source .venv/bin/activate
# Install dependencies
uv pip install -r requirements.txt
或者,您可以使用提供的安装脚本:
# Make the script executable
chmod +x setup.sh
# Run setup
./setup.sh
3.设置环境变量
# Windows:
set FUJITSU_API_BASE_URL=https://apigateway.research.global.fujitsu.com/sdtp
set FUJITSU_API_KEY=your_api_key_here
# Unix/MacOS:
export FUJITSU_API_BASE_URL=https://apigateway.research.global.fujitsu.com/sdtp
export FUJITSU_API_KEY=your_api_key_here
或者,您可以创建具有以下设置的.env
文件:
FUJITSU_API_BASE_URL=https://apigateway.research.global.fujitsu.com/sdtp
FUJITSU_API_KEY=your_api_key_here
用法
启动 MCP 服务器
python -m fujitsu_sdt_mcp
服务器使用标准 I/O 与 MCP 客户端进行通信。
使用交互式客户端
还提供了一个简单的客户端,用于与 MCP 服务器直接交互:
当您启动客户端时,将显示可用资源和工具的列表,您可以从命令行调用它们。
使用 Claude Desktop 进行设置
要将服务器与 MCP 兼容的 LLM 客户端(例如 Claude Desktop)一起使用:
- 打开 Claude 桌面
- 前往“设置”>“开发者设置”>“编辑配置文件”
- 添加以下设置:
"command": "uvx",
"args": [
"fujitsu-sdt-mcp"
],
"env": {
"FUJITSU_API_BASE_URL": "https://apigateway.research.global.fujitsu.com/sdtp",
"FUJITSU_API_KEY": "your_api_key_here"
}
- 重启Claude桌面
资源和工具
资源
resource://digital_rehearsal_overview
:数字排练技术概述resource://simulation_metrics_explanation
:模拟指标的解释resource://scenario_examples
:示例场景
工具
list_simulations
:检索模拟列表start_simulation
:开始模拟get_simulation_result
:检索模拟结果get_metrics
:检索模拟指标list_simdata
:检索模拟数据列表get_simdata
:检索模拟数据analyze_traffic_simulation
:分析交通模拟compare_scenarios
:比较场景create_natural_language_simulation_config
:从自然语言生成模拟设置
使用示例
检索模拟列表
开始模拟
tool start_simulation {"simdataId": "your_simdata_id"}
分析交通模拟
tool analyze_traffic_simulation {"simulationId": "your_simulation_id", "region": "Tokyo", "timeRange": "morning rush hour", "scenario": "traffic optimization"}
从自然语言生成模拟设置
tool create_natural_language_simulation_config {"description": "I want to run a traffic optimization simulation during morning rush hour in Tokyo"}
LLM 互动示例
User: I want to run a traffic simulation during morning rush hour in Tokyo
Claude: I can help you run a traffic simulation for Tokyo's morning rush hour. Here's how we can set it up.
First, let's generate simulation settings from your natural language description:
[Tool execution: create_natural_language_simulation_config]
Generated settings:
{
"simulationType": "traffic",
"parameters": {
"region": "Tokyo",
"timeRange": "morning_rush"
},
"name": "traffic_20250416_123045"
}
Next, let's check available simulation data:
[Tool execution: list_simdata]
From this data, I can start a simulation using Tokyo's morning traffic data.
I've selected the appropriate simulation data ID and will start the simulation:
[Tool execution: start_simulation]
The simulation has started. The simulation ID is "sim_12345".
It will take some time for the results to be available. Once complete, I'll analyze them.
(After simulation completes)
Let's analyze the simulation results:
[Tool execution: analyze_traffic_simulation]
Analysis results:
- CO2 emissions: 1,250kg
- Average travel time: 42 minutes
- Total traffic volume: 15,700 vehicles
From these results, I can see that the Shibuya-Shinjuku route experiences particularly severe congestion.
Here are some potential improvements:
1. Optimize traffic signal control
2. Implement one-way traffic on certain roads during specific times
3. Increase public transportation frequency
Would you like to see a more detailed analysis?
贡献
请通过 GitHub Issues 报告错误或功能请求。欢迎提交 Pull 请求。
执照
本项目遵循 MIT 许可证发布。详情请参阅许可证文件。
致谢
- 富士通公司 - 社交数字孪生技术的发展
- 模型上下文协议 (MCP) - 实现与 LLM 的无缝集成