Skip to main content
Glama
ZoezoeCookie

mcp-luopan

by ZoezoeCookie

mcp-luopan

Verwandelt "Luopan" – eine Horoskopberechnung basierend auf der Ziping Zhenquan-Methode – in eine MCP-Tool-Sammlung (Model Context Protocol). Damit kann jeder MCP-Client (Claude Code / Claude Desktop / OpenClaw / Cursor / selbst entwickelte LLM-Agenten) im Dialog Horoskope für Benutzer erstellen, lesen und Folgefragen beantworten.

Der Cloud-Einstiegspunkt ist bereits live: https://luopan.caihangao.com. MCP verweist standardmäßig darauf, ist sofort einsatzbereit und erfordert keinen lokalen Server.


Welches Problem wird gelöst?

LLMs können von sich aus keine Bazi-Berechnungen durchführen. Es ist falsch, das Modell direkt auf Basis von Trainingswissen "Horoskope analysieren" zu lassen – Himmelsstämme, Erdzweige, Monatsregenten, Zehn-Götter-Konstellationen und Strukturanalysen sind rein regelbasierte Berechnungen, die von einer spezialisierten Engine durchgeführt werden müssen.

mcp-luopan kapselt die gesamte Engine (Berechnung → Zehn Götter → Struktur → Glückssäulen → Bericht → Folgefragen) in 3 MCP-Tools. Das LLM erfindet nichts mehr, sondern:

  1. Erhält präzise Horoskopdaten (Vier Säulen / Struktur / Glückssäulen / Fünf Elemente / Zehn Götter)

  2. Formuliert Sprache basierend auf echten Daten (Die Fähigkeit, Geschichten zu erzählen, liegt beim LLM, die Fakten bei der Engine)

  3. Unterstützt kontextbezogene Folgefragen (5 Folgefragen / 2 Stunden TTL, verwaltet durch Backend-Session)


Related MCP server: Chinese Fortune Analysis System (BaZi)

Typische Anwendungsfälle

Szenario A: Analyse für einen Freund in Claude Code / Claude Desktop

Du (Benutzer):

Analysiere bitte einen Jungen, der am 15. März 1991 um 5 Uhr morgens geboren wurde, und schau dir die Struktur und die Karriere für dieses Jahr an.

Claude automatisch:

  1. Ruft luopan_analyze(year=1991, month=3, day=15, hour=5, gender=1) auf → erhält session_id und das vollständige Horoskop

  2. Übersetzt "Zheng-Guan-Struktur / Tian-Cheng / Trend der Glückssäulen / Partnerprofil" in natürliche Sprache für dich

  3. Du fragst nach "Karriere dieses Jahr" → Claude ruft luopan_chat(session_id, "Karriere dieses Jahr") auf → erhält eine Antwort, die spezifisch für dieses eine Horoskop ist

Du musst während des gesamten Prozesses keine Fachbegriffe verstehen oder JSON sehen.

Szenario B: Stapelanalyse

Du möchtest eine "Verteilung der Strukturen von 100 Prominenten" auswerten:

# 伪代码:让一个 Agent 循环调用
for person in people:
    chart = call_tool("luopan_analyze", **person.birth_info)
    record(person.name, chart["pattern"]["final_pattern"])

Die Engine läuft in der Cloud und belastet nicht deine lokale CPU; das Skript kümmert sich nur um die IO-Orchestrierung.

Szenario C: Einbettung in OpenClaw / Feishu Agent

Registriere luopan in der mcp.json von OpenClaw und autorisiere einen Agenten (z. B. einen Feishu-Bot) für diese 3 Tools. Der Agent kann dann im Feishu-Dialog Horoskope für Benutzer erstellen und Folgefragen beantworten. Die lokale OpenClaw-Instanz läuft bereits nach diesem Muster; die Cloud-Bereitstellung für OpenClaw ist noch TODO.

Szenario D: LLM Eval / Prompt Engineering Experimente

Du möchtest verschiedene Sprachstile von Modellen bei der Horoskopdeutung testen oder ein "Luopan-Persona" für einen Agenten einstellen – das Backend liefert immer dieselben Fakten, die Modellunterschiede zeigen sich vollständig auf der Ebene der natürlichen Sprache.


