Token导航 LogoToken导航TokenDH.com
Spacemolt Crafting Server logo
浏览器工具未说明官方级别未说明来源级核验

Spacemolt Crafting Server

MCP Server

一个集成了市场数据和智能定价的综合性工艺查询服务器,支持MCP和HTTP API模式,适用于游戏内物品制作和资源管理。

工具数

6

提示词数

0

GitHub Stars

3

资源数

0
HTMLClaude浏览器自动化Claude

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

作者 / 组织

rsned

提供方

rsned

最后核验

2026/5/17 20:19

快速接入

先看主来源和安装命令,再打开仓库或文档;下面只保留这个条目的关键接入事实。

详细介绍

SpaceMolt制作查询服务器

SpaceMolt制作查询的综合服务器 市场数据整合智能定价.支持用于AI代理和web服务的MCP(模型上下文协议)和HTTP API模式。

  • 上次根据服务器版本重建和重新填充数据库: 0.271.3
  • 市场数据提交和复杂的定价计算
  • 用于实时市场数据集成的HTTP API

特性

6个MCP工具

  1. craft_query -“我可以用我的库存制作什么?”(可选市场定价,带station_id)
  2. craft_path_to -“我该如何制作这个特定的物品?”
  3. recipe_lookup -“告诉我这个食谱”(可选市场定价,带station_id)
  4. component_uses -“我能用这个项目做什么?”(可选市场定价,带station_id)
  5. bill_of_materials -“我需要什么原材料?”
  6. recipe_market_profitability -“显示所有配方的盈利能力”(有库存支持)

市场数据集成

  • 实时市场数据API:通过HTTP提交和查询市场价格
  • 复杂的定价算法:成交量加权,二次价格拍卖,中位数
  • 异常值自动处理:忽略价格操纵和极端异常值
  • 市场信心评分:基于样本量的高/中/低置信度
  • 自动重新计算:提交新订单时自动更新统计信息
  • 7天订单保留:保持订单有条理和新鲜

HTTP API终结点

# Submit market data
POST /api/v1/market/submit
Content-Type: application/json

{
  "station_id": "Grand Exchange Station",
  "empire_id": "empire_123",
  "orders": [
    {
      "item_id": "ore_iron",
      "order_type": "sell",
      "price_per_unit": 30,
      "volume_available": 128700
    }
  ]
}

# Query current market price
GET /api/v1/market/price/ore_iron

# Admin: manually recalculate stats
POST /api/v1/admin/market/recalc/ore_iron

制作服务器在返回食谱时使用粗略的优先级排序,以确保最好的东西可以先制作,而不是燃烧所有的周期和库存,制作标准弹药和冶炼铁。

按优先级分配配方

层级类别配方计数
1(最高)造船,传奇25
2精炼、模块、气体处理、设备、组件、采矿、冰精炼201
3武器、隐形、被动舰艇、无人机、防御、电子战108
4实用程序23
5弹药0
6(最低)耗材,仅限设施,生物精炼115

快速开始

安装

# Clone the repository
git clone https://github.com/rsned/spacemolt-crafting-server.git
cd spacemolt-crafting-server

# Build the server
go build -o bin/crafting-server ./cmd/crafting-server

# (Optional) Install to PATH
cp bin/crafting-server ~/bin/

用法

作为MCP服务器(默认)

# Run the server (communicates via stdin/stdout)
./bin/crafting-server -db crafting.db

作为HTTP服务器

# Run in HTTP API mode on port 8080
./bin/crafting-server -db crafting.db -http :8080

# Server is now available at:
# - http://localhost:8080/api/v1/health
# - http://localhost:8080/api/v1/market/submit
# - http://localhost:8080/api/v1/market/price/:item_id
# - http://localhost:8080/api/v1/admin/market/recalc/:item_id

数据库快照

预构建的数据库快照可在 database/ 目录,包含已导入的所有项目、食谱和技能。您可以直接使用它:

# Copy the pre-built database
cp database/crafting.db ./

# Or run the server with the snapshot directly
./bin/crafting-server -db database/crafting.db

从零开始

要从游戏目录JSON文件创建和填充新的数据库,请执行以下操作:

