UNPKG

@kya-os/mcp-i

Version:

The TypeScript MCP framework with identity features built-in

34 lines (33 loc) 972 B
type DefaultContext = Object; type GetContext<T extends DefaultContext> = () => T; type SetContext<T extends DefaultContext> = (data: Partial<T>) => void; export interface Context<T extends DefaultContext> { /** Run a callback with a specific context. */ provider: (initialValue: T, callback: () => void) => void; /** Get the context. */ getContext: GetContext<T>; /** Partially update the context. */ setContext: SetContext<T>; } interface CreateContextOptions { name: string; } /** * Create context allows you to create scoped variables for fucntions. * Similar to React's context API. * Usage: * ```ts * interface MyContext { * value: string; * } * * const context = createContext({ name: "my-context" }); * * context.provider({ * value: "hello", * }, () => { * // Do something with the context * })``` */ export declare function createContext<T extends Object>({ name, }: CreateContextOptions): Context<T>; export {};