Quick Start: In 60 Sekunden einsatzbereit

1. Installation

git clone <this-repo> /Users/Neil/Projects/mcp-servers/mcp-luopan
cd /Users/Neil/Projects/mcp-servers/mcp-luopan
uv venv && uv pip install -e .

Oder mit einer normalen venv:

python3 -m venv .venv && source .venv/bin/activate
pip install -e .

Nach der Installation ist mcp-luopan ausführbar (unter .venv/bin/).

2. Rauchtest (Verifizierung ohne MCP-Host)

echo '{"jsonrpc":"2.0","id":1,"method":"tools/list"}' | .venv/bin/mcp-luopan

Erwarte die Anzeige von 3 Tools: luopan_analyze / luopan_chat / luopan_session_info.

3. Registrierung bei einem MCP-Host

Claude Code (derzeit am häufigsten)

Bearbeite ~/.claude.json oder die projektbezogene .mcp.json:

{
  "mcpServers": {
    "luopan": {
      "command": "/Users/Neil/Projects/mcp-servers/mcp-luopan/.venv/bin/mcp-luopan",
      "env": {
        "LUOPAN_API_BASE": "https://luopan.caihangao.com",
        "LUOPAN_TIMEOUT_SECONDS": "60"
      }
    }
  }
}

Starte Claude Code neu, öffne eine neue Sitzung und sage einfach "Benutze Luopan, um mir ein Horoskop zu erstellen", dann wird das Tool aufgerufen.

OpenClaw (lokal oder Cloud)

Füge es zu ~/.openclaw/mcp.json hinzu:

"luopan": {
  "command": "/Users/Neil/Projects/mcp-servers/mcp-luopan/.venv/bin/mcp-luopan",
  "env": {
    "LUOPAN_API_BASE": "https://luopan.caihangao.com",
    "LUOPAN_TIMEOUT_SECONDS": "60"
  }
}

Damit ein Agent es nutzen kann, muss tools.allow nicht explizit luopan_* auflisten – OpenClaw erlaubt standardmäßig allen Agenten den Zugriff auf alle Server in der mcp.json.

Claude Desktop

Bearbeite ~/Library/Application Support/Claude/claude_desktop_config.json, die Struktur ist identisch.


Semantik der drei Tools

Alle Tools geben JSON-Strings zurück. Bei Fehlern wird {"error": "...", "hint": "..."} zurückgegeben, ohne Exceptions an das LLM zu werfen.

luopan_analyze(year, month, day, hour, gender)

Vollständige Horoskopanalyse – ein Aufruf liefert alle Informationen. Vor dem Aufruf muss: das Geburtsdatum (gregorianisch), die Geburtsstunde (0-23) und das Geschlecht (1=männlich / 0=weiblich) mit dem Benutzer bestätigt werden.

Zurückgegebene Felder (Auszug):

Feld

Inhalt

session_id

12-stellige Kurz-ID für nachfolgende luopan_chat-Aufrufe

sizhu

Vier Säulen (Himmelsstämme/Erdzweige von Jahr/Monat/Tag/Stunde)

pattern

Strukturbestimmung (z. B. "Zheng-Guan-Struktur / Tian-Cheng / followup_remaining=5")

report

Drei-Ebenen-Deutung (Karte Tier1 / Detail Tier2 / Technik Tier3)

dayun

Zeitachse der Glückssäulen + 5-stufige Glücks-/Unglücksbewertung

highlights

Horoskop-Highlights (13 Regeln, Seltenheit 1-3)

partner

Profil des komplementären Partners (38 Unterstrukturen × 3 Status-Mappings)

female

Spezifisch für weibliche Horoskope (Ehemann-Stern/Kind-Stern/Ehe-Palast, nur wenn gender=0)

wuxing / shishen

Statistik der Fünf Elemente / Zehn-Götter-Beziehungen

followup_remaining

Verbleibende Anzahl an Folgefragen (Standard 5)

luopan_chat(session_id, question)

Folgefragen zu einem bestehenden Horoskop. Muss innerhalb von 2 Stunden und maximal 5 Mal erfolgen.

