forked from chigwell/telegram-mcp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
67 lines (46 loc) · 1.93 KB
/
Copy pathmain.py
File metadata and controls
67 lines (46 loc) · 1.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
"""Compatibility entrypoint for the Telegram MCP server.
The implementation lives in the telegram_mcp package. This module keeps the
historic `main` import path and console script target working.
"""
from telegram_mcp.install_guard import UnsafeInstallationError, assert_safe_distribution
try:
assert_safe_distribution()
except UnsafeInstallationError as exc:
raise SystemExit(str(exc)) from None
from telegram_mcp import runtime as _runtime
from telegram_mcp.runtime import *
from telegram_mcp.runner import _main, main
from telegram_mcp.tools import *
# Backward-compatible alias for callers/tests that monkeypatch main.SERVER_ALLOWED_ROOTS.
SERVER_ALLOWED_ROOTS = _runtime.SERVER_ALLOWED_ROOTS
def _sync_runtime_roots() -> None:
_runtime.SERVER_ALLOWED_ROOTS = SERVER_ALLOWED_ROOTS
async def _get_effective_allowed_roots(ctx):
_sync_runtime_roots()
return await _runtime._get_effective_allowed_roots(ctx)
async def _get_effective_allowed_roots_with_status(ctx):
_sync_runtime_roots()
return await _runtime._get_effective_allowed_roots_with_status(ctx)
async def _ensure_allowed_roots(ctx, tool_name):
_sync_runtime_roots()
return await _runtime._ensure_allowed_roots(ctx, tool_name)
async def _resolve_readable_file_path(*, raw_path, ctx, tool_name):
_sync_runtime_roots()
return await _runtime._resolve_readable_file_path(
raw_path=raw_path,
ctx=ctx,
tool_name=tool_name,
)
async def _resolve_writable_file_path(*, raw_path, default_filename, ctx, tool_name):
_sync_runtime_roots()
return await _runtime._resolve_writable_file_path(
raw_path=raw_path,
default_filename=default_filename,
ctx=ctx,
tool_name=tool_name,
)
def _configure_allowed_roots_from_cli(argv=None) -> None:
_runtime._configure_allowed_roots_from_cli(argv)
globals()["SERVER_ALLOWED_ROOTS"] = _runtime.SERVER_ALLOWED_ROOTS
if __name__ == "__main__":
main()