astrology-mcp

astrology-mcp

MCP server for astrological calculations including natal charts, planetary positions, aspects, transits, and progressions using Swiss Ephemeris.

Category
访问服务器

README

Astrology MCP Tool

A Python-based astrology calculation tool using Swiss Ephemeris for use with MCP servers and local LLMs.

Features

  • Natal Chart Calculation: Calculate complete birth charts with planetary positions, houses, and angles
  • Planetary Positions: Get current positions of all planets including Mercury through Pluto
  • Aspect Calculations: Calculate planetary aspects (conjunction, square, opposition, trine, sextile)
  • Transit Analysis: Track transiting planets and their aspects to natal positions
  • Progressions: Solar arc progressions for forecasting

Supported House Systems

  • Whole Sign (default) - Each house corresponds to a full zodiac sign
  • Placidus, Equal House, Koch, Porphyry, and Regiomontanus available

Installation

Using a Virtual Environment (Recommended)

# Create and activate a virtual environment
python -m venv .venv
source .venv/bin/activate

# Install dependencies
pip install -r requirements.txt

System-wide Installation (Not Recommended)

# Install dependencies globally
pip install -r requirements.txt

Swiss Ephemeris Setup

Swiss Ephemeris requires ephemeris files for accurate calculations. Download the free ephemeris files:

  1. Visit https://www.astro.com/swisseph/
  2. Download sweph_01.zip through sweph_06.zip
  3. Extract to a directory (e.g., ~/ephe)

The ephemeris files will be automatically detected or you can set the path explicitly.

Usage

Basic Example

from astrology.charts.chart import calculate_natal_chart
from datetime import datetime, timezone

# Create a chart for July 20, 2024 at 14:30 in New York
chart = calculate_natal_chart(
    birth_datetime=datetime(2024, 7, 20, 14, 30),
    latitude=40.7128,
    longitude=-74.0060
)

# Access chart data
print(f"Sun: {chart.get_planet_sign('SUN')} {chart.get_planet_degree('SUN')}°")
print(f"Ascendant: {chart.ascendant.sign_name} {chart.ascendant.degree_in_sign}°")

# Get planetary positions
for planet, position in chart.planets.items():
    print(f"{planet.name}: {position.longitude.sign_name} {position.longitude.degree_in_sign}°")

# Get house positions
for planet, house in chart.house_positions.items():
    print(f"{planet.name} is in House {house}")

With Timezone Support

The library handles timezone-aware datetimes automatically. For accurate results, include timezone information in your datetime strings:

from datetime import datetime, timezone, timedelta

# PDT (UTC-7) - California daylight saving time
birth_dt = datetime(1984, 5, 10, 20, 44, tzinfo=timezone(timedelta(hours=-7)))
chart = calculate_natal_chart(
    birth_datetime=birth_dt,
    latitude=34.0211,
    longitude=-118.3965
)

# Or use ISO format with timezone offset
chart = calculate_natal_chart(
    birth_datetime=datetime.fromisoformat("1984-05-10T20:44:00-07:00"),
    latitude=34.0211,
    longitude=-118.3965
)

Note: Without timezone info, the library assumes input is in local time and converts it to UTC. For the most accurate results, always include timezone information.

Using with Any MCP Client

The server uses the Model Context Protocol (MCP) and can be integrated with any MCP-compatible client.

Quick Start:

  1. Copy mcp.json from this project to your MCP client's configuration directory
  2. Restart or reload your MCP client

Manual Setup:

# Activate virtual environment first
source /path/to/astrology-mcp/.venv/bin/activate

# Run the server
python -m astrology_mcp_server.main

The server communicates via stdio, so any MCP client that supports stdio transport can use it.

Available tools:

  • get_current_time - Get the current UTC date and time
  • calculate_natal_chart - Calculate a complete birth chart (birth_datetime with timezone recommended)
  • get_planet_positions - Get current planetary positions
  • calculate_aspects - Calculate planetary aspects between chart objects
  • calculate_transits - Get current transits to a natal chart
  • get_houses - Get house positions for planets

Important: For accurate natal charts, provide birth datetime with timezone.

Project Structure

astrology-mcp/
├── src/
│   ├── astrology_mcp_server/
│   │   └── main.py            # MCP server entry point
│   └── astrology/
│       ├── __init__.py
│       ├── core/
│       │   ├── calendar.py    # Date/time handling
│       │   ├── ephemeris.py   # Planet positions
│       │   └── aspects.py     # Aspect calculations
│       ├── charts/
│       │   └── chart.py       # Natal chart calculation
│       ├── transits/
│       │   └── transit.py     # Transit calculations
│       └── progressions/
│           └── solar_arc.py   # Progression calculations
└── tests/

Development

# Ensure virtual environment is activated
source .venv/bin/activate

# Run tests
python -m pytest tests/

# Install in development mode
pip install -e .

# Run example natal chart (with your birth data)
python my_natal_chart.py

Troubleshooting

Incorrect Chart Results

If your chart shows incorrect planet signs or house positions:

  1. Check timezone handling: Ensure your datetime has proper timezone info

    from datetime import datetime, timezone, timedelta
    
    # Include timezone offset for accurate conversion to UTC
    dt = datetime.fromisoformat("1984-05-10T20:44:00-07:00")  # PDT
    
    chart = calculate_natal_chart(
        birth_datetime=dt,
        latitude=34.0211,
        longitude=-118.3965
    )
    
  2. Verify ephemeris files: Make sure Swiss Ephemeris files are downloaded and accessible

  3. Check house system: Verify you're using the correct house system (default is Whole Sign)

License

This project is licensed under the MIT License - see the LICENSE file for details.

Note: This project uses Swiss Ephemeris, which is available under a dual license (AGPL or Commercial). See the LICENSE file for full details and attribution requirements.

Using with LM Studio

LM Studio is a popular interface for running local LLMs and integrating MCP servers.

Setup:

  1. Copy mcp.json from this project to your LM Studio MCP config directory (typically ~/.lmstudio/mcp.json)
  2. Restart LM Studio

Example configuration:

{
  "mcpServers": {
    "astrology": {
      "command": "/path/to/astrology-mcp/.venv/bin/python",
      "args": [
        "-c",
        "import sys; sys.path.insert(0, '/path/to/astrology-mcp/src'); import astrology_mcp_server.main; astrology_mcp_server.main.main()"
      ]
    }
  }
}

Available tools in LM Studio:

  • get_current_time - Get the current UTC date and time
  • calculate_natal_chart - Calculate a complete birth chart (birth_datetime with timezone recommended)
  • get_planet_positions - Get current planetary positions
  • calculate_aspects - Calculate planetary aspects between chart objects
  • calculate_transits - Get current transits to a natal chart
  • get_houses - Get house positions for planets

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选