Antwort (standardisiert):

{
  "answer": "AI 的回答文本",
  "followup_remaining": 4,
  "followup_count": 1,
  "max_followups": 5,
  "session_id": "..."
}

Wenn followup_remaining == 0 oder session_expired zurückgegeben wird, muss zwingend luopan_analyze für ein neues Horoskop aufgerufen werden.

luopan_session_info(session_id)

Optimistische Abfrage des Session-Status – kein Backend-Aufruf. Das Backend hat keine separate Session-Status-Schnittstelle; die verbindliche Prüfung erfolgt über Fehlermeldungen von luopan_chat. Dieses Tool dient als Hilfsmittel für Agenten, um lokal zu "erinnern", ob eine Session abgelaufen ist.


Konfigurationsparameter

Umgebungsvariable

Standardwert

Beschreibung

LUOPAN_API_BASE

http://127.0.0.1:8000

Backend-Adresse. Für Cloud empfohlen: https://luopan.caihangao.com; für lokales Debugging: http://127.0.0.1:8000 mit uvicorn

LUOPAN_TIMEOUT_SECONDS

60

HTTP-Timeout. KI-Analysen dauern gelegentlich 30s+, Puffer einplanen

LUOPAN_HTTP_RETRIES

1

Anzahl der Wiederholungsversuche bei kurzzeitigen Netzwerkstörungen


Beispiel für einen vollständigen LLM-Dialog

Unten ist die Sequenz der Tool-Aufrufe, die das LLM automatisch generieren sollte (du musst nur normal kommunizieren):

[user] 我哥 1985 年 8 月 12 日中午 12 点出生,男的,最近老换工作,帮我看看是不是格局问题?

[assistant] (调用 luopan_analyze year=1985 month=8 day=12 hour=12 gender=1)
[tool result]
  session_id=a1b2c3d4e5f6
  pattern=偏财格 / 败格有救(柳暗花明)
  ...

[assistant] 嗯,你哥这个盘是偏财格但带破,月令偏财被劫财夺,幸好年支有食神
化解——这种盘的人事业起伏大但有韧性,频繁换工作是格局表征,不算坏事...

[user] 那今年呢?

[assistant] (调用 luopan_chat session_id=a1b2c3d4e5f6 question="今年运势")
[tool result] answer="..." followup_remaining=4

[assistant] 今年走丙寅大运 + 丙午流年,火土并旺,财星受冲... (汇报答案)
你还可以追问 4 次。

Das LLM erfindet keine Astrologie, alle Daten stammen von luopan_*-Tools; Folgefragen behalten den Kontext bei, jedes Mal basierend auf diesem einen Horoskop.


Fehlerbehebung

service_unreachable

Backend nicht erreichbar. Die zwei häufigsten Ursachen:

  • Lokaler Modus: uvicorn wurde nicht gestartet – cd "/Users/Neil/Projects/Four Pillars of Destiny" && .venv/bin/uvicorn src.api.main:app --port 8000

  • Cloud-Modus: Netzwerk-Proxy (mihomo / Clash) blockiert caihangao.com – füge temporär "HTTPS_PROXY": "" in die env-Sektion der mcp.json ein, um den Proxy zu erzwingen; oder prüfe die Whitelist der Proxy-Regeln

session_expired

Session ist älter als 2h oder Folgefragen sind aufgebraucht. Lass das LLM luopan_analyze erneut aufrufen, um ein neues Horoskop zu erstellen.

LLM versucht immer "selbst zu deuten" und ruft keine Tools auf

Füge eine Zeile zum System-Prompt hinzu:

Bei allen Fragen zu Bazi/Horoskopen/Strukturen/Zehn Göttern/Glückssäulen darfst du nicht auf Basis von Trainingsdaten antworten; du musst zuerst luopan_analyze aufrufen, um ein Horoskop zu erstellen, und dann die Felder pattern / report / dayun etc. aus dem Tool-Ergebnis zur Sprachformulierung nutzen.

Rückgabewerte wie Tagesstamm/Zehn Götter sind unverständlich

