feat: initial commit from workspace-mcp
Some checks failed
Check Maintainer Edits Enabled / check-maintainer-edits (pull_request) Has been cancelled
Check Maintainer Edits Enabled / check-maintainer-edits-internal (pull_request) Has been cancelled
Docker Build and Push to GHCR / build-and-push (pull_request) Has been cancelled
Ruff / ruff (pull_request) Has been cancelled

This commit is contained in:
2026-03-17 19:23:33 -05:00
commit 395f0e2029
138 changed files with 41691 additions and 0 deletions

43
core/context.py Normal file
View File

@@ -0,0 +1,43 @@
# core/context.py
import contextvars
from typing import Optional
# Context variable to hold injected credentials for the life of a single request.
_injected_oauth_credentials = contextvars.ContextVar(
"injected_oauth_credentials", default=None
)
# Context variable to hold FastMCP session ID for the life of a single request.
_fastmcp_session_id = contextvars.ContextVar("fastmcp_session_id", default=None)
def get_injected_oauth_credentials():
"""
Retrieve injected OAuth credentials for the current request context.
This is called by the authentication layer to check for request-scoped credentials.
"""
return _injected_oauth_credentials.get()
def set_injected_oauth_credentials(credentials: Optional[dict]):
"""
Set or clear the injected OAuth credentials for the current request context.
This is called by the service decorator.
"""
_injected_oauth_credentials.set(credentials)
def get_fastmcp_session_id() -> Optional[str]:
"""
Retrieve the FastMCP session ID for the current request context.
This is called by authentication layer to get the current session.
"""
return _fastmcp_session_id.get()
def set_fastmcp_session_id(session_id: Optional[str]):
"""
Set or clear the FastMCP session ID for the current request context.
This is called when a FastMCP request starts.
"""
_fastmcp_session_id.set(session_id)