astro-mcp
astro-mcp
占星 MCP 服务器 — 为 LLM 代理提供高精度占星工具。
实现了 14 个工具,基于 Swiss Ephemeris(pyswisseph),并可与任何 Model Context Protocol 客户端(如 Claude Desktop 等)集成。
工具
# | 名称 | 描述 |
1 |
| 完整本命盘:行星、角度、宫位、相位 |
2 |
| 行运相位对本命盘、月相、朔望和月亮空亡 |
3 |
| 一天代表一年的推进 + 太阳弧 |
4 |
| 年度太阳回归盘 |
5 |
| 根据生活事件对候选出生时间进行评分 |
6 |
| 月度月亮回归盘 |
7 |
| 跨盘相位 + 宫位叠加 |
8 |
| 中点或戴维森组合盘 |
9 |
| 年度推进——年主星和激活的宫位 |
10 |
| 任意日期/地点的24个行星时 |
11 |
| 12个阿拉伯点/宿(福点、精神点、婚姻点等) |
12 |
| 日期范围内的行星位置表 |
13 |
| 查找特定相位的精确日期 |
14 |
| 映点和反映点,可选行运接触 |
Related MCP server: auseklis
安装
# 1. Clone
git clone https://github.com/DrewCyber/astro-mcp
cd astro-mcp
# 2. Create virtual environment
python3.11 -m venv .venv
source .venv/bin/activate
# 3. Install package + dev dependencies
pip install -e ".[dev]"
# 4. Download Swiss Ephemeris data files
bash scripts/download_ephe.sh
# 5. Set environment variable
export EPHE_PATH="$(pwd)/ephe"
# 6. Run tests
pytest tests/Claude Desktop 配置
添加到 ~/Library/Application Support/Claude/claude_desktop_config.json:
{
"mcpServers": {
"astro": {
"command": "/path/to/astro-mcp/.venv/bin/python",
"args": ["-m", "astro_mcp"],
"env": {
"EPHE_PATH": "/path/to/astro-mcp/ephe",
"GEOCODING_PROVIDER": "nominatim",
"GEOCODING_USER_AGENT": "astro-mcp/1.0",
"LOG_LEVEL": "WARNING"
}
}
}
}环境变量
变量 | 默认值 | 描述 |
|
| Swiss Ephemeris |
|
|
|
| — | 如果 |
|
| Nominatim 用户代理 |
|
| 地理编码结果的 LRU 缓存大小 |
|
| 持久化地理编码缓存,使查询在重启后仍然有效。仅存储城市 → 纬度/经度/时区。设置为空以禁用 |
|
|
|
|
| 全局容许度乘数(0.1–3.0) |
|
|
|
|
| Python 日志级别 |
架构
src/astro_mcp/
├── server.py # MCP server — tool registration and dispatch
├── schemas.py # Pydantic input models (source of the JSON schemas)
├── config.py # Settings from environment variables
├── core/
│ ├── models.py # Data models and astrological constants
│ ├── errors.py # AstroError and the structured error codes
│ ├── ephemeris_provider.py # Swiss Ephemeris wrapper (pyswisseph)
│ ├── geocoding.py # City → lat/lon/tz (geopy + timezonefinder)
│ ├── moon.py # Lunar phase, lunations and void-of-course
│ └── formatters.py # LLM-optimized serialization
└── tools/
├── natal.py # Tool 1
├── transits.py # Tool 2
├── progressions.py # Tool 3
├── returns.py # Tools 4 + 6
├── rectification.py # Tool 5
├── synastry.py # Tools 7 + 8
├── profections.py # Tool 9
├── planetary_hours.py # Tool 10
├── arabic_parts.py # Tool 11
├── ephemeris.py # Tools 12 + 13
└── antiscia.py # Tool 14输出格式
所有工具返回紧凑的 JSON,不带空白,以最小化 LLM 上下文令牌(比冗长 JSON 小约 75%)。行星代码缩写(Su、Mo、Me 等),相位使用 3 字母代码(Cnj、Tri、Squ),并且当行星顺行时省略逆行标志("R":true)以节省额外令牌。
失败也使用相同的契约,因此客户端无需解析散文:
{"error":true,"code":"INPUT_ERROR","message":"Invalid arguments for 'calculate_natal_chart'.","hint":"birth_location.lat: Input should be less than or equal to 90"}行星代码
各工具支持的代码:
Su太阳Mo月亮Me水星Ve金星Ma火星Ju木星Sa土星Ur天王星Ne海王星Pl冥王星Ch凯龙星Li暗月莉莉丝(平均远地点)NN北交点(默认为真实交点;当NODE_TYPE=mean时为平均交点)SN南交点小行星(支持
include_asteroids时):Ce谷神星,Pa智神星,Jun婚神星,Ves灶神星
API 说明
get_ephemeris接受单个planet或行星列表。get_ephemeris.step支持1h、2h、3h、6h、12h、1d、7d、30d。get_ephemeris现在返回timezone字段,并以output_tz格式化dt。find_aspect_exact_dates.mode支持:transit-to-transit用于两个移动天体transit-to-natal用于行运到本命行星/角度auto(默认)根据是否存在birth_*推断模式
测试
pytest tests/ -v --cov=src/astro_mcp --cov-report=term-missing黄金图表回归测试内联在测试套件中(tests/test_audit_regressions.py),并已针对 Astro.com 和 Solar Fire 进行验证。
许可证
MIT
This server cannot be deployed
Maintenance
Related MCP Connectors
Swiss Ephemeris for AI agents: exact natal charts, transits, synastry and birth-place resolution
Western natal charts, horoscopes, transits and synastry for AI agents, verified vs NASA JPL.
Real astrology for AI agents: cosmic weather, synastry, timing, astrocartography, and divination.
Vedic and Western astrology for AI agents: charts, dasha, matchmaking, panchanga, numerology, tarot.
Related MCP Servers
- FlicenseNot gradedqualityCmaintenanceMulti-tradition astrology engine that computes real birth charts, transits, and synastry for AI agents via MCP tools.8-
- AlicenseAqualityCmaintenanceAstrology MCP server that computes natal charts, transits, synastry, progressions, returns, eclipses, retrogrades, and moon phases from a real ephemeris, enabling AI agents to provide accurate astrological calculations without hallucination.1261 npm1MIT
- AlicenseAqualityDmaintenanceCalculates astrological natal charts with high precision using Swiss Ephemeris, supporting multiple house systems and location inputs.218 npm5AGPL 3.0
- AlicenseAqualityAmaintenanceVedic and Western astrology for AI agents: 103 read-only tools for natal charts, dasha, kundali matching with Rajju and Vedha vetoes, panchanga, numerology and tarot, backed by Swiss Ephemeris and verified against NASA JPL Horizons.103MIT