Skip to main content
This is an OpenAI MCP extension, not part of MCP or MCP Apps. Only ChatGPT supports it: on other hosts the function rejects.
A view usually has no access to the filesystem. When your server knows the absolute path of a file, for example one it just generated, useOpenFile asks ChatGPT to open it. This needs ChatGPT desktop, and the path must exist on the machine that runs it. ChatGPT desktop opens the file in a new tab with its built-in viewer, from which the user can view the source or open it in an external editor. It doesn’t go through your app’s file entrypoint, even when the file’s extension matches one. That’s what we observed in ChatGPT desktop; the spec doesn’t describe it.

Example

A view offers to open the file the tool exported.

Returns

A memoized function that sends openai/files/open with the absolute path. It rejects with a NotSupportedError on hosts that don’t advertise openai/files, so check useHost().openaiCapabilities.files before showing the control.

useHost

Check which extensions the host supports

useOpenExternal

Open a URL outside the conversation