Skip to main content
Glama
alicenjr

Dynamic Reincarnation Story

by alicenjr

handle_user_message

Process user messages to guide interactive reincarnation storytelling, routing responses based on character choices and narrative paths for personalized adventure experiences.

Instructions

Main entry point - handle any user message and route accordingly

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
messageYes
user_idYes

Implementation Reference

  • main.py:163-201 (handler)
    The @mcp.tool()-decorated function that implements the 'handle_user_message' tool logic. It manages the user's story state, handles the 'Arise' trigger, routes messages based on story progress, and delegates to other functions for narrative generation.
    @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)

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