obsidian-mcp-server
Version:
Obsidian Knowledge-Management MCP (Model Context Protocol) server that enables AI agents and development tools to interact with an Obsidian vault. It provides a comprehensive suite of tools for reading, writing, searching, and managing notes, tags, and fr
25 lines (24 loc) • 947 B
JavaScript
/**
* @fileoverview Defines the AsyncLocalStorage context for authentication information.
* This module provides a mechanism to store and retrieve authentication details
* (like scopes and client ID) across asynchronous operations, making it available
* from the middleware layer down to the tool and resource handlers without
* drilling props.
*
* @module src/mcp-server/transports/auth/core/authContext
*/
import { AsyncLocalStorage } from "async_hooks";
/**
* An instance of AsyncLocalStorage to hold the authentication context (`AuthStore`).
* This allows `authInfo` to be accessible throughout the async call chain of a request
* after being set in the authentication middleware.
*
* @example
* // In middleware:
* await authContext.run({ authInfo }, next);
*
* // In a deeper handler:
* const store = authContext.getStore();
* const scopes = store?.authInfo.scopes;
*/
export const authContext = new AsyncLocalStorage();