This repository has been archived on 2026-07-19. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
shira-hermes/mcp_server/tools/_helpers.py
T
chaim 6f7b94d6f8 feat: initial shira-hermes service
Shira AI backend using OpenAI-compatible agent with tool-calling loop,
replacing the smart-assistant route in ai-gateway.

Components:
- FastAPI adapter (same HTTP contract as ai-gateway)
- Agent runner with agentic tool-calling loop via ai-gateway /v1/chat/completions
- EspoCRM REST API client
- 20 MCP tools (CRM, documents, legal assistance)
- Prompt builder ported from ai-gateway JS to Python
- SOUL.md personality definition
- Dockerfile for Coolify deployment

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-13 17:29:35 +00:00

38 lines
1019 B
Python

"""Shared helper functions for MCP tools."""
from __future__ import annotations
import re
def normalize_date(date_str: str | None, default_time: str = "08:00:00") -> str | None:
"""Normalize various date formats to YYYY-MM-DD HH:mm:ss."""
if not date_str:
return None
# DD/MM/YYYY or DD-MM-YYYY or DD.MM.YYYY
m = re.match(r"^(\d{1,2})[/\-.](\d{1,2})[/\-.](\d{4})(?:\s+(.+))?$", date_str)
if m:
base = f"{m.group(3)}-{m.group(2).zfill(2)}-{m.group(1).zfill(2)}"
return f"{base} {m.group(4) or default_time}"
# YYYY-MM-DD
if re.match(r"^\d{4}-\d{2}-\d{2}$", date_str):
return f"{date_str} {default_time}"
# YYYY-MM-DD HH:mm
if re.match(r"^\d{4}-\d{2}-\d{2}\s+\d{2}:\d{2}$", date_str):
return f"{date_str}:00"
return date_str
def ok(message: str) -> str:
"""Return a success message."""
return message
def fail(message: str) -> str:
"""Return an error message (prefixed for visibility)."""
return f"{message}"