|
| 1 | +--- |
| 2 | +title: Deploy and host a ChatGPT App |
| 3 | +description: "Deploy and host your ChatGPT App (MCP server) so anyone can use it." |
| 4 | +--- |
| 5 | + |
| 6 | +In this article, we walk through how to deploy your ChatGPT App to the mcp-agent cloud platform to have it readily available for anyone to use. |
| 7 | + |
| 8 | +<video controls width="100%"> |
| 9 | + <source src="https://github.com/user-attachments/assets/cb50700c-5650-4f12-ac2e-2eabba5c8144" type="video/mp4" /> |
| 10 | + Your browser does not support the video tag. |
| 11 | +</video> |
| 12 | + |
| 13 | +## What are ChatGPT Apps? |
| 14 | +OpenAI announced the [support for Apps within ChatGPT](https://openai.com/index/introducing-apps-in-chatgpt/). ChatGPT Apps unlock interactive experiences that live inside ChatGPT conversations, allowing applications to respond to natural language with in-chat interfaces (like maps or playlists). |
| 15 | + |
| 16 | +## Guide for deploying your application |
| 17 | + |
| 18 | +### TL;DR |
| 19 | + |
| 20 | +1. **Create an `MCPApp()`** in your python server code |
| 21 | +2. **Install** the `mcp-agent` library |
| 22 | +3. **Deploy** with the `mcp-agent` CLI |
| 23 | + |
| 24 | +### 1) Prerequisites |
| 25 | + |
| 26 | +- Python **3.10+** |
| 27 | + |
| 28 | +### 2) Install dependencies |
| 29 | + |
| 30 | +**Using `uv` (recommended):** |
| 31 | +```bash |
| 32 | +uv init |
| 33 | +uv sync |
| 34 | +``` |
| 35 | +Or with pip: |
| 36 | +```bash |
| 37 | +pip install mcp-agent |
| 38 | +pip install fastapi |
| 39 | +``` |
| 40 | + |
| 41 | +### 3) Minimal code change: create an MCPApp() |
| 42 | + |
| 43 | +`MCPApp` is the constructor for defining an MCP Application. The `mcp-agent` library looks for the `MCPApp` when configuring the application in the hosted cloud platform. |
| 44 | + |
| 45 | +Make sure your server creates an MCPApp() and wires it to your FastMCP instance. |
| 46 | + |
| 47 | +```python main.py |
| 48 | +from mcp_agent.app import MCPApp |
| 49 | +from fastmcp import FastMCP # import if your project uses FastMCP |
| 50 | + |
| 51 | +mcp = FastMCP( |
| 52 | + name="your-app-name", |
| 53 | + message_path="/sse/messages", # important: aligns with your SSE path |
| 54 | + stateless_http=True, # recommended for cloud hosting |
| 55 | +) |
| 56 | + |
| 57 | +# ❗️ Key addition: register your MCP server as an mcp-agent App |
| 58 | +app = MCPApp( |
| 59 | + name="your-app-name", |
| 60 | + description="your-app-description", |
| 61 | + mcp=mcp, |
| 62 | +) |
| 63 | + |
| 64 | +# ----- Your ChatGPT Application code here ----- |
| 65 | +``` |
| 66 | + |
| 67 | +These are the key changes needed for mcp-agent cloud hosting. |
| 68 | + |
| 69 | +### 4) Add deployment config & secrets |
| 70 | + |
| 71 | +Create two files at the repo root: |
| 72 | + |
| 73 | +```yaml mcp_agent.config.yaml |
| 74 | +# Execution engine: asyncio or temporal |
| 75 | +execution_engine: asyncio |
| 76 | + |
| 77 | +name: "your-app-name" |
| 78 | +description: "your-app-description" |
| 79 | + |
| 80 | +logger: |
| 81 | + transports: [console, file] |
| 82 | + level: info |
| 83 | + path: logs/mcp-agent.log |
| 84 | +``` |
| 85 | +
|
| 86 | +```yaml mcp_agent.secrets.yaml |
| 87 | +# You can leave this blank. This is useful if you want to pass in keys or secrets to your MCP server |
| 88 | +``` |
| 89 | + |
| 90 | +### 5) Deploy to mcp-agent cloud |
| 91 | + |
| 92 | +With `uv`: |
| 93 | + |
| 94 | +```bash |
| 95 | +uv run mcp-agent login |
| 96 | +uv run mcp-agent deploy --no-auth |
| 97 | +``` |
| 98 | + |
| 99 | +Or with `venv`: |
| 100 | + |
| 101 | +```bash |
| 102 | +mcp-agent login |
| 103 | +mcp-agent deploy --no-auth |
| 104 | +``` |
| 105 | + |
| 106 | +<Info>Support for OAuth coming soon!</Info> |
| 107 | + |
| 108 | +After a successful deploy, you'll see a cloud URL like: |
| 109 | + |
| 110 | +``` |
| 111 | +https://<deployment-id>.deployments.mcp-agent.com/sse |
| 112 | +``` |
| 113 | + |
| 114 | +### 6) Test in ChatGPT |
| 115 | + |
| 116 | +1. Enable Developer Mode in ChatGPT. |
| 117 | +2. Go to Settings → Connectors and add your app's MCP server. |
| 118 | +3. Use your cloud URL, making sure it ends with `/sse`. |
| 119 | + |
| 120 | +<Note>ChatGPT connects to the SSE endpoint, so the `/sse` suffix is required.</Note> |
| 121 | + |
| 122 | +.png) |
| 123 | + |
| 124 | +--- |
| 125 | + |
| 126 | +## Troubleshooting |
| 127 | + |
| 128 | +- **404 / Connection errors in ChatGPT**: Ensure your URL ends with `/sse` and your code's `message_path` is `/sse/messages`. |
| 129 | +- **Auth errors**: If you are unable to deploy because of an Auth issue, make sure you run `mcp-agent login`. If you are unable to access your ChatGPT app, make sure you deployed with the `--no-auth` configuration to make sure you can access your application. |
| 130 | +- **MCP Inspector**: If you want to test without ChatGPT, you can use [MCP Inspector](https://modelcontextprotocol.io/docs/tools/inspector) (a debugging tool) for MCP servers to validate to make sure your MCP application is properly configured. |
| 131 | + |
| 132 | +## Additional Resources |
| 133 | + |
| 134 | +- [Example ChatGPT Apps](https://github.com/lastmile-ai/openai-apps-sdk) |
| 135 | +- [mcp-agent repo](https://github.com/lastmile-ai/mcp-agent) |
0 commit comments