file.resourceUri instead. useFileResource reads that resource, re-reads it whenever the host reports a change, and saves edits back.
Reading uses the standard MCP
resources/read. Text or blob selection, change subscriptions and writes come from the OpenAI MCP extensions, so only ChatGPT desktop supports them.Example
A part editor loads the opened file as text and saves the user’s edits.Parameters
uri
file.resourceUri from the tool input. Pass undefined to do nothing, for example when the view also opens outside a file entrypoint.
options
openai/resource. Elsewhere it reads the resource once.
Returns
data
writable tells whether ChatGPT accepts writes, and etag identifies this version. undefined until the first read completes.
isLoading, error
isLoading is true until the first read of uri completes. Re-reads after a change keep the previous data on screen until the new contents arrive. error holds the last read failure, and data keeps the last contents that loaded.
write
openai/resources/write, with the current etag as ifMatch. When ChatGPT returned no etag, the write has no version check. When the file changed since the last read, ChatGPT answers conflict instead of overwriting it, and the hook re-reads the latest version into data. On saved, data takes the new contents and etag. It rejects with a NotSupportedError when the host doesn’t advertise openai/resource, data isn’t loaded yet, or data.writable is false.
registerTool
Add a file entrypoint to a tool
useOpenFile
Ask ChatGPT to open another local file