### Start MCP-Server Source: https://docs.tiangong.earth/MCP/lca_local This command starts the MCP-Server using npx, which allows executing Node.js packages without global installation. It launches the MCP-Server with HTTP local interface. ```bash # Start MCP-Server npx -p @tiangong-lca/mcp-server tiangong-lca-mcp-http-local ``` -------------------------------- ### Debug Project using npm start Source: https://docs.tiangong.earth/dev/dev-env Starts the project in debug mode. The application will be accessible at localhost:8000. ```shell npm start ``` -------------------------------- ### MCP Server - Cherry Studio Integration Source: https://context7.com/context7/tiangong_earth/llms.txt Guides on integrating the Tiangong LCA platform's MCP server directly within the Cherry Studio client for seamless data access and interaction. ```APIDOC ## Cherry Studio MCP Configuration ### Description Configures the Cherry Studio client to connect to the Tiangong LCA MCP server. ### Configuration Steps 1. In Cherry Studio, navigate to Settings > MCP Settings. 2. Click 'Add Server'. 3. Configure the following details: - **Type**: Streamable HTTP - **URL**: `https://lcamcp.tiangong.earth/mcp` - **Headers**: - `Content-Type`: application/json - `Authorization`: Bearer YOUR_API_KEY ### Usage After saving the configuration and establishing the MCP server connection, you can interact with the MCP tools through the chat interface. For example, you can ask: *User: "帮我查找中国的钢铁生产过程数据"* *Assistant: [Uses MCP Search_processes_Tool to query]* *Result: 找到15个相关过程数据...* ``` -------------------------------- ### Install Project Dependencies using npm and nvm Source: https://docs.tiangong.earth/dev/dev-env Installs Node Version Manager (nvm) and Node.js, then installs project dependencies using npm. Ensures the correct Node.js version (22) is aliased and used. ```shell curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.3/install.sh | bash nvm install nvm alias default 22 nvm use npm install ``` -------------------------------- ### Deploy Tiangong LCA Locally with Docker Source: https://context7.com/context7/tiangong_earth/llms.txt This Bash script outlines the steps for locally deploying the Tiangong LCA platform using Docker. It includes cloning the repository, configuring environment variables via a .env file, starting the services, checking their status, accessing the application and Supabase Studio, managing services (stop, restart, logs), rebuilding services, performing database backups, and resetting the environment. ```bash # 1. 克隆仓库 git clone https://github.com/linancn/tiangong-lca-next.git cd tiangong-lca-next # 2. 配置环境变量 cd docker cp .env.example .env nano .env # 关键配置项: # POSTGRES_PASSWORD=your_secure_password # JWT_SECRET=your_jwt_secret_at_least_32_characters # ANON_KEY=your_supabase_anon_key # SERVICE_ROLE_KEY=your_supabase_service_role_key # DASHBOARD_USERNAME=supabase # DASHBOARD_PASSWORD=your_dashboard_password # SMTP_HOST=smtp.exmail.qq.com # SMTP_PORT=465 # SMTP_USER=your_account@yourcompany.com # SMTP_PASS=your_smtp_password # SMTP_ADMIN_EMAIL=your_account@yourcompany.com # SMTP_SENDER_NAME=TianGong LCA # 3. 启动服务 docker compose up -d # 4. 检查服务状态 docker compose ps # 5. 访问应用 # TianGong LCA应用: http://localhost:8000 # Supabase Studio: http://localhost:54321 # PostgreSQL: localhost:5432 (会话连接) 或 localhost:6543 (池化连接) # 6. 管理命令 # 停止服务 docker compose stop # 重启服务 docker compose restart # 查看日志 docker compose logs -f app # 重建服务 docker compose up -d --build # 数据库备份 docker exec -t supabase-db pg_dumpall -c -U postgres > backup_$(date +%Y-%m-%d_%H-%M-%S).sql # 完全重置环境 ./reset.sh ``` -------------------------------- ### Install and Use Node.js with NVM Source: https://docs.tiangong.earth/MCP/lca_local This snippet demonstrates how to install a specific version of Node.js using NVM (Node Version Manager) and how to configure it for use. NVM is a tool for managing multiple Node.js versions on the same machine. ```bash # Install Node.js version 22 nvm install 22 # Configure the Node.js version to use nvm use ``` -------------------------------- ### Install MCP-Server Package Source: https://docs.tiangong.earth/MCP/lca_local This command installs the MCP-Server package globally using npm. This package is essential for running the MCP Server locally. ```bash # Install the package npm install -g @tiangong-lca/mcp-server@0.0.14 ``` -------------------------------- ### Launch MCP Inspector - Node.js Source: https://docs.tiangong.earth/MCP/KB_remote Command to launch the MCP Inspector tool using npx. This requires Node.js and npm to be installed. It automatically opens the Inspector web page in the default browser. ```bash npx @modelcontextprotocol/inspector ``` -------------------------------- ### Automate Release with Git Tags and Cloudflare Pages Source: https://docs.tiangong.earth/dev/dev-env Configures automatic release deployment by creating and pushing Git tags. Requires CLOUDFLARE_API_TOKEN and CLOUDFLARE_ACCOUNT_ID environment variables for deployment to Cloudflare Pages. ```shell # List existing tags git tag # Create a new tag git tag v0.0.1 # Push the tag to the remote repository git push origin v0.0.1 ``` -------------------------------- ### 备份 PostgreSQL 数据库 Source: https://docs.tiangong.earth/deploy/local-deploy 通过 `docker exec` 命令执行 `pg_dumpall` 来创建 PostgreSQL 数据库的完整备份。备份文件包含时间戳以便于管理。 ```bash # 创建 PostgreSQL 数据库备份 docker exec -t supabase-db pg_dumpall -c -U postgres > backup_$(date +%Y-%m-%d_%H-%M-%S).sql ``` -------------------------------- ### Build Project for Production using npm run build Source: https://docs.tiangong.earth/dev/dev-env Builds the project for production deployment. This command typically compiles and optimizes the code. ```shell npm run build ``` -------------------------------- ### 生成API密钥与访问API (Bash) Source: https://context7.com/context7/tiangong_earth/llms.txt 指导用户如何通过平台界面生成API密钥,并展示如何使用`curl`命令携带API密钥访问API来查询过程数据。API密钥是用于程序化访问和MCP服务器集成的关键凭证。 ```bash # 生成API Key流程 # 1. 登录天工生命周期数据平台 https://tiangong.earth # 2. 点击右上角个人名称,选择"账号信息" # 3. 点击"生成API Key"按钮 # 4. 输入平台密码进行验证 # 5. 点击"生成密钥"按钮,获取API Key # 使用API Key访问API curl -X GET "https://tiangong.earth/api/processes?name=煤炭" \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" # 响应示例 { "data": [ { "id": "550e8400-e29b-41d4-a716-446655440000", "name": "煤炭开采", "classification": "能源/化石燃料", "version": "1.0.0", "updated_at": "2025-10-10T12:00:00Z" } ], "total": 1 } ``` -------------------------------- ### 配置 Docker Compose 服务 Source: https://docs.tiangong.earth/deploy/local-deploy 使用 Docker Compose 管理 TianGong LCA 应用及其 Supabase 后端服务的启动、停止、重启和状态检查。这些命令用于控制整个应用的生命周期。 ```bash # 启动所有服务 docker compose up -d ``` ```bash # 以后台模式启动所有服务 docker compose up -d # 启动所有服务并在终端显示日志 docker compose up ``` ```bash # 停止所有服务,但保留容器 docker compose stop # 停止所有服务并移除容器 docker compose down # 停止所有服务、移除容器并删除数据卷(注意:此操作将删除所有数据) docker compose down -v ``` ```bash # 重启所有服务 docker compose restart ``` ```bash # 列出所有服务及其状态 docker compose ps # 检查指定服务的详细状态 docker compose ps app # 查看所有服务的资源使用情况 docker stats ``` ```bash # 为 app 服务重建并重启 docker compose up -d --build app # 重建所有服务 docker compose up -d --build ``` -------------------------------- ### 使用API进行数据搜索 (Bash) Source: https://context7.com/context7/tiangong_earth/llms.txt 展示如何使用HTTP GET请求调用平台的搜索API,根据关键词和模块对LCA过程数据进行全文搜索。该功能支持在所有字段中进行深度搜索和智能匹配。 ```bash # 搜索过程数据 GET https://tiangong.earth/api/search/processes?q=煤炭&module=open-data Authorization: Bearer YOUR_API_KEY ``` -------------------------------- ### 更新 TianGong LCA 服务 Source: https://docs.tiangong.earth/deploy/local-deploy 用于更新部署在 Docker 上的 TianGong LCA 服务。首先拉取最新的 Docker 镜像,然后重新启动服务以应用更新。 ```bash # 拉取最新镜像 docker compose pull # 重启服务 docker compose up -d ``` -------------------------------- ### Test Project Code using npm test Source: https://docs.tiangong.earth/dev/dev-env Executes the project's test suite. This command runs all defined tests to ensure code functionality. ```shell npm test ``` -------------------------------- ### 团队协作 API 示例 Source: https://context7.com/context7/tiangong_earth/llms.txt 演示如何使用API管理团队,包括创建团队、邀请成员、贡献数据、查看团队数据以及管理成员角色。 ```bash # 创建团队 POST https://tiangong.earth/api/teams Authorization: Bearer YOUR_API_KEY Content-Type: application/json { "name": "环境影响评估研究团队", "description": "专注于工业产品LCA研究" } ``` ```bash # 邀请成员加入团队 POST https://tiangong.earth/api/teams/team-001/invitations Authorization: Bearer YOUR_API_KEY Content-Type: application/json { "email": "member@example.com", "role": "member" // 角色: owner, admin, member } ``` ```bash # 成员接受邀请 POST https://tiangong.earth/api/teams/invitations/inv-12345/accept Authorization: Bearer MEMBER_API_KEY ``` ```bash # 贡献数据给团队 POST https://tiangong.earth/api/my-data/processes/550e8400-e29b-41d4-a716-446655440000/contribute Authorization: Bearer YOUR_API_KEY Content-Type: application/json { "team_id": "team-001" } ``` ```bash # 查看团队数据 GET https://tiangong.earth/api/team-data/processes?team_id=team-001 Authorization: Bearer YOUR_API_KEY ``` ```bash # 管理团队成员 PUT https://tiangong.earth/api/teams/team-001/members/member@example.com Authorization: Bearer YOUR_API_KEY Content-Type: application/json { "role": "admin" // 设为管理员 } ``` ```bash # 移除团队成员 DELETE https://tiangong.earth/api/teams/team-001/members/member@example.com Authorization: Bearer YOUR_API_KEY ``` -------------------------------- ### PostgreSQL 数据库连接命令 Source: https://docs.tiangong.earth/deploy/local-deploy 提供了两种连接 PostgreSQL 数据库的方式:一种用于基于会话的连接,另一种用于池化的事务连接。这些命令适用于直接与数据库交互。 ```bash psql 'postgres://postgres.your-tenant-id:your-super-secret-and-long-postgres-password@localhost:5432/postgres' ``` ```bash psql 'postgres://postgres.your-tenant-id:your-super-secret-and-long-postgres-password@localhost:6543/postgres' ``` -------------------------------- ### 从备份恢复 PostgreSQL 数据库 Source: https://docs.tiangong.earth/deploy/local-deploy 用于从 SQL 备份文件恢复 PostgreSQL 数据库。该过程包括停止服务、移除旧数据卷、启动数据库服务、等待其准备就绪,然后导入备份数据。 ```bash # 停止服务 docker compose down # 重置数据库卷 rm -rf ./volumes/db/data # 启动数据库服务 docker compose up -d db # 等待数据库准备就绪 sleep 10 # 从备份文件恢复 cat your_backup_file.sql | docker exec -i supabase-db psql -U postgres # 启动所有服务 docker compose up -d ``` -------------------------------- ### 用户注册、登录与API认证 (Bash) Source: https://context7.com/context7/tiangong_earth/llms.txt 演示如何使用Bash脚本通过HTTP请求注册新用户、登录获取访问令牌,并使用该令牌访问受保护的API端点。需要提供有效的邮箱和密码。 ```bash # 注册新用户 POST https://tiangong.earth/auth/register Content-Type: application/json { "email": "user@example.com", "password": "SecurePassword123!" } # 登录获取令牌 POST https://tiangong.earth/auth/login Content-Type: application/json { "email": "user@example.com", "password": "SecurePassword123!" } # 响应示例 { "access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...", "token_type": "bearer", "expires_in": 3600 } # 使用令牌访问API GET https://tiangong.earth/api/user/profile Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9... ``` -------------------------------- ### 查看 Docker Compose 服务日志 Source: https://docs.tiangong.earth/deploy/local-deploy 用于查看 Docker Compose 管理的服务的日志信息。可以查看所有服务的聚合日志,或过滤特定服务的日志,并可以选择实时跟踪日志。 ```bash docker compose logs ``` ```bash docker compose logs app docker compose logs db ``` ```bash # 查看所有日志信息 docker compose logs -f # 查看指定服务的日志 docker compose logs -f app docker compose logs -f db docker compose logs -f auth ``` -------------------------------- ### 数据搜索功能 Source: https://context7.com/context7/tiangong_earth/llms.txt 提供全局搜索API,允许用户在所有数据字段中进行关键词搜索。 ```APIDOC ## 数据搜索功能 ### 描述 平台提供强大的全文搜索功能,支持在所有字段中进行深度搜索和智能匹配。可指定搜索范围,例如在开放数据或我的数据中进行搜索。 ### API Endpoint #### 搜索过程数据 * **Method**: GET * **Endpoint**: `https://tiangong.earth/api/search/processes` * **Query Parameters**: * `q` (string) - Required - 搜索关键词 * `module` (string) - Optional - 指定搜索模块, e.g., "open-data" 或 "my-data" * **Headers**: * `Authorization` (string) - Required - API Key 或 Access Token, 格式: `Bearer YOUR_AUTH_TOKEN` ```bash GET https://tiangong.earth/api/search/processes?q=煤炭&module=open-data Authorization: Bearer YOUR_API_KEY ``` * **Success Response (200)**: 返回搜索匹配的数据列表,结构与对应模块的数据列表接口类似。 ``` -------------------------------- ### MCP服务器 - Cherry Studio集成配置 Source: https://context7.com/context7/tiangong_earth/llms.txt 展示如何在Cherry Studio客户端中配置天工LCA的MCP服务器连接,包括服务器URL和认证信息。 ```json // Cherry Studio MCP配置 // 在设置 > MCP Settings > Add Server { "type": "Streamable HTTP", "url": "https://lcamcp.tiangong.earth/mcp", "headers": { "Content-Type": "application/json", "Authorization": "Bearer YOUR_API_KEY" } } // 保存配置后启动MCP Server连接 // 在聊天界面使用MCP工具 // 示例对话: // User: "帮我查找中国的钢铁生产过程数据" // Assistant: [使用MCP Search_processes_Tool查询] // Result: 找到15个相关过程数据... ``` -------------------------------- ### 生成API密钥 Source: https://context7.com/context7/tiangong_earth/llms.txt 指导用户如何在平台内生成API Key,并提供使用API Key进行程序化访问的示例。 ```APIDOC ## 生成API密钥 ### 描述 在平台账号信息页面生成API Key,用于程序化访问和MCP服务器集成。API Key的使用方式与认证令牌类似,通过Authorization头进行传递。 ### 流程 1. 登录天工生命周期数据平台 `https://tiangong.earth` 2. 点击右上角个人名称,选择"账号信息" 3. 点击"生成API Key"按钮 4. 输入平台密码进行验证 5. 点击"生成密钥"按钮,获取API Key ### API 示例 #### 查询过程数据 (使用API Key) * **Method**: GET * **Endpoint**: `https://tiangong.earth/api/processes?name=煤炭` * **Headers**: * `Authorization` (string) - Required - API Key, 格式: `Bearer YOUR_API_KEY` * `Content-Type` (string) - Required - `application/json` ```bash curl -X GET "https://tiangong.earth/api/processes?name=煤炭" \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" ``` * **Success Response (200)**: * `data` (array) - 过程数据列表 * `id` (string) - 过程ID * `name` (string) - 过程名称 * `classification` (string) - 分类 * `version` (string) - 版本 * `updated_at` (string) - 更新时间 (ISO 8601格式) * `total` (integer) - 数据总数 ```json { "data": [ { "id": "550e8400-e29b-41d4-a716-446655440000", "name": "煤炭开采", "classification": "能源/化石燃料", "version": "1.0.0", "updated_at": "2025-10-10T12:00:00Z" } ], "total": 1 } ``` ``` -------------------------------- ### 克隆 TianGong LCA 仓库 Source: https://docs.tiangong.earth/deploy/local-deploy 用于初始化本地项目,通过 Git 克隆 TianGong LCA Next 应用的仓库。请确保将占位符 URL 替换为实际的仓库地址。 ```bash TODO: 将仓库 URL 替换为你自己的 git clone https://github.com/linancn/tiangong-lca-next.git cd tiangong-lca-next ``` -------------------------------- ### 数据模块 - 开放数据查看 Source: https://context7.com/context7/tiangong_earth/llms.txt 提供访问平台标准化LCA数据集的API,包括列表查询和详情查看。 ```APIDOC ## 数据模块 - 开放数据查看 ### 描述 开放数据模块提供经过审核的标准化LCA数据集,所有用户均可查看和引用。可以通过API查询数据集列表或获取特定数据集的详细信息。 ### API Endpoints #### 1. 查询开放数据集列表 * **Method**: GET * **Endpoint**: `https://tiangong.earth/api/open-data/processes` * **Query Parameters**: * `page` (integer) - Optional - 页码, 默认为1 * `limit` (integer) - Optional - 每页数量, 默认为20 * **Headers**: * `Authorization` (string) - Required - API Key 或 Access Token, 格式: `Bearer YOUR_AUTH_TOKEN` ```bash GET https://tiangong.earth/api/open-data/processes?page=1&limit=20 Authorization: Bearer YOUR_API_KEY ``` * **Success Response (200)**: * `data` (array) - 数据集列表 * `id` (string) - 数据集ID * `name` (string) - 数据集名称 * `classification` (string) - 分类 * `version` (string) - 版本 * `geography` (string) - 地理区域 * `time_period` (string) - 时间范围 * `updated_at` (string) - 更新时间 (ISO 8601格式) * `pagination` (object) - 分页信息 * `page` (integer) - 当前页 * `limit` (integer) - 每页数量 * `total` (integer) - 总数 ```json { "data": [ { "id": "550e8400-e29b-41d4-a716-446655440000", "name": "crude steel production; Hotrolling; Production mix, in the factory", "classification": "Materials production/Metals and alloys", "version": "3.0", "geography": "CN", "time_period": "2020-2022", "updated_at": "2025-09-15T10:30:00Z" } ], "pagination": { "page": 1, "limit": 20, "total": 156 } } ``` #### 2. 查看特定数据集详情 * **Method**: GET * **Endpoint**: `https://tiangong.earth/api/open-data/processes/{id}` * **Path Parameters**: * `id` (string) - Required - 数据集ID * **Headers**: * `Authorization` (string) - Required - API Key 或 Access Token, 格式: `Bearer YOUR_AUTH_TOKEN` ```bash GET https://tiangong.earth/api/open-data/processes/550e8400-e29b-41d4-a716-446655440000 Authorization: Bearer YOUR_API_KEY ``` * **Success Response (200)**: 包含完整的过程信息 * `id` (string) - 数据集ID * `name` (string) - 数据集名称 * `classification` (string) - 分类 * `version` (string) - 版本 * `geography` (string) - 地理区域 * `time_period` (object | string) - 时间范围 * `start` (string) - 开始时间 (YYYY-MM-DD) * `end` (string) - 结束时间 (YYYY-MM-DD) * `inputs` (array) - 输入流列表 * `flow_id` (string) - 流ID * `flow_name` (string) - 流名称 * `amount` (number) - 数量 * `unit` (string) - 单位 * `outputs` (array) - 输出流列表 * `flow_id` (string) - 流ID * `flow_name` (string) - 流名称 * `amount` (number) - 数量 * `unit` (string) - 单位 * `is_reference` (boolean) - 是否为参考流 ```json { "id": "550e8400-e29b-41d4-a716-446655440000", "name": "crude steel production; Hotrolling; Production mix, in the factory", "classification": "Materials production/Metals and alloys", "version": "3.0", "geography": "CN", "time_period": { "start": "2020-01-01", "end": "2022-12-31" }, "inputs": [ { "flow_id": "660e8400-e29b-41d4-a716-446655440111", "flow_name": "coal", "amount": 450.5, "unit": "kg" } ], "outputs": [ { "flow_id": "770e8400-e29b-41d4-a716-446655440222", "flow_name": "steel, crude", "amount": 1000, "unit": "kg", "is_reference": true } ] } ``` ``` -------------------------------- ### 用户注册与认证 Source: https://context7.com/context7/tiangong_earth/llms.txt 提供用户注册、登录以获取认证令牌,以及使用令牌访问受保护资源的API。 ```APIDOC ## 用户注册与认证 ### 描述 用户通过邮箱注册账号,完成邮箱验证后即可登录平台。平台支持基本信息管理、密码修改和邮箱更换功能。注册和登录后可获取API访问所需的认证令牌。 ### API Endpoints #### 1. 注册新用户 * **Method**: POST * **Endpoint**: `https://tiangong.earth/auth/register` * **Request Body**: * `email` (string) - Required - 用户邮箱 * `password` (string) - Required - 用户密码 ```json { "email": "user@example.com", "password": "SecurePassword123!" } ``` #### 2. 登录获取令牌 * **Method**: POST * **Endpoint**: `https://tiangong.earth/auth/login` * **Request Body**: * `email` (string) - Required - 用户邮箱 * `password` (string) - Required - 用户密码 ```json { "email": "user@example.com", "password": "SecurePassword123!" } ``` * **Success Response (200)**: * `access_token` (string) - 认证令牌 * `token_type` (string) - 令牌类型 (e.g., "bearer") * `expires_in` (integer) - 令牌过期时间(秒) ```json { "access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...", "token_type": "bearer", "expires_in": 3600 } ``` #### 3. 访问受保护资源 * **Method**: GET * **Endpoint**: `/api/user/profile` (示例) * **Headers**: * `Authorization` (string) - Required - 认证令牌, 格式: `Bearer YOUR_ACCESS_TOKEN` *Example Usage*: ```bash GET https://tiangong.earth/api/user/profile Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9... ``` ``` -------------------------------- ### Search Processes API Source: https://context7.com/context7/tiangong_earth/llms.txt This API allows searching for processes with various filters and sorting options. It supports keyword search, geographical filtering, and sorting by update time. ```APIDOC ## GET /api/search/processes ### Description Searches for processes based on a query string and module. Supports filtering by module and other parameters. ### Method GET ### Endpoint `/api/search/processes` ### Query Parameters - **q** (string) - Required - The search query string. - **module** (string) - Optional - The module to search within. - **geography** (string) - Optional - Filters results by geography. - **sort** (string) - Optional - Field to sort results by. - **order** (string) - Optional - Order of sorting (e.g., 'asc', 'desc'). ### Request Example ```bash GET https://tiangong.earth/api/search/processes?q=coal&module=open-data Authorization: Bearer YOUR_API_KEY ``` ### Response #### Success Response (200) - **results** (array) - An array of matching process objects. - **id** (string) - The unique identifier of the process. - **name** (string) - The name of the process. - **match_fields** (array) - Fields that matched the search query. - **classification** (string) - The classification of the process. - **version** (string) - The version of the process. - **match_reason** (string) - Reason for the match (if applicable). - **total** (integer) - The total number of matching results. #### Response Example ```json { "results": [ { "id": "550e8400-e29b-41d4-a716-446655440000", "name": "煤炭开采", "match_fields": ["name", "classification"], "classification": "能源/化石燃料/煤炭", "version": "2.0" }, { "id": "660e8400-e29b-41d4-a716-446655440111", "name": "粗钢生产", "match_fields": ["inputs"], "match_reason": "输入流包含'煤炭'", "classification": "材料生产/金属合金", "version": "3.0" } ], "total": 2 } ``` ``` -------------------------------- ### 同步 Supabase Edge Functions Source: https://docs.tiangong.earth/deploy/local-deploy 将外部仓库的 Supabase Edge Functions 同步到本地 Docker 数据卷和 Supabase 项目目录。这涉及到创建临时目录、克隆仓库、复制文件和清理临时文件。 ```bash # 创建临时目录 mkdir -p temp_repo # 克隆 Edge Functions 仓库 git clone --depth 1 https://github.com/linancn/tiangong-lca-edge-functions.git temp_repo # 将 Edge Functions 复制到 Docker 数据卷目录 mkdir -p docker/volumes/functions cp -r temp_repo/supabase/functions/* docker/volumes/functions/ # 将 Edge Functions 复制到本地 Supabase 目录 cp -r temp_repo/supabase/functions/* supabase/functions/ # 清理临时目录 rm -rf temp_repo ``` -------------------------------- ### 导入与导出用户LCA数据 (Bash) Source: https://context7.com/context7/tiangong_earth/llms.txt 演示如何使用HTTP GET请求导出用户的数据为JSON格式,以及如何使用HTTP POST请求导入JSON格式的数据。导入文件需符合TIDAS结构标准,并使用`multipart/form-data`发送。 ```bash # 导出数据为JSON格式 GET https://tiangong.earth/api/my-data/processes/550e8400-e29b-41d4-a716-446655440000/export Authorization: Bearer YOUR_API_KEY # 导入JSON数据 POST https://tiangong.earth/api/my-data/processes/import Authorization: Bearer YOUR_API_KEY Content-Type: multipart/form-data # 表单数据包含JSON文件 # 文件格式必须符合TIDAS结构标准,无嵌套错误 ``` -------------------------------- ### MCP Server Integration - Remote Access Source: https://context7.com/context7/tiangong_earth/llms.txt Documentation for integrating with the Tiangong LCA platform's MCP (Model Context Protocol) server for remote access and AI tool integration. ```APIDOC ## MCP Inspector Connection ### Description Connects to the MCP server using the MCP Inspector tool. ### Tool `npx @modelcontextprotocol/inspector` ### Configuration - **Transport Type**: Streamable HTTP - **URL**: `https://lcamcp.tiangong.earth/mcp` - **Token**: YOUR_API_KEY or OAuth Access Token ## Using MCP Tools (e.g., Search_processes_Tool) ### Description Demonstrates how to use available MCP tools through the Inspector interface to search for processes. ### Steps 1. Open the MCP Inspector. 2. Navigate to the 'Tools' tab. 3. Click 'List Tools'. 4. Select 'Search_processes_Tool'. 5. Enter search keywords (e.g., 'coal'). 6. Click 'Run Tool'. ### Response Example ```json { "results": [ { "id": "550e8400-e29b-41d4-a716-446655440000", "name": "coal mining; underground", "geography": "CN", "version": "2.0" } ] } ``` ``` -------------------------------- ### Lint Project Code using npm run lint Source: https://docs.tiangong.earth/dev/dev-env Checks the code formatting according to project linting rules. This command verifies code style without making any changes. ```shell npm run lint ``` -------------------------------- ### 查询开放LCA数据集列表与详情 (Bash) Source: https://context7.com/context7/tiangong_earth/llms.txt 展示如何使用HTTP GET请求查询平台上的开放LCA数据集列表,并通过数据集ID获取特定数据集的详细信息。这些数据经过审核且标准化,可供所有用户查看和引用。 ```bash # 查询开放数据集列表 GET https://tiangong.earth/api/open-data/processes?page=1&limit=20 Authorization: Bearer YOUR_API_KEY # 响应示例 { "data": [ { "id": "550e8400-e29b-41d4-a716-446655440000", "name": "crude steel production; Hotrolling; Production mix, in the factory", "classification": "Materials production/Metals and alloys", "version": "3.0", "geography": "CN", "time_period": "2020-2022", "updated_at": "2025-09-15T10:30:00Z" } ], "pagination": { "page": 1, "limit": 20, "total": 156 } } # 查看特定数据集详情 GET https://tiangong.earth/api/open-data/processes/550e8400-e29b-41d4-a716-446655440000 Authorization: Bearer YOUR_API_KEY # 响应包含完整的过程信息,包括输入输出流、地理位置、时间范围等 { "id": "550e8400-e29b-41d4-a716-446655440000", "name": "crude steel production; Hotrolling; Production mix, in the factory", "classification": "Materials production/Metals and alloys", "version": "3.0", "geography": "CN", "time_period": { "start": "2020-01-01", "end": "2022-12-31" }, "inputs": [ { "flow_id": "660e8400-e29b-41d4-a716-446655440111", "flow_name": "coal", "amount": 450.5, "unit": "kg" } ], "outputs": [ { "flow_id": "770e8400-e29b-41d4-a716-446655440222", "flow_name": "steel, crude", "amount": 1000, "unit": "kg", "is_reference": true } ] } ``` -------------------------------- ### 重置 TianGong LCA 环境 Source: https://docs.tiangong.earth/deploy/local-deploy 执行一个重置脚本 (`reset.sh`) 来完全清除当前的 TianGong LCA 环境。此操作将停止并移除所有容器,删除所有数据卷,并将 `.env` 文件恢复到默认状态。 ```bash # 运行重置脚本 ./reset.sh ``` -------------------------------- ### 管理用户LCA数据集 (创建、编辑、删除) (Bash) Source: https://context7.com/context7/tiangong_earth/llms.txt 演示如何使用HTTP POST, PUT, DELETE请求管理用户自己的LCA数据集,包括创建新的过程数据、编辑现有数据以及删除不再需要的数据。需要提供API密钥进行认证。 ```bash # 创建新的过程数据 POST https://tiangong.earth/api/my-data/processes Authorization: Bearer YOUR_API_KEY Content-Type: application/json { "name": "甲醇生产", "version": "1.0.0", "classification": "Chemicals production/Organic chemicals", "geography": "CN-BJ", "time_period": { "start": "2024-01-01", "end": "2024-12-31" }, "inputs": [ { "flow_id": "880e8400-e29b-41d4-a716-446655440333", "amount": 1.5, "unit": "kg" } ], "outputs": [ { "flow_id": "990e8400-e29b-41d4-a716-446655440444", "amount": 1.0, "unit": "kg", "is_reference": true } ] } # 编辑现有过程数据 PUT https://tiangong.earth/api/my-data/processes/550e8400-e29b-41d4-a716-446655440000 Authorization: Bearer YOUR_API_KEY Content-Type: application/json { "version": "1.1.0", "inputs": [ { "flow_id": "880e8400-e29b-41d4-a716-446655440333", "amount": 1.45, "unit": "kg" } ] } # 删除过程数据 DELETE https://tiangong.earth/api/my-data/processes/550e8400-e29b-41d4-a716-446655440000 Authorization: Bearer YOUR_API_KEY ``` -------------------------------- ### Fix Project Code Formatting using npm run lint:fix Source: https://docs.tiangong.earth/dev/dev-env Checks and automatically fixes code formatting issues based on project linting rules. This command attempts to resolve stylistic inconsistencies. ```shell npm run lint:fix ``` -------------------------------- ### MCP服务器集成 - 远程访问配置与工具使用 Source: https://context7.com/context7/tiangong_earth/llms.txt 配置MCP Inspector以连接天工LCA的MCP服务器,并演示如何使用Inspector工具搜索过程数据。 ```bash # MCP Inspector连接配置 npx @modelcontextprotocol/inspector # 在Inspector界面配置: # Transport Type: Streamable HTTP # URL: https://lcamcp.tiangong.earth/mcp # Token: YOUR_API_KEY 或 OAuth Access Token # 使用MCP工具搜索过程 # 在Inspector的Tools标签页中: # 1. 点击 "List Tools" # 2. 选择 "Search_processes_Tool" # 3. 输入搜索关键词: "coal" # 4. 点击 "Run Tool" ```