# Build the server
go build -o bin/crafting-server ./cmd/crafting-server

# Import all data into a new database (the DB file is created automatically)
./bin/crafting-server -db crafting.db \
  -import-items /path/to/catalog_items.json \
  -import-recipes /path/to/catalog_recipes.json \
  -import-skills /path/to/catalog_skills.json \
  -verbose

目录JSON文件使用 {"items": [...]} 信封格式,导入程序会自动处理。您还可以分别导入每个文件:

# Import items first (provides item metadata for names, categories, etc.)
./bin/crafting-server -db crafting.db -import-items catalog_items.json

# Import recipes (with inputs and outputs)
./bin/crafting-server -db crafting.db -import-recipes catalog_recipes.json

# Import skills (with prerequisites and XP thresholds)
./bin/crafting-server -db crafting.db -import-skills catalog_skills.json

# Set game version (optional, tracks which server version the data came from)
./bin/crafting-server -db crafting.db -game-version 0.271.3 -import-items catalog_items.json

# (Optional) Import market data for profit calculations
./bin/crafting-server -db crafting.db -import-market market.json

正在检查数据库版本

要查看数据库是从哪个游戏服务器版本构建的:

./bin/crafting-server -db crafting.db -version

输出:

Game Version: 0.271.3
Imported At: 2026-03-15 15:35:35 PDT
Updated At:  2026-04-24 14:59:37 PDT

验证导入

导入后,您可以使用SQLite验证数据:

sqlite3 crafting.db "
  SELECT 'items', COUNT(*) FROM items
  UNION ALL SELECT 'recipes', COUNT(*) FROM recipes
  UNION ALL SELECT 'skills', COUNT(*) FROM skills
  UNION ALL SELECT 'recipe_inputs', COUNT(*) FROM recipe_inputs
  UNION ALL SELECT 'recipe_outputs', COUNT(*) FROM recipe_outputs
  UNION ALL SELECT 'skill_levels', COUNT(*) FROM skill_levels
  UNION ALL SELECT 'skill_prerequisites', COUNT(*) FROM skill_prerequisites;
"

预期计数:~527个项目,~531个食谱,~28个技能,加上填充的连接表。

Claude代码集成

要将此MCP服务器与Claude Code一起使用,请将其添加到您的Claude Code配置文件中。

配置

编辑您的Claude Code配置文件(通常 ~/.config/claude/claude_desktop_config.json 在Linux/macOS或 %APPDATA%\Claude\claude_desktop_config.json 在Windows上):

{
  "mcpServers": {
    "spacemolt-crafting": {
      "command": "/path/to/spacemolt-crafting-server/bin/crafting-server",
      "args": [
        "-db",
        "/path/to/spacemolt-crafting-server/database/crafting.db"
      ]
    }
  }
}

重要提示: 更新路径以匹配您的实际安装目录。

重新启动Claude代码

更新配置后,重新启动Claude Code以加载MCP服务器。然后,服务器将可用于协助制作查询。

数据库

服务器使用SQLite进行快速、高效的食谱和技能查询:

  • 项目: 游戏目录中的527个项目定义
  • 食谱: SpaceMolt的531个食谱
  • 技能: 28技能定义
  • 数据库大小: ~500KB(基本)+市场数据变量
  • 查询性能: 典型1-5ms

模式

核心表

  • items -项目元数据(名称、类别、稀有性、base_value)
  • recipes -配方元数据
  • recipe_inputs -必填输入项(倒排索引)
  • recipe_outputs -配方输出项(支持多个输出)
  • skills -技能定义
  • skill_prerequisites -技能依赖性
  • skill_levels -每级XP阈值
  • stations -用于市场查询的站点信息
  • illegal_recipes -标有禁止理由和合法地点的非法食谱
  • category_priorities -配方类别的优先级分配

市场数据表

  • market_order_book -个人买卖订单(7天保留期)

- 存储原始订单数据,包括价格、数量、站点、时间戳 - 用于复杂的价格计算 - 7天后自动修剪

  • market_price_stats -预先计算的市场统计数据

