Skip to main content
Glama
d4nshields

Bibliomantic MCP Server

i_ching_divination

Perform I Ching divination using the traditional three-coin method with changing lines to receive philosophical guidance through traditional Chinese wisdom.

Instructions

Enhanced I Ching divination with traditional three-coin method and changing lines. MAINTAINS EXACT BACKWARD COMPATIBILITY while providing richer content.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • Primary handler function for the i_ching_divination tool, decorated with @mcp.tool(). Executes the divination by calling BiblioManticDiviner.perform_simple_divination() and formats the response.
    @mcp.tool()
    def i_ching_divination(query: Optional[str] = None) -> str:
        """
        Perform I Ching divination using traditional three-coin method.
        
        Generates a random hexagram with interpretation for guidance.
        Uses cryptographically secure randomness to simulate coin tosses.
        
        Args:
            query: Optional question or context for the divination
            
        Returns:
            Formatted hexagram reading with interpretation
        """
        logger.info("Performing I Ching divination")
        
        result = diviner.perform_simple_divination()
        
        if result["success"]:
            response = f"""🎋 **I Ching Divination**
    
    **Hexagram {result['hexagram_number']}: {result['hexagram_name']}**
    
    {result['interpretation']}
    
    *Generated using traditional three-coin method with cryptographically secure randomness.*
    *This follows the authentic I Ching methodology as described in ancient Chinese divination.*"""
    
            if query:
                response += f"\n\n**Your Question:** {query}"
                response += f"\n\n**Guidance:** Consider how this hexagram's wisdom applies to your specific situation."
            
            logger.info(f"Generated hexagram {result['hexagram_number']} - {result['hexagram_name']}")
            return response
        else:
            error_msg = f"Divination failed: {result.get('error', 'Unknown error')}"
            logger.error(error_msg)
            return error_msg
  • Handler variant with ethical disclaimers. Similar logic to primary handler.
    @mcp.tool()
    def i_ching_divination(query: Optional[str] = None) -> str:
        """
        Perform I Ching divination using traditional three-coin method.
        
        Generates a random hexagram with interpretation for philosophical guidance.
        Uses cryptographically secure randomness to simulate coin tosses.
        
        Args:
            query: Optional question or context for the divination
            
        Returns:
            Formatted hexagram reading with interpretation and ethical disclaimer
        """
        logger.info("Performing I Ching divination with ethical safeguards")
        
        result = diviner.perform_simple_divination()
        
        if result["success"]:
            response = f"""🎋 **I Ching Divination**
    
    **Hexagram {result['hexagram_number']}: {result['hexagram_name']}**
    
    {result['interpretation']}
    
    **Method:** Traditional three-coin method using cryptographically secure randomness
    **Purpose:** Philosophical reflection and contemplation
    
    {ETHICAL_DISCLAIMER}"""
    
            if query:
                response += f"\n\n**Your Question:** {query}"
                response += f"\n\n**Guidance:** Consider how this hexagram's wisdom might offer perspective on your situation, while remembering this is a tool for reflection, not prediction."
            
            logger.info(f"Generated hexagram {result['hexagram_number']} - {result['hexagram_name']} with ethical disclaimer")
            return response
        else:
            error_msg = f"Divination failed: {result.get('error', 'Unknown error')}"
            logger.error(error_msg)
            return f"{error_msg}\n\n{BRIEF_DISCLAIMER}"
  • Enhanced handler with additional features like changing lines and contextual guidance, falls back to basic.
    @mcp.tool()
    def i_ching_divination(query: Optional[str] = None) -> str:
        """
        Enhanced I Ching divination with traditional three-coin method and changing lines.
        MAINTAINS EXACT BACKWARD COMPATIBILITY while providing richer content.
        """
        logger.info("Performing enhanced I Ching divination")
        
        result = diviner.perform_simple_divination()
        
        if result["success"]:
            # Enhanced formatting while maintaining compatibility
            response = f"""🎋 **I Ching Divination**
    
    **Hexagram {result['hexagram_number']}: {result['hexagram_name']}**
    
    {result['interpretation']}
    
    **Method:** Traditional three-coin method using cryptographically secure randomness"""
    
            # Add enhanced features if available
            if result.get("enhanced") and result.get("changing_lines"):
                response += f"\n**Changing Lines:** {', '.join(map(str, result['changing_lines']))}"
            
            response += f"\n**Purpose:** Philosophical reflection and contemplation\n\n{ETHICAL_DISCLAIMER}"
    
            if query:
                response += f"\n\n**Your Question:** {query}"
                if ENHANCED_MODE and hasattr(diviner, 'enhanced_engine') and diviner.enhanced_engine:
                    # Add contextual guidance
                    context = diviner.enhanced_engine.infer_context_from_query(query)
                    contextual_guidance = diviner.enhanced_engine.get_contextual_interpretation(
                        result['hexagram_number'], context
                    )
                    response += f"\n\n**Contextual Guidance:** {contextual_guidance}"
                else:
                    response += f"\n\n**Guidance:** Consider how this hexagram's wisdom might offer perspective on your situation."
            
            logger.info(f"Generated enhanced hexagram {result['hexagram_number']} - {result['hexagram_name']}")
            return response
        else:
            error_msg = f"Divination failed: {result.get('error', 'Unknown error')}"
            logger.error(error_msg)
            return f"{error_msg}\n\n{BRIEF_DISCLAIMER}"
  • Core helper method in BiblioManticDiviner class that performs the simple divination by calling IChing.generate_hexagram_by_coins() and returns the result dictionary used by all handlers.
    def perform_simple_divination(self) -> dict:
        """
        Perform a standalone divination without query integration.
        
        Useful for testing the divination system or providing pure I Ching
        consultations without Claude integration.
        
        Returns:
            Dictionary containing complete divination information
        """
        try:
            hexagram_number, hexagram_name, interpretation = self.iching.generate_hexagram_by_coins()
            
            return {
                "success": True,
                "hexagram_number": hexagram_number,
                "hexagram_name": hexagram_name,
                "interpretation": interpretation,
                "formatted_text": self.iching.format_divination_text(
                    hexagram_number, hexagram_name, interpretation
                )
            }
            
        except Exception as e:
            logger.error(f"Simple divination failed: {str(e)}")
            return {
                "success": False,
                "error": str(e),
                "fallback_wisdom": "The path forward requires inner contemplation and patient observation."
            }
  • Core randomness and hexagram generation logic using cryptographically secure secrets module to simulate three-coin tosses, maps to hexagram from database.
    def generate_hexagram_by_coins(self) -> Tuple[int, str, str]:
        """
        Generate a hexagram using the traditional three-coin method.
        
        Simulates throwing three coins six times to generate six lines,
        building a hexagram from bottom to top as in traditional practice.
        
        Returns:
            Tuple containing (hexagram_number, name, interpretation)
        """
        lines = []
        
        # Generate six lines (bottom to top)
        for _ in range(6):
            # Throw three coins: heads = 3, tails = 2
            coin_sum = sum(3 if secrets.randbelow(2) else 2 for _ in range(3))
            
            # 6 or 9 are changing lines, but for simplicity we use stable lines
            # 6 (three tails) = yin line = 0
            # 9 (three heads) = yang line = 1
            # 7 (two tails, one head) = yang line = 1  
            # 8 (two heads, one tail) = yin line = 0
            if coin_sum in [6, 8]:  # Yin line
                lines.append('0')
            else:  # coin_sum in [7, 9] - Yang line
                lines.append('1')
        
        # Convert binary to hexagram number (1-64)
        binary_string = ''.join(reversed(lines))  # Traditional order: bottom to top
        hexagram_number = self._binary_to_hexagram_number(binary_string)
        
        hexagram_data = self.hexagrams[hexagram_number]
        return hexagram_number, hexagram_data["name"], hexagram_data["interpretation"]
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. It mentions 'enhanced' divination and 'richer content,' but doesn't disclose key behavioral traits such as whether it's read-only, if it has side effects, rate limits, or authentication needs. The backward compatibility note is useful but insufficient for a tool with no annotation coverage.

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 brief and front-loaded, with two sentences that convey the main points efficiently. There's no unnecessary verbosity, and each sentence adds value (method details and compatibility). However, it could be more structured with clearer separation of features.

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

Completeness3/5

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

Given the tool's complexity (divination with a method) and the presence of an output schema, the description covers the basic purpose and method. However, with no annotations and low parameter coverage, it lacks details on behavior and inputs. It's minimally adequate but has clear gaps in context.

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

Parameters2/5

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

The input schema has one parameter ('query') with 0% description coverage, and the tool description adds no information about parameters. It doesn't explain what the 'query' parameter is for, its format, or examples. With low schema coverage, the description fails to compensate, leaving parameters undocumented.

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

Purpose3/5

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

The description states the tool performs 'I Ching divination with traditional three-coin method and changing lines,' which provides a general purpose. However, it's somewhat vague about what 'enhanced' and 'richer content' mean, and it doesn't clearly differentiate from sibling tools like 'bibliomantic_consultation' or 'get_hexagram_details.' The mention of backward compatibility adds context but doesn't sharpen the core purpose.

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?

There is no guidance on when to use this tool versus alternatives like 'bibliomantic_consultation' or 'get_hexagram_details.' The description implies it's for I Ching divination but doesn't specify scenarios, prerequisites, or exclusions. Without explicit when/when-not instructions, it offers minimal usage direction.

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

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/d4nshields/bibliomantic-mcp-server'

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