UNPKG

mcp-use

Version:

Opinionated MCP Framework for TypeScript (@modelcontextprotocol/sdk compatible) - Build MCP Agents, Clients and Servers with support for ChatGPT Apps, Code Mode, OAuth, Notifications, Sampling, Observability and more.

31 lines (28 loc) 841 B
import { __name } from "./chunk-3GQAWCBQ.js"; // src/server/context-storage.ts import { AsyncLocalStorage } from "async_hooks"; var requestContextStorage = new AsyncLocalStorage(); async function runWithContext(context, fn, sessionId) { return requestContextStorage.run({ honoContext: context, sessionId }, fn); } __name(runWithContext, "runWithContext"); function getRequestContext() { return requestContextStorage.getStore()?.honoContext; } __name(getRequestContext, "getRequestContext"); function getSessionId() { return requestContextStorage.getStore()?.sessionId; } __name(getSessionId, "getSessionId"); function hasRequestContext() { return requestContextStorage.getStore() !== void 0; } __name(hasRequestContext, "hasRequestContext"); export { runWithContext, getRequestContext, getSessionId, hasRequestContext };