Skip to main content
Glama
takada-at

Fortune MCP Server

by takada-at

get_horoscope

Calculate personalized horoscopes for a specified date, time, and location. Use input parameters like datetime, latitude, and longitude to generate astrological insights tailored to individual preferences.

Instructions

ホロスコープを計算して返します

Args:
    datetime_str: 計算する日時(YYYY-MM-DD HH:MM:SS形式、省略時は現在時刻)
    random_time: ランダムな日時でホロスコープを生成するか
    latitude: 緯度(デフォルト: 東京)
    longitude: 経度(デフォルト: 東京)

Returns:
    ホロスコープの結果

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
datetime_strNo
latitudeNo
longitudeNo
random_timeNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The complete handler for the 'get_horoscope' tool. It is registered via the @mcp.tool() decorator and implements horoscope calculation including planetary longitudes, ascendant, MC, and major aspects using the swisseph library. Supports custom datetime, random time, and location.
    @mcp.tool()
    def get_horoscope(
        datetime_str: str = None,
        random_time: bool = False,
        latitude: float = 35.6895,
        longitude: float = 139.6917
    ) -> str:
        """ホロスコープを計算して返します
        
        Args:
            datetime_str: 計算する日時(YYYY-MM-DD HH:MM:SS形式、省略時は現在時刻)
            random_time: ランダムな日時でホロスコープを生成するか
            latitude: 緯度(デフォルト: 東京)
            longitude: 経度(デフォルト: 東京)
        
        Returns:
            ホロスコープの結果
        """
        try:
            # 日時の取得
            jst = pytz.timezone('Asia/Tokyo')
            
            if random_time:
                year = random.randint(1900, 2100)
                month = random.randint(1, 12)
                day = random.randint(1, 28)
                hour = random.randint(0, 23)
                minute = random.randint(0, 59)
                second = random.randint(0, 59)
                jst_dt = jst.localize(datetime(year, month, day, hour, minute, second))
            elif datetime_str:
                try:
                    dt = datetime.strptime(datetime_str, '%Y-%m-%d %H:%M:%S')
                    jst_dt = jst.localize(dt)
                except ValueError:
                    try:
                        dt = datetime.strptime(datetime_str, '%Y-%m-%d')
                        jst_dt = jst.localize(dt)
                    except ValueError:
                        return "エラー: 日時は 'YYYY-MM-DD HH:MM:SS' または 'YYYY-MM-DD' 形式で指定してください"
            else:
                utc_dt = datetime.now(pytz.utc)
                jst_dt = utc_dt.astimezone(jst)
            
            # UTCに変換
            utc_dt = jst_dt.astimezone(pytz.utc)
            
            # ユリウス日の計算
            jd = swe.julday(utc_dt.year, utc_dt.month, utc_dt.day,
                           utc_dt.hour + utc_dt.minute / 60)
            
            # 天体の定義
            planets = {
                '太陽': swe.SUN,
                '月': swe.MOON,
                '水星': swe.MERCURY,
                '金星': swe.VENUS,
                '火星': swe.MARS,
                '木星': swe.JUPITER,
                '土星': swe.SATURN,
                '天王星': swe.URANUS,
                '海王星': swe.NEPTUNE,
                '冥王星': swe.PLUTO,
            }
            
            zodiac_signs = [
                ('牡羊座♈', 0),
                ('牡牛座♉', 30),
                ('双子座♊', 60),
                ('蟹座♋', 90),
                ('獅子座♌', 120),
                ('乙女座♍', 150),
                ('天秤座♎', 180),
                ('蠍座♏', 210),
                ('射手座♐', 240),
                ('山羊座♑', 270),
                ('水瓶座♒', 300),
                ('魚座♓', 330)
            ]
            
            # 天体位置の計算
            positions = {}
            for name, planet_id in planets.items():
                lon = swe.calc_ut(jd, planet_id)[0][0]
                positions[name] = lon
            
            # ハウスの計算
            _, asc_mc = swe.houses(jd, latitude, longitude, b'P')
            positions['アセンダント'] = asc_mc[0]
            positions['MC(天頂)'] = asc_mc[1]
            
            # 結果の整形
            result_text = f"🌟 ホロスコープ 🌟\n"
            result_text += f"日時: {jst_dt.strftime('%Y年%m月%d日 %H:%M:%S')} JST\n"
            result_text += f"場所: 緯度 {latitude:.4f}, 経度 {longitude:.4f}\n\n"
            
            result_text += "【天体位置】\n"
            for body, lon in positions.items():
                sign_index = int(lon / 30)
                sign_name = zodiac_signs[sign_index][0]
                degree_in_sign = lon % 30
                result_text += f"{body}: {sign_name} {degree_in_sign:.2f}°\n"
            
            # アスペクトの計算(主要なもののみ)
            result_text += "\n【主要アスペクト】\n"
            aspects_found = []
            planet_names = list(planets.keys())
            for i in range(len(planet_names)):
                for j in range(i + 1, len(planet_names)):
                    name1, name2 = planet_names[i], planet_names[j]
                    lon1, lon2 = positions[name1], positions[name2]
                    diff = abs(lon1 - lon2)
                    if diff > 180:
                        diff = 360 - diff
                    
                    # 主要アスペクトのチェック
                    if abs(diff - 0) <= 8:
                        aspects_found.append(f"{name1} - {name2}: コンジャンクション(0°)")
                    elif abs(diff - 60) <= 6:
                        aspects_found.append(f"{name1} - {name2}: セクスタイル(60°)")
                    elif abs(diff - 90) <= 8:
                        aspects_found.append(f"{name1} - {name2}: スクエア(90°)")
                    elif abs(diff - 120) <= 8:
                        aspects_found.append(f"{name1} - {name2}: トライン(120°)")
                    elif abs(diff - 180) <= 8:
                        aspects_found.append(f"{name1} - {name2}: オポジション(180°)")
            
            if aspects_found:
                for aspect in aspects_found[:10]:  # 最大10個まで表示
                    result_text += f"{aspect}\n"
            else:
                result_text += "主要アスペクトは検出されませんでした。\n"
            
            return result_text
            
        except Exception as e:
            return f"エラーが発生しました: {str(e)}"
  • The @mcp.tool() decorator registers the get_horoscope function as an MCP tool.
    @mcp.tool()
  • Input schema defined by function parameters with type annotations and detailed docstring describing arguments and return value.
    def get_horoscope(
        datetime_str: str = None,
        random_time: bool = False,
        latitude: float = 35.6895,
        longitude: float = 139.6917
    ) -> str:
        """ホロスコープを計算して返します
        
        Args:
            datetime_str: 計算する日時(YYYY-MM-DD HH:MM:SS形式、省略時は現在時刻)
            random_time: ランダムな日時でホロスコープを生成するか
            latitude: 緯度(デフォルト: 東京)
            longitude: 経度(デフォルト: 東京)
        
        Returns:
            ホロスコープの結果
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. While it mentions what the tool does (calculates horoscopes) and describes parameters, it doesn't disclose important behavioral traits like whether this is a read-only operation, what authentication might be needed, rate limits, error conditions, or what format the horoscope result takes. The description is minimal and lacks behavioral context.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is well-structured and appropriately sized. It starts with the core purpose, then provides a clear Args section with parameter explanations, and ends with Returns information. Every sentence earns its place, though the Japanese-only text might limit accessibility in some contexts. The structure is logical and efficient.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given that an output schema exists (though not shown), the description doesn't need to explain return values in detail. The description covers the purpose and all parameters comprehensively. For a calculation tool with 4 parameters and no annotations, this description provides good context, though it could benefit from more behavioral information about the calculation process itself.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

With 0% schema description coverage (titles only, no descriptions), the description provides excellent parameter semantics. It clearly explains all 4 parameters: datetime_str format and default behavior, random_time purpose, latitude/longitude defaults and reference location. This fully compensates for the schema's lack of descriptions and adds meaningful context beyond the bare schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'ホロスコープを計算して返します' (calculates and returns a horoscope). This is a specific verb+resource combination. However, it doesn't explicitly differentiate from the sibling tool 'draw_tarot', which appears to be a different type of divination tool. The purpose is clear but lacks sibling differentiation.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. There's no mention of the sibling tool 'draw_tarot' or any other context for choosing between horoscope calculation and tarot drawing. The only usage information is implicit in the parameter descriptions, but no explicit when/when-not guidance is provided.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/takada-at/fortune_mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server