Skip to main content
Glama

get_active_context

Retrieve the current graph and document IDs from a user's Mnemosyne session to identify what they are actively working on in the interface.

Instructions

Returns the currently active graph ID and document ID from the user's session. Use this to understand what the user is currently working on in the Mnemosyne UI. The user_id is automatically derived from authentication if not provided.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
user_idNo

Implementation Reference

  • The core handler function `get_active_context_tool` decorated with `@server.tool(name="get_active_context")`. This defines and registers the tool, implementing logic to fetch active graph/document from Hocuspocus Y.js session.
    @server.tool( name="get_active_context", title="Get Active Graph and Document", description=( "Returns the currently active graph ID and document ID from the user's session. " "Use this to understand what the user is currently working on in the Mnemosyne UI. " "The user_id is automatically derived from authentication if not provided." ), ) async def get_active_context_tool( user_id: Optional[str] = None, context: Context | None = None, ) -> dict: """Get the active graph and document from session state.""" auth = MCPAuthContext.from_context(context) token = auth.require_auth() # Auto-derive user_id if not provided if not user_id: # Try auth context first, then token user_id = auth.user_id or (get_user_id_from_token(token) if token else None) if not user_id: raise RuntimeError( "Could not determine user ID. Either provide it explicitly or " "ensure your token contains a 'sub' claim." ) try: await hp_client.ensure_session_connected(user_id) active_graph = hp_client.get_active_graph_id() active_doc = hp_client.get_active_document_id() session_snapshot = hp_client.get_session_snapshot() result = { "active_graph_id": active_graph, "active_document_id": active_doc, "session": session_snapshot, } return result except Exception as e: logger.error( "Failed to get active context", extra_context={"error": str(e)}, ) raise RuntimeError(f"Failed to get active context: {e}")
  • Invocation of `register_hocuspocus_tools(mcp_server)` in `create_standalone_mcp_server()`, which executes the tool decorators to register `get_active_context` on the MCP server instance.
    register_hocuspocus_tools(mcp_server)

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/sophia-labs/mnemosyne-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server