- representative_price -采用混合定价法计算 - stat_method -volume_weighted、second_price、median或msrp_only - sample_count -计算中使用的订单数量 - total_volume -总交易量 - confidence_score -数据质量指标(0.0-1.0) - min_price, max_price, stddev -价格分布指标

  • market_prices -传统价格数据(向后兼容性)
  • market_price_summary -遗留汇总摘要

定价方法

服务器根据市场特征自动选择最佳定价算法:

方法条件用例置信度
体积加权10+订单和50K+数量或100K+数量淹没市场(矿石)0.95(高)
第二次价格拍卖3+订单正常流动性0.75(中等)
中位数1+订单稀疏数据,单笔订单0.50(中低)
仅限MSRP0个订单无市场数据0.0(无)

例子: 22个订单总计134133个单位的铁矿石使用体积加权平均值,给予大量订单(128700@30cr)适当的权重,同时忽略异常值(999cr)。

查询示例

我能做什么?(有市场意识的利润分析)

{
  "method": "tools/call",
  "params": {
    "name": "craft_query",
    "arguments": {
      "components": [
        {"id": "ore_copper", "quantity": 50}
      ],
      "limit": 10
    }
  }
}

增强对市场数据的响应:

{
  "profit_analysis": {
    "output_sell_price": 5000,
    "input_cost": 3200,
    "profit_per_unit": 1800,
    "profit_margin_pct": 36.0,
    "msrp": 4500,
    "market_status": "high_confidence",
    "pricing_method": "volume_weighted",
    "sample_count": 247,
    "total_volume_24h": 125000
  }
}

HTTP API使用情况

提交市场数据

curl -X POST http://localhost:8080/api/v1/market/submit \
  -H "Content-Type: application/json" \
  -d '{
    "station_id": "Grand Exchange Station",
    "empire_id": "empire_123",
    "source": "manual_scan",
    "orders": [
      {
        "item_id": "ore_iron",
        "order_type": "sell",
        "price_per_unit": 30,
        "volume_available": 128700,
        "player_stall_name": "IronMiner42"
      }
    ]
  }'

答复:

{
  "batch_id": "batch_20260228_150405",
  "orders_received": 1,
  "orders_accepted": 1,
  "orders_rejected": 0
}

查询市场价格

curl http://localhost:8080/api/v1/market/price/ore_iron

答复:

{
  "item_id": "ore_iron",
  "sell_price": 29,
  "buy_price": 25,
  "msrp": 1,
  "method_name": "volume_weighted"
}

管理员:手动重新计算

curl -X POST http://localhost:8080/api/v1/admin/market/recalc/ore_iron

答复:

{
  "status": "success",
  "item_id": "ore_iron",
  "station": "Grand Exchange Station"
}

物料清单

{
  "method": "tools/call",
  "params": {
    "name": "bill_of_materials",
    "arguments": {
      "recipe_id": "craft_scanner_1",
      "quantity": 1
    }
  }
}

食谱市场盈利能力

按利润排序,获得所有食谱的市场盈利能力。根据当前市场数据或MSRP显示哪些产品最有利可图。

基本用法(仅限MSRP)

{
  "method": "tools/call",
  "params": {
    "name": "recipe_market_profitability",
    "arguments": {}
  }
}

答复:

{
  "recipes": [
    {
      "recipe_id": "build_quantum_shield",
      "recipe_name": "Build Quantum Entanglement Shield",
      "output_sell_price": 750000,
      "output_msrp": 750000,
      "output_uses_msrp": true,
      "input_cost": 182000,
      "input_uses_msrp": true,
      "profit": 568000,
      "profit_margin_pct": 312.1
    }
  ],
  "total_recipes": 531
}

市场数据

{
  "method": "tools/call",
  "params": {
    "name": "recipe_market_profitability",
    "arguments": {
      "station_id": "Grand Exchange Station"
    }
  }
}

有库存支持

指定库存中已有的项目。该工具将把您拥有的物品的投入成本设置为0,根据您需要购买的物品显示真实利润。

{
  "method": "tools/call",
  "params": {
    "name": "recipe_market_profitability",
    "arguments": {
      "station_id": "Grand Exchange Station",
      "components": [
        {"id": "ore_iron", "quantity": 1000},
        {"id": "ore_copper", "quantity": 500}
      ]
    }
  }
}

