mcp-use TypeScript API
    Preparing search index...

    Variable modelContextConst

    modelContext: {
        clear(): void;
        remove(key: string): void;
        set(key: string, content: string): void;
    } = ...

    Imperative model-context API for non-React call sites (event handlers, stores).

    Delegates to the active document runtime's model-context store. Strings register as root-level nodes in the same tree ModelContext builds. Every push merges the complete tree under _uiContext beside the current useViewState object. Updates batch per microtask and use the same async flush pump as the component API.

    Type Declaration

    • clear: function
      • Remove all context entries.

        Returns void

        When no view runtime is mounted.

    • remove: function
      • Remove the entry registered under key.

        Parameters

        Returns void

        When no view runtime is mounted.

    • set: function
      • Register or update a named root-level text context entry.

        Parameters

        • key: string

          Stable key for this entry (replaces any prior value under the same key).

        • content: string

          Text describing what the user is seeing.

        Returns void

        When no view runtime is mounted.

    When no view runtime is mounted (bootstrapView has not activated a runtime, or it has been disposed).

    modelContext.set("active-item", `Viewing ${item.name}`);
    modelContext.remove("active-item");
    modelContext.clear();