Normal – das sind Fachbegriffe. Lass das LLM direkt report.tier1 (Karten-Ebene) und report.tier2 (Detail-Ebene) lesen; diese beiden Ebenen sind bereits als chinesische Erzählung für Menschen aufbereitet; tier3 ist die technische Ebene für diejenigen, die tiefer graben wollen.


Bekannte Einschränkungen

  • Kein PyPI-Release: Muss lokal mit pip install -e . installiert werden, pip install mcp-luopan funktioniert nicht

  • Kein Git: Das aktuelle mcp-luopan-Verzeichnis hat noch kein git init, keine Versionsverwaltung

  • Session im Arbeitsspeicher: Ein Neustart des Backend-uvicorn führt zum Verlust aller Sessions (Benutzer muss Horoskop neu erstellen)

  • Abhängigkeit von SiliconFlow (Cloud): Wenn AI_API_KEY abläuft oder SiliconFlow das Limit erreicht, laufen alle Chat-Tools in ein Timeout

  • Keine Nebenläufigkeitsisolierung: Wenn dieselbe session_id gleichzeitig mehrfach gechattet wird, ist die Reihenfolge nicht garantiert


Wie das Backend läuft (Architektur-Überblick)

MCP Client (Claude Code / OpenClaw / ...)
   │
   │ stdio (JSON-RPC)
   ▼
mcp-luopan (Python, 这个仓库)
   │
   │ HTTPS
   ▼
