This guide explains how to expose a locally running Serena MCP server (powered by MCPO) to the internet using Cloudflare Tunnel, and how to connect it to ChatGPT as a Custom GPT with tool access.
Once configured, ChatGPT becomes a powerful coding agent with direct access to your codebase, shell, and file system — so read the security notes carefully.
Make sure you have uv and cloudflared installed.
Run the following command to launch Serena as http server (assuming port 8000):
uvx mcpo --port 8000 --api-key <YOUR_SECRET_KEY> -- \
uvx --from git+https://github.com/oraios/serena \
serena start-mcp-server --context chatgpt --project $(pwd)--api-keyis required to secure the server.--projectshould point to the root of your codebase.
You can also use other options, and you don't have to pass --project if you want to work on multiple projects
or want to activate it later. See
uvx --from git+https://github.com/oraios/serena serena start-mcp-server --helpRun:
cloudflared tunnel --url http://localhost:8000This will give you a public HTTPS URL like:
https://serena-agent-tunnel.trycloudflare.com
Your server is now securely exposed to the internet.
- Go to ChatGPT → Explore GPTs → Create
- During setup, click “Add APIs”
- Set up API Key authentication with the auth type as Bearer and enter the api key you used to start the MCPO server.
- In the Schema section, click on import from URL and paste
<cloudflared_url>/openapi.jsonwith the URL you got from the previous step. - Add the following line to the top of the imported JSON schema:
Important: don't include a trailing slash at the end of the URL!
"servers": ["url": "<cloudflared_url>"],
ChatGPT will read the schema and create functions automatically.
Depending on your configuration and enabled tools, Serena's MCP server may:
- Execute arbitrary shell commands
- Read, write, and modify files in your codebase
This gives ChatGPT the same powers as a remote developer on your machine.
- NEVER expose your API key
- Only expose this server when needed, and monitor its use.
In your project’s .serena/project.yml or global config, you can disable tools like:
excluded_tools:
- execute_shell_command
- ...
read_only: trueThis is strongly recommended if you want a read-only or safer agent.
With this setup, ChatGPT becomes a coding assistant running on your local code — able to index, search, edit, and even run shell commands depending on your configuration.
Use responsibly, and keep security in mind.