使用说明
保诚集团
MCP服务器 繁荣的宇宙 游戏数据通过FIO API。
概述
这是一个 模型上下文协议(MCP) 提供访问Prosperous Universe游戏数据工具的服务器。它使用 FIO REST API 以获取实时游戏信息。
安装
需要Python 3.11+和 紫外线.
# Clone the repository (includes submodules)
git clone --recurse-submodules <repo-url>
cd prun-mcp
# Or if already cloned without submodules:
git submodule update --init
# Install dependencies
uv sync
注: 此MCP服务器使用来自的内容 fnar/prun社区衍生力学 作为游戏力学公式的git子模块。
关于toon格式的说明
此项目使用 toon-python 用于TOON序列化(与JSON相比,令牌减少30-60%)。该库直接从GitHub安装,因为PyPI版本(v0.1.0)有一个未实现的编码器。这是在中配置的 pyproject.toml 通过 [tool.uv.sources].
用法
本地
uv run prun-mcp
码头工人
# Build the image
docker build -t prun-mcp:latest .
# Run with STDIO transport
docker run -i prun-mcp:latest
Claude代码配置
添加服务器(本地):
claude mcp add prun-mcp -- uv run --directory /path/to/prun-mcp prun-mcp
添加服务器(Docker):
claude mcp add prun-mcp -- docker run -i prun-mcp:latest
管理命令:
claude mcp list # List configured servers
claude mcp remove prun-mcp # Remove the server
手动配置
或者,添加到MCP客户端配置中(~/.claude.json):
{
"mcpServers": {
"prun-mcp": {
"command": "uv",
"args": ["run", "--directory", "/path/to/prun-mcp", "prun-mcp"]
}
}
}
或者使用Docker:
{
"mcpServers": {
"prun-mcp": {
"command": "docker",
"args": ["run", "-i", "prun-mcp:latest"]
}
}
}
可用工具
| 类别 | 工具 | 文档 |
|---|---|---|
| 材料 | get_material_info, refresh_materials_cache, get_all_materials |
文档/工具/材料.md |
| 建筑物 | get_building_info, refresh_buildings_cache, search_buildings |
docs/tools/buildings.md |
| 行星 | get_planet_info, search_planets |
docs/tools/planets.md |
| 食谱 | get_recipe_info, search_recipes, refresh_recipes_cache |
docs/tools/recipes.md |
| 交易所 | get_exchange_prices, get_exchange_all |
docs/tools/exchange.md |
| 市场分析 | get_market_summary, analyze_fill_cost, get_price_history_summary, get_order_book_depth, get_price_history |
docs/tools/market_analysis.md |
| 齿轮 | calculate_cogm |
docs/tools/cogm.md |
| 允许I/O | calculate_permit_io, calculate_building_cost |
docs/tools/permit_io.md |
| 基础平面图 | save_base_plan, get_base_plan, list_base_plans, delete_base_plan, calculate_plan_io |
docs/tools/base_plans.md |
可用资源
| URI | 描述 |
|---|---|
exchange://list |
列出所有商品交易所的代码和名称 |
workforce://types |
按层级顺序列出员工类型(先锋→ 科学家) |
workforce://habitation |
列出具有劳动力容量的居住建筑 |
buildings://efficiency |
建筑效率公式和因素概述 |
buildings://efficiency/workforce |
员工满意度对效率的影响 |
buildings://efficiency/experts |
专家奖金制度(高达~28.4%) |
buildings://efficiency/cogc |
CoGC广告计划奖金(高达25%) |
buildings://efficiency/condition |
建筑状况和维护 |
pct-mechanics://list |
可用游戏机制主题列表 |
pct-mechanics://arc |
ARC水平公式 |
pct-mechanics://building-degradation |
建筑条件和维修成本公式 |
pct-mechanics://hq |
总部升级成本和效率公式 |
pct-mechanics://planet |
行星资源开采公式 |
pct-mechanics://population-infrastructure |
人口需求、幸福和增长 |
pct-mechanics://ship-blueprints |
船舶建造公式和部件体积 |
pct-mechanics://workforce |
劳动力效率公式 |
配置
| 环境变量 | 描述 | 默认值 |
|---|---|---|
PRUN_MCP_CACHE_DIR |
缓存文件目录(材料、建筑、配方) | cache (相对于工作目录) |
发展
# Install dev dependencies
uv sync
# Run tests
PYTEST_DISABLE_PLUGIN_AUTOLOAD="" uv run pytest
# Lint and format
uv run ruff check .
uv run ruff format .
# Type check
uv run pyright
项目结构
prun-mcp/
├── data/
│ └── community-mechanics/ # Git submodule: FNAR community-derived game mechanics
├── src/prun_mcp/
│ ├── __init__.py
│ ├── app.py # FastMCP instance
│ ├── server.py # Entry point
│ ├── fio/ # FIO API client
│ │ ├── __init__.py
│ │ ├── client.py # HTTP client for FIO API
│ │ └── exceptions.py # Custom exceptions
│ ├── cache/ # JSON-based caching layer (24h TTL)
│ │ ├── __init__.py
│ │ ├── materials_cache.py
│ │ ├── buildings_cache.py
│ │ ├── recipes_cache.py
│ │ └── workforce_cache.py
│ ├── models/ # Pydantic models for type safety
│ │ ├── __init__.py
│ │ ├── fio.py # FIO API response models
│ │ └── domain.py # Domain output models (COGM, BuildingCost, etc.)
│ ├── prun_lib/ # Business logic layer (reusable as standalone library)
│ │ ├── __init__.py # Public API exports
│ │ ├── exceptions.py # Unified exception classes
│ │ ├── building.py # Building cost calculations
│ │ ├── cogm.py # COGM (Cost of Goods Manufactured) calculations
│ │ ├── market.py # Market analysis logic
│ │ ├── base_io.py # Base I/O calculations
│ │ ├── exchange.py # Exchange validation and data fetching
│ │ └── ... # Additional business logic modules
│ ├── storage/ # Persistent storage
│ │ ├── __init__.py
│ │ ├── base_plan_storage.py # Base plan JSON storage
│ │ └── validation.py # Plan validation rules
│ ├── resources/ # Static reference data (MCP resources)
│ │ ├── __init__.py
│ │ ├── buildings.py # Building efficiency documentation
│ │ ├── exchanges.py # Exchange data resource
│ │ ├── extraction.py # Extraction building constants
│ │ ├── mechanics.py # Community mechanics resources
│ │ └── workforce.py # Workforce types and habitation
│ └── tools/ # Thin MCP tool wrappers
│ ├── __init__.py
│ ├── materials.py # Material-related tools
│ ├── buildings.py # Building-related tools
│ ├── planets.py # Planet-related tools
│ ├── recipes.py # Recipe-related tools
│ ├── exchange.py # Exchange/pricing tools
│ ├── market_analysis.py # Market analysis tools
│ ├── cogm.py # COGM calculation tool
│ ├── building_cost.py # Building cost calculation tool
│ ├── permit_io.py # Permit I/O calculation tool
│ ├── base_plans.py # Base plan management tools
│ └── info.py # Server info tools (version, cache status)
架构说明: 工具是“超薄”包装器,用于验证输入,委托给 prun_lib 用于业务逻辑,并使用TOON对输出进行序列化。这种分离允许 prun_lib 作为繁荣宇宙计算的独立库。
许可证
麻省理工学院