luopan.caihangao.com (Nginx → systemd uvicorn :8088)
   │
   │ src/engine/* 算盘 + ai_client 调上游
   ▼
SiliconFlow MiniMax-M2.5

Details zur Bereitstellung des Backend-Dienstes siehe Upstream-Projekt: Four Pillars of Destiny / docs/design/deployment.md.

Available Tools

2 tools
luopan_analyzeA

Produce a full destiny-chart reading for a birth moment.

IMPORTANT: Before calling, you MUST confirm with the user:

  • solar calendar date (阳历): year / month / day

  • birth hour 0-23 (时辰),if unsure warn them the reading will be less precise

  • gender: 1 for 男, 0 for 女

Output contains: session_id (used for follow-ups), sizhu (the chart), pattern (格局), report (a three-tier reading), dayun (luck pillars), highlights (notable traits), partner (气场画像), female (if gender=0), and followup_remaining (starts at 5).

When presenting to the user, translate technical terms (e.g. 十神, 格局名称) into plain language like "气场 / 画像 / 此局". The public persona is 罗盘 (fengshui compass), never expose the words 八字 / 子平.

Sessions expire in 2 hours and allow up to 5 follow-up questions via luopan_chat.

Args: year: Birth year, e.g. 1991 month: Birth month 1-12 day: Birth day 1-31 hour: Birth hour 0-23 gender: 1 = 男, 0 = 女

ParametersJSON Schema
NameRequiredDescriptionDefault
yearYes
monthYes
dayYes
hourYes
genderYes

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

A4.9/5.0
Behavior5/5

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

Despite no annotations, the description fully discloses behavioral traits: outputs, session expiration (2 hours), follow-up limit (5), and presentation instructions (translate terms, use persona).

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?

Well-structured with clear sections (title, note, output, presentation, session info). Slightly lengthy but every sentence adds value; no wasted words.

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

Completeness5/5

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

Given the output schema exists, the description still adds valuable context about follow-ups, session expiration, and output fields. No notable gaps.

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?

Schema description coverage is 0%, but the description explains all 5 parameters with examples and ranges (e.g., year e.g. 1991, month 1-12, day 1-31, hour 0-23, gender 1=男, 0=女). This adds complete meaning beyond the schema.

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

Purpose5/5

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

The description clearly states it produces a full destiny-chart reading for a birth moment. It distinguishes from the sibling tool luopan_chat by mentioning follow-up capability.

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

Usage Guidelines5/5

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

Explicitly lists pre-call confirmations required from the user, warns about less precise hour, and explains session expiration and follow-up limit. Provides clear guidance on when to use this tool vs luopan_chat.

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

luopan_chatA

Ask a follow-up question against an existing chart-reading session.

Session_id comes from a prior luopan_analyze call. The backend enforces a 2-hour TTL and a 5-question cap; when either is hit, call luopan_analyze again to open a new session.

Returns (normalized): answer: the AI reply text followup_remaining: questions you still have left after this one followup_count: questions used so far (incl. this one) max_followups: hard cap (5) session_id: echoed back

When followup_remaining == 0 or this call returns session_expired, the next turn must call luopan_analyze to open a fresh session. When followup_remaining == 1, warn the user before they spend it.

Args: session_id: The session_id returned by luopan_analyze question: The user's follow-up question (specific events / years / topics yield better answers than vague "is my fate good")

ParametersJSON Schema
NameRequiredDescriptionDefault
session_idYes
questionYes

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

A5/5.0
Behavior5/5

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

With no annotations, the description fully discloses behavior: backend-enforced limits, return fields with meanings, and lifecycle management. It clearly states what happens when limits are hit, meeting the full burden for behavioral transparency.

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

Conciseness5/5

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

The description is well-structured: purpose statement, runtime constraints, structured return fields, and actionable usage notes. Each sentence earns its place; no redundancy.

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

Completeness5/5

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

Given the output schema not provided as structured input, the description enumerates return fields and their meanings. It fully explains the session lifecycle, restrictions, and expected behavior, providing complete context for an AI to use the tool correctly within the sibling ecosystem.

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?

Schema coverage is 0%, so description must add meaning. It explains session_id comes from prior luopan_analyze, and question provides usage tips ('specific events/years/topics yield better answers'). This adds significant value beyond the bare schema.

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

Purpose5/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: 'Ask a follow-up question against an existing chart-reading session.' It specifies the resource (session) and verb (ask), and distinguishes from sibling tool luopan_analyze, which starts new sessions.

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

Usage Guidelines5/5

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

Explicitly guides when to use (follow-up questions) and when not to (session expired or followup_remaining==0, then call luopan_analyze). It also details constraints (2-hour TTL, 5-question cap) and gives actionable advice (warn user when remaining==1).

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

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

  1. 2 tool updatesv0.1.0
    • First observedluopan_analyze
    • First observedluopan_chat

TDQS

A5/5.0

Scored across 2 tools

Disambiguation5/5

The two tools have clearly distinct purposes: one creates a new chart-reading session, the other handles follow-up questions within an existing session. There is no overlap or ambiguity.

Naming Consistency5/5

Both tools follow a consistent verb_noun pattern with the prefix 'luopan_' (luopan_analyze, luopan_chat) in snake_case, making them predictable and easy to understand.

Tool Count5/5

With only 2 tools, the server is tightly scoped to its purpose: initial analysis and follow-up chat. No unnecessary tools exist, and the count is perfect for the functionality provided.

Completeness5/5

The tool set covers the complete lifecycle: creating a session with a full chart reading and asking up to 5 follow-up questions. No obvious gaps exist for the intended domain.

Maintenance

ActivityInactive
ResponsivenessNo issues

Related MCP Connectors

Related MCP Servers

  • A
    license
    A
    quality
    B
    maintenance
    Enables AI tools to perform Chinese fortune-telling analysis including Ziwei Doushu (Purple Star Astrology) and Bazi (Four Pillars) chart generation, fortune reading, and element analysis. Supports multiple calendar systems and output formats for comprehensive divination services.
    7
    8 npm
    6
    MIT
  • A
    license
    Not graded
    quality
    D
    maintenance
    Enables traditional Chinese fortune-telling through BaZi (Four Pillars) analysis, including solar/lunar date conversion, Five Element balance calculations, Ten Gods deduction, and destiny interpretation for metaphysics applications.
    23 npm
    MIT
  • A
    license
    Not graded
    quality
    D
    maintenance
    Provides accurate Chinese Bazi (八字) fortune-telling calculations including birth chart analysis, destiny forecasting, and Chinese calendar information. Addresses inaccuracies in existing AI fortune-telling tools by delivering precise Bazi data for personality analysis and metaphysical insights.
    343 npm
    ISC
  • A
    license
    A
    quality
    C
    maintenance
    Enables AI agents to perform Chinese metaphysics calculations including BaZi charts, Tong Shu indicators, solar terms, and more, using a verified engine with 740+ tests.
    8
    8
    MIT