库存如何影响利润计算:

  • 完整库存: 如果您有≥所需数量,成本=0(您已经拥有它)
  • 部分库存: 如果你有一些但不够,成本=价格×短缺
  • 无库存: 所需数量的全价

例子: 一个食谱需要10个5克拉的ore_iron:

  • 库存为0时:输入成本=50cmr
  • 库存中有5个:input_cost=25cr(只需多支付5个)
  • 库存中有10+:input_cost=0cr(你有足够的库存)

这使得能够根据您的实际库存,而不仅仅是理论市场成本,准确计算盈利能力。

建筑

cmd/crafting-server/       # Main entry point
cmd/test-tools/            # MCP tool integration tests
pkg/crafting/              # Public domain types
internal/
  ├── api/                 # HTTP API server and handlers
  └── crafting/
      ├── db/              # Database layer (SQLite)
      │   └── migrations/  # Database schema migrations
      ├── engine/          # Query business logic
      ├── mcp/             # MCP protocol
      └── sync/            # Data import from catalog JSON

关键组件

  • internal/api/ -用于市场数据的HTTP服务器API

- 市场数据提交端点 - 价格查询端点 - 管理员重新计算端点 - 优雅的关机和超时处理

  • **internal/crafting/db/market*.go** -市场数据管理

- MarketStore用于订单簿和价格统计 - 采用混合定价算法的统计计算器 - 订单提交后自动重新计算 - 旧订单修剪(7天保留期)

  • internal/crafting/db/migrations/ -数据库版本控制

- 迁移005:增强的市场表 - 自动迁移应用程序 - 架构版本跟踪

依赖项

  • 去: 1.24或更高版本
  • 外部: modernc.org/sqlite (纯Go SQLite驱动程序)
  • 标准库: 上下文、数据库/sql、编码/json、日志/slog

发展

构建

go build ./cmd/crafting-server

测试

单元测试

go test ./...

MCP工具集成测试

test-tools 命令为所有6个MCP工具提供了各种场景的全面测试:

# Build and run comprehensive tool tests
go run ./cmd/test-tools

# Or build and run directly
go build -o bin/test-tools ./cmd/test-tools
./bin/test-tools

# Show full output (not elided)
./bin/test-tools -v

测试内容:

  • 所有6个MCP工具(工艺查询、工艺路径、回收查找、组件使用、物料清单、回收市场适用性)
  • 无效输入(不存在的ID、负数、空参数)
  • 简单查询(具有通用值的基本用法)
  • 复杂场景(可选参数、库存支持、优化策略)

棉绒

golangci-lint run

配置

命令行选项:

-db string
    Path to SQLite database (default "data/crafting/crafting.db")
-http string
    Start HTTP server on specified address (e.g., ":8080")
    When set, server runs in HTTP mode instead of MCP mode
-import-items string
    Import items from JSON file
-import-recipes string
    Import recipes from JSON file
-import-skills string
    Import skills from JSON file
-import-market string
    Import market data from JSON file
-game-version string
    Set game server version (e.g., "0.271.3")
-version
    Show database version information and exit
-verbose
    Enable verbose logging

HTTP服务器配置

在HTTP模式下运行时(-http :8080),服务器使用这些超时:

  • 读取超时: 10秒
  • 写入超时: 10秒
  • 关机超时: 5秒(优雅关机)

数据格式

导入程序接受平面JSON数组和目录信封格式({"items": [...], "total": N}).

项目JSON(目录格式)

{
  "items": [
    {
      "id": "ore_copper",
      "name": "Copper Ore",
      "description": "Common metallic ore.",
      "category": "ore",
      "rarity": "common",
      "size": 1,
      "base_value": 10,
      "stackable": true,
      "tradeable": true
    }
  ]
}

配方JSON(目录格式)

{
  "items": [
    {
      "id": "craft_engine_core",
      "name": "Assemble Engine Core",
      "description": "Build propulsion system cores.",
      "category": "Components",
      "crafting_time": 10,
      "inputs": [
        {"item_id": "refined_alloy", "quantity": 3},
        {"item_id": "ore_cobalt", "quantity": 4}
      ],
      "outputs": [
        {"item_id": "comp_engine_core", "quantity": 1}
      ]
    }
  ]
}

