|
@@ -1,7 +1,6 @@
|
|
|
from __future__ import annotations
|
|
from __future__ import annotations
|
|
|
|
|
|
|
|
import asyncio
|
|
import asyncio
|
|
|
-import hashlib
|
|
|
|
|
import logging
|
|
import logging
|
|
|
import subprocess
|
|
import subprocess
|
|
|
|
|
|
|
@@ -11,6 +10,7 @@ import time
|
|
|
from collections import Counter
|
|
from collections import Counter
|
|
|
from datetime import datetime, timezone
|
|
from datetime import datetime, timezone
|
|
|
from email.utils import parsedate_to_datetime
|
|
from email.utils import parsedate_to_datetime
|
|
|
|
|
+from pathlib import Path
|
|
|
|
|
|
|
|
from fastapi import FastAPI, Form
|
|
from fastapi import FastAPI, Form
|
|
|
from mcp.server.fastmcp import FastMCP
|
|
from mcp.server.fastmcp import FastMCP
|
|
@@ -44,14 +44,19 @@ logging.basicConfig(
|
|
|
|
|
|
|
|
_PROCESS_STARTED_AT = time.monotonic()
|
|
_PROCESS_STARTED_AT = time.monotonic()
|
|
|
|
|
|
|
|
-_VERSION_HASH = (
|
|
|
|
|
- subprocess.check_output(
|
|
|
|
|
- ["git", "rev-parse", "--short=9", "HEAD"],
|
|
|
|
|
- cwd=__file__,
|
|
|
|
|
|
|
+_REPO_ROOT = Path(__file__).resolve().parent
|
|
|
|
|
+try:
|
|
|
|
|
+ _VERSION_HASH = (
|
|
|
|
|
+ subprocess.check_output(
|
|
|
|
|
+ ["git", "rev-parse", "--short=9", "HEAD"],
|
|
|
|
|
+ cwd=str(_REPO_ROOT),
|
|
|
|
|
+ stderr=subprocess.DEVNULL,
|
|
|
|
|
+ )
|
|
|
|
|
+ .decode()
|
|
|
|
|
+ .strip()
|
|
|
)
|
|
)
|
|
|
- .decode()
|
|
|
|
|
- .strip()
|
|
|
|
|
-)
|
|
|
|
|
|
|
+except Exception:
|
|
|
|
|
+ _VERSION_HASH = "unknown"
|
|
|
|
|
|
|
|
mcp = FastMCP(
|
|
mcp = FastMCP(
|
|
|
"news-mcp",
|
|
"news-mcp",
|