25 lines
628 B
TypeScript

import { useState, useEffect } from 'react';
/**
* Hook to access MCP App context and initial data
* In production, this would read from window.mcpContext
*/
export function useMCPApp<T = any>() {
const [context, setContext] = useState<T | null>(null);
const [loading, setLoading] = useState(true);
useEffect(() => {
// In production MCP Apps, initial data is injected via window.mcpContext
// For now, we'll simulate this
const mcpContext = (window as any).mcpContext;
if (mcpContext) {
setContext(mcpContext);
}
setLoading(false);
}, []);
return { context, loading };
}