Kuk1's picture
Deploy Echo Universal Host
85dd3af
import logging
from mcp.server.fastmcp import FastMCP
from services.mcp_server.core.config import load_config
from services.mcp_server.core.actions import perform_voice_notify
# Configure logging
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger("agentbell.mcp")
# Create FastMCP server
mcp = FastMCP("AgentBell")
@mcp.tool()
def voice_notify(text: str) -> str:
"""
Speak a message to the user via local audio.
Use this tool to act as a "Voice Companion" for the user.
You should narrate your key steps, status, and requests for attention.
USAGE PROTOCOL:
1. WHEN TO SPEAK:
- **Before Actions**: BEFORE running terminal commands, editing files, or calling other tools, speak a concise summary of what you are about to do.
- **Start of Task**: When receiving a new request, briefly acknowledge the plan.
- **End of Task**: When a task is complete, summarize the result.
- **Blocks/Confirmations**: If an action might require user approval (e.g. `rm`, `install`), you MUST speak BEFORE calling that tool.
2. CONTENT GUIDELINES:
- **Language**: ALWAYS match the language of the user's last message/prompt.
- **Style**: Human-like, concise (5-15 words), intelligent summary.
- **Forbidden**: Do NOT read raw filenames, paths, URLs, or code blocks. Use general terms.
3. CRITICAL TIMING (PREVENT DEADLOCKS):
- You MUST call `voice_notify`, **WAIT** for it to return, and ONLY THEN call the subsequent action tool.
- **NEVER** call `voice_notify` and a blocking tool (like `run_terminal_cmd`) in the same parallel execution block.
"""
logger.info(f"AgentBell triggered: {text}")
config = load_config()
try:
return perform_voice_notify(text, config)
except RuntimeError as e:
return f"Error: {e}"
except Exception as e:
return f"Error playing voice: {e}"
if __name__ == "__main__":
mcp.run()