Add user-bound external MCP server and OAuth access
This commit is contained in:
@@ -22,6 +22,10 @@ PROTOCOL_VERSION = "2025-06-18"
|
||||
|
||||
|
||||
def _user_tab() -> tuple[str, str]:
|
||||
from mcp_context import current_tool_context
|
||||
bound = current_tool_context()
|
||||
if bound is not None:
|
||||
return bound.username, bound.tab_id
|
||||
return (
|
||||
os.environ.get("SMETA_USER", "").strip(),
|
||||
os.environ.get("SMETA_TAB", "default").strip() or "default",
|
||||
@@ -37,6 +41,12 @@ def _work_dir(user: str, tab: str) -> Path:
|
||||
|
||||
Иначе — DATA_DIR/user/tab (как на хосте main-приложения).
|
||||
"""
|
||||
from mcp_context import current_tool_context
|
||||
bound = current_tool_context()
|
||||
if bound is not None:
|
||||
if (user, tab) != (bound.username, bound.tab_id):
|
||||
raise PermissionError("MCP context does not own this work directory")
|
||||
return bound.work_dir
|
||||
direct = os.environ.get("SMETA_WORK_DIR")
|
||||
if direct:
|
||||
return Path(direct)
|
||||
|
||||
Reference in New Issue
Block a user