Skip to main content
Glama
alicenjr

Dynamic Reincarnation Story

by alicenjr

handle_user_message

Processes user messages to route interactions and generate personalized reincarnation story paths based on choices and soul-searching questions.

Instructions

Main entry point - handle any user message and route accordingly

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
user_idYes
messageYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • main.py:163-200 (handler)
    The core handler implementation for the 'handle_user_message' tool. Decorated with @mcp.tool() for registration. Handles user messages by managing story state, checking triggers like 'Arise', routing based on story progress (path selection, guidance questions, etc.), and delegating to other story functions.
    @mcp.tool()
    def handle_user_message(user_id: str, message: str) -> str:
        """Main entry point - handle any user message and route accordingly"""
        state = get_user_state(user_id)
        message_lower = message.strip().lower()
        
        # Check for "Arise" trigger to start the story
        if message_lower == "arise" and not state["story_started"]:
            state["story_started"] = True
            state["current_context"] = "User invoked 'Arise' to begin reincarnation"
            return str(arise_trigger_response()) + "\n\n" + str(initial_reincarnation_offer())
        
        # If story hasn't started yet, prompt user to begin
        if not state["story_started"]:
            return """
    I sense a lost soul seeking purpose... If you wish to begin your journey of reincarnation, 
    speak the word "Arise" and we shall commence.
    
    Otherwise, tell me what brings you to this realm between life and death.
    """
        
        # Route based on current story state
        if not state["current_path"]:
            # Story started but no path chosen yet
            if "question" in message_lower or "answer" in message_lower:
                return str(three_guidance_questions())
            elif any(str(i) in message_lower for i in [1, 2, 3]):
                # User might be trying to choose a path directly
                return "Please first answer the three guidance questions so I can understand your soul's true desires, then I will help you choose the perfect path."
            else:
                return str(initial_reincarnation_offer()) + "\n\n" + "Would you like me to ask the three guidance questions to help you choose your path?"
        
        # If we have a path but no introduction yet
        if state["current_path"] and state["story_step"] == 0:
            return generate_path_introduction(user_id)
        
        # Normal story progression
        return process_user_input(user_id, message)
  • Input schema defined by type hints: user_id (str), message (str) with return type str.
    def handle_user_message(user_id: str, message: str) -> str:
  • main.py:163-163 (registration)
    The @mcp.tool() decorator registers the function as an MCP tool named 'handle_user_message'.
    @mcp.tool()
  • main.py:12-24 (helper)
    Helper function get_user_state used by handle_user_message to retrieve or initialize per-user story state.
    def get_user_state(user_id: str) -> Dict[str, Any]:
        """Get or create user story state"""
        if user_id not in story_states:
            story_states[user_id] = {
                "current_path": None,
                "story_step": 0,
                "choices_made": [],
                "user_answers": {},
                "last_narrative": "",
                "current_context": "",
                "story_started": False
            }
        return story_states[user_id]
Behavior2/5

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

With no annotations provided, the description carries full burden but fails to disclose key behavioral traits. It mentions routing but doesn't explain what that entails (e.g., side effects, permissions, rate limits, or response format). For a tool with an output schema, it doesn't hint at return values, leaving the agent uncertain about the operation's impact.

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 appropriately sized and front-loaded with 'Main entry point,' but it's under-specified rather than concise. The two phrases are efficient with zero waste, earning a high score for structure, though the content is lacking.

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

Completeness2/5

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

Given the tool's complexity as a routing entry point, no annotations, 0% schema coverage, and an output schema, the description is incomplete. It doesn't explain the routing logic, prerequisites, or how it interacts with sibling tools, leaving significant gaps for the agent despite the output schema's existence.

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?

Schema description coverage is 0%, so the description must compensate but adds no meaning beyond the schema. It doesn't explain what 'user_id' or 'message' represent, their formats, or constraints. With 2 undocumented parameters, this is inadequate, as the description fails to provide any parameter context.

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

Purpose2/5

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

The description 'Main entry point - handle any user message and route accordingly' is tautological with the tool name 'handle_user_message' and only vaguely states what the tool does. It mentions routing but doesn't specify what resources or systems are involved, nor does it differentiate from sibling tools like 'process_user_input' or 'ask_guidance_questions'.

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 minimal guidance by calling this the 'main entry point,' implying it should be used first, but offers no explicit when-to-use rules, no exclusions, and no comparison to alternatives like 'process_user_input' or 'start_story.' This leaves the agent with unclear direction on tool selection.

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/alicenjr/Dynamic-Reincarnation-mcp'

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