技能JSON(目录格式)

{
  "items": [
    {
      "id": "armor_advanced",
      "name": "Advanced Armor",
      "description": "Expert armor plating.",
      "category": "Combat",
      "max_level": 10,
      "training_source": "Take hull damage in combat.",
      "required_skills": {"armor": 5},
      "xp_per_level": [500, 1500, 3000, 5000, 8000, 12000, 17000, 23000, 30000, 40000],
      "bonus_per_level": {"armorEffectiveness": 2, "hullHP": 3}
    }
  ]
}

演出

  • 查询速度: 典型查询为1-5ms
  • 数据库大小: ~500KB(基本)+市场数据变量

- 基础:527个项目,531个食谱,28个技能 - 市场数据:每份订单约1KB(保留7天)

  • 二进制大小: ~10MB
  • 内存使用情况: 约5MB典型(MCP模式),约10MB(HTTP模式)
  • HTTP API: 处理1000+并发提交
  • 市场统计数据计算: 典型项目\<50ms

市场数据集成指南

数据库迁移

服务器使用自动数据库迁移来管理架构更新:

  • 迁移005: 增强的市场表(订单簿、价格统计)
  • 迁移在服务器启动时自动运行
  • 在中跟踪迁移状态 schema_migrations 桌子
  • 与现有数据库向后兼容

查看应用的迁移:

sqlite3 crafting.db "SELECT * FROM schema_migrations ORDER BY applied_at;"

手动迁移控制:

服务器会自动处理迁移,但您可以验证架构版本:

./bin/crafting-server -db crafting.db -version

建立市场数据收集

  1. 启动HTTP服务器:
./bin/crafting-server -db crafting.db -http :8080
  1. 提交市场数据:

使用游戏的 view_market 命令输出或手动扫描站市场:

import requests
import json

# From view_market.json
market_data = {
    "station_id": "Grand Exchange Station",
    "empire_id": "your_empire_id",
    "orders": [
        {
            "item_id": item["item_id"],
            "order_type": "sell",
            "price_per_unit": order["price_each"],
            "volume_available": order["quantity"],
            "player_stall_name": order.get("source", "")
        }
        for item in view_market_data["items"]
        for order in item["sell_orders"]
    ]
}

response = requests.post(
    "http://localhost:8080/api/v1/market/submit",
    json=market_data
)
print(response.json())
  1. 制作查询价格:
# Get current price before crafting
curl http://localhost:8080/api/v1/market/price/comp_steel
  1. MCP工具自动使用市场数据:

所有返回的MCP工具 profit_analysis 现在包括:

  • 实际市场价格(不仅仅是MSRP)
  • 市场信心水平
  • 使用的定价方法
  • 样品计数(订单数量)

最佳实践

  1. 定期提交数据: 市价单7天后到期
  2. 提交买入和卖出订单: 了解完整的市场情况
  3. 使用唯一批次ID: 跟踪提交来源
  4. 优雅地处理错误: 检查 orders_rejected 作为回应
  5. 监控信心评分: 低置信度=不可靠的定价

MIT许可证-请参阅 许可证 文件

相关项目

作者

@rsned

致谢

摘录自 space很多 更好的模块化和独立维护项目。

目录标签

目录标签

HTMLClaude浏览器自动化本地部署工艺查询市场数据集成智能定价游戏资源管理HTTPAPI

支持客户端

Claude

接入字段

传输方式(transport,传输协议)

未说明

鉴权方式(authType,认证方式)

none

工具数量(toolCount,工具数)

6

资源数量(resourceCount,资源数)

0

提示词数量(promptCount,提示词数)

0

权限和风险

未说明none部署方式未说明

接入前请确认传输方式、认证方式和部署位置,并根据实际工具能力限制访问范围。

安装前确认

不要直接授予不必要的文件、网络或账号权限;先核对安装命令和配置内容。

仍需确认:installCommand

来源信息

继续浏览同类 MCP