Member Junction
    Preparing search index...

    MCPClientManager is a singleton that manages connections to external MCP servers.

    Features:

    • Support for all MCP transport types (StreamableHTTP, SSE, Stdio, WebSocket)
    • Multiple authentication methods (None, Bearer, APIKey, OAuth2, Basic, Custom)
    • Integration with MJ CredentialEngine for secure credential storage
    • Rate limiting with request queuing
    • Comprehensive execution logging
    • Permission-based access control
    const manager = MCPClientManager.Instance;

    // Connect to an MCP server
    await manager.connect('connection-id', { contextUser });

    // Call a tool
    const result = await manager.callTool('connection-id', 'tool-name', {
    arguments: { param1: 'value1' }
    }, { contextUser });

    // Disconnect
    await manager.disconnect('connection-id', { contextUser });

    Hierarchy (View Summary)

    Index

    Constructors

    Accessors

    • get GlobalKey(): string

      Returns string

    Methods

    • Gets information about an active connection

      Parameters

      • connectionId: string

        Connection ID

      Returns { connectedAt: Date; connectionName: string; serverName: string }

      Connection info or null if not connected

    • The Global Object Store is a place to store global objects that need to be shared across the application. Depending on the execution environment, this could be the window object in a browser, or the global object in a node environment, or something else in other contexts. The key here is that in some cases static variables are not truly shared because it is possible that a given class might have copies of its code in multiple paths in a deployed application. This approach ensures that no matter how many code copies might exist, there is only one instance of the object in question by using the Global Object Store.

      Returns GlobalObjectStore

    • Gets the OAuth connection status for a connection.

      Parameters

      • connectionId: string

        MCP Server Connection ID

      • contextUser: UserInfo

        User context

      Returns Promise<
          {
              hasValidTokens: boolean;
              isOAuthEnabled: boolean;
              reauthorizationReason?: string;
              requiresReauthorization: boolean;
              tokenExpiresAt?: Date;
          },
      >

      OAuth connection status or null if not an OAuth2 connection

    • Initializes the manager. Should be called once at application startup.

      Parameters

      • contextUser: UserInfo

        User context for initialization

      • Optionaloptions: { publicUrl?: string }

        Optional initialization options

      Returns Promise<void>

    • Notifies listeners that OAuth authorization has completed successfully. Called by OAuth callback handler after code exchange succeeds.

      Parameters

      • connectionId: string

        The connection ID that was authorized

      • Optionaldata: Record<string, unknown>

        Optional additional data (token info, etc.)

      Returns void

    • Notifies listeners that an OAuth token was successfully refreshed. Called by TokenManager after successful token refresh.

      Parameters

      • connectionId: string

        The connection ID whose token was refreshed

      • Optionaldata: Record<string, unknown>

        Optional additional data (new expiration, etc.)

      Returns void

    • Notifies listeners that OAuth token refresh failed. Called by TokenManager when refresh fails.

      Parameters

      • connectionId: string

        The connection ID whose token refresh failed

      • data: {
            authorizationUrl?: string;
            error: string;
            requiresReauthorization: boolean;
            stateParameter?: string;
        }

        Error details and whether re-authorization is required

      Returns void

    • Syncs MCP Server Tools to MJ Actions. Creates the category hierarchy System/MCP/{ServerName} and an Action for each tool.

      Parameters

      • serverId: string

        The MCP Server ID to sync actions for

      • contextUser: UserInfo

        The user context for database operations

      • Optionalprovider: IMetadataProvider

      Returns Promise<MCPSyncActionsResult>

      Sync result with counts of created/updated actions and params

    • Returns the singleton instance of the class. If the instance does not exist, it is created and stored in the Global Object Store. If className is provided it will be used as part of the key in the Global Object Store, otherwise the actual class name will be used. NOTE: the class name used by default is the lowest level of the object hierarchy, so if you have a class that extends another class, the lowest level class name will be used.

      Type Parameters

      Parameters

      • this: new () => T
      • OptionalclassName: string

      Returns T