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.
54 lines • 2.08 kB
TypeScript
/**
* Resource Subscription Management
*
* Handles subscription tracking and notifications for MCP resource updates.
* Implements the MCP resources/subscribe and resources/unsubscribe protocol.
*/
import type { McpServer as OfficialMcpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import type { SessionData } from "../sessions/index.js";
/**
* Subscription manager for tracking resource subscriptions across sessions
*/
export declare class ResourceSubscriptionManager {
/**
* Tracks resource subscriptions per session
* Map structure: uri -> Set<sessionId>
*/
private subscriptions;
/**
* Register subscription handlers with an MCP server instance
*
* @param server - The native MCP server instance
* @param sessions - Map of active sessions
*/
registerHandlers(server: OfficialMcpServer, sessions: Map<string, SessionData>): void;
/**
* Get session ID from request context or sessions map
*
* @param sessions - Map of active sessions
* @param server - The server instance to match against
* @returns The session ID, or undefined if not found
*/
private getSessionIdFromContext;
/**
* Notify subscribed clients that a resource has been updated
*
* This method sends a `notifications/resources/updated` notification to all
* sessions that have subscribed to the specified resource URI.
*
* @param uri - The URI of the resource that changed
* @param sessions - Map of active sessions
* @returns Promise that resolves when all notifications have been sent
*/
notifyResourceUpdated(uri: string, sessions: Map<string, SessionData>): Promise<void>;
/**
* Clean up resource subscriptions for a closed session
*
* This method is called automatically when a session is closed to remove
* all resource subscriptions associated with that session.
*
* @param sessionId - The session ID to clean up
*/
cleanupSession(sessionId: string): void;
}
//# sourceMappingURL=subscriptions.d.ts.map