/** Source context passed through the MCP factory so tools know who called them. */ export interface McpSourceContext { /** Job name if called from a job runner, e.g. "scout" */ jobName?: string; /** Channel name: "slack" | "telegram" | "terminal" */ channel?: string; /** The room the calling engine is operating in */ room?: string; /** Slack channel ID where the current session lives (for thread replies) */ slackChannelId?: string; /** Slack thread timestamp (for replying back to the current thread) */ slackThreadTs?: string; } /** Factory for per-query MCP servers — each query gets its own Protocol instance. */ let _mcpFactory: ((ctx?: McpSourceContext) => Record) | null = null; export function setMcpFactory(factory: (ctx?: McpSourceContext) => Record): void { _mcpFactory = factory; } export function getMcpServers(ctx?: McpSourceContext): Record | undefined { return _mcpFactory?.(ctx) ?? undefined; }