Vps-mcp
Enables a ChatGPT Web conversation to act as a coding agent on a VPS, with project-bound chats, Git worktree isolation, live activity streaming, structured questions, and file/image exchange via MCP.
README
Vps-mcp Agent Portal
A self-hosted Codex-style coding control plane for a VPS. It combines a clean browser portal with an MCP gateway so an individual ChatGPT Web conversation can bind to an individual project chat, work in an isolated Git worktree, stream observable activity, ask structured questions, receive files/images, and mirror its final answer back into the portal.
What is implemented
- Workspaces mapped to Git repositories on the VPS.
- Independent chats with Plan / Build / Review modes.
- One-time
bind_...codes that bind one MCP session to one portal chat. - One active agent lease per chat; different chats can run in parallel.
- Build-mode Git worktree +
agent/<chat-id>branch isolation. - Full canonical chat history with context-pressure compaction only when needed.
- Search/retrieval of older raw messages after compaction.
- Structured portal questions: text, confirm, single-choice, multi-choice.
- Live durable SSE activity: status, commands, stdout/stderr, file changes, questions, completion.
- Image/file attachments, content-addressed storage, MIME sniffing, dedupe and MCP delivery.
- Changes/diff and rolling run-summary surfaces in the web UI.
- OAuth authorization-code + PKCE for MCP; access tokens are stored hashed in Postgres.
- Browser auth with Argon2, HttpOnly/Secure/SameSite cookies, CSRF and rate limiting.
- Legacy unrestricted
terminalremains available when the MCP session is not portal-bound. Once bound, it is disabled and the agent must usechat_terminal, so chat mode policy is applied. - Unit, integration, official MCP-client, public smoke, restart and Playwright browser tests.
Important ChatGPT Web limitation
MCP does not provide a mechanism for a server to create a new ChatGPT Web model turn. A message submitted in the portal is durably queued and returned by chat_sync, but it cannot wake an idle ChatGPT tab by itself.
For truly unattended portal-initiated runs, the planned V2 AgentDriver/OpenAI Responses API worker is the right path. The existing architecture deliberately keeps that future driver separate from the chat/workspace/event model.
Context behavior
The portal stores the complete canonical thread permanently.
- While the thread fits the configured budget,
chat_connecthydrates the entire chat verbatim. A saved rolling summary is ignored. - Near context pressure, an older checkpoint summary replaces only the messages it covers; every message after that checkpoint stays verbatim.
chat_historyandchat_history_searchcan retrieve compacted-out raw history at any time.chat_syncis cursor-based and returns only new messages/events/answers after connection.
This matches the coding-agent pattern discussed for Codex/OpenCode: full detail first, compaction only when the context window requires it.
MCP tools
terminal— broad VPS terminal when the MCP session is not bound to a portal chat.chat_connect(binding_code)chat_sync()chat_activity(stage, message)chat_ask(...)chat_terminal(command, cwd?, timeout?)chat_history(...)chat_history_search(query, limit?)chat_compact(...)chat_attachment(attachment_id)chat_complete(answer, summary, structured?, compacted_through_seq?)chat_disconnect()
Repository layout
apps/
api/ Fastify control API + auth + SSE + portal static hosting
mcp/ Streamable HTTP MCP/OAuth gateway + chat agent service
portal/ React/Vite Codex-style UI
packages/
core/ IDs, modes, context policy, redaction
db/ PostgreSQL migration/repository layer
workspace/ Git repository/worktree/diff lifecycle
attachments/content-addressed upload storage
tests/
e2e/ Playwright browser happy path
smoke/ public HTTPS portal → OAuth → MCP end-to-end smoke
docs/
ARCHITECTURE.md
deploy/
systemd/
traefik/
TODO.md canonical implementation tracker
Development
Requirements: Node 22+, Docker, Git.
npm install
docker compose up -d postgres
On a fresh Docker volume, create/use a test database and set TEST_DATABASE_URL, then run:
TEST_DATABASE_URL=postgresql://... npm test
npm run typecheck
npm run build
npm audit --omit=dev --audit-level=high
Browser E2E:
E2E_BASE_URL=https://your-host \
E2E_ADMIN_PASSWORD='...' \
npm run e2e
Public smoke:
SMOKE_BASE_URL=https://your-host \
SMOKE_ADMIN_PASSWORD='...' \
SMOKE_OAUTH_PASSWORD='...' \
npm run smoke
The smoke runner creates a temporary Git repository, exercises Plan/Q&A/attachments/Build/worktree/completion, then deletes its chat/workspace/worktree.
Deployment
The production deployment on the test VPS uses separate systemd services and the existing Coolify Traefik instance. Templates are under deploy/.
The original /opt/terminal-mcp is intentionally kept as a rollback/control MCP until the new connector is added in ChatGPT and explicitly cut over.
Security notes
- Browser responses never include DB credentials, MCP OAuth password, executor credentials, or attachment storage paths.
- MCP access/session/binding tokens are stored hashed where persistence is required.
- Observable activity is secret-redacted; private model chain-of-thought is never sent to the portal.
- Plan/Review shell commands use a conservative inspection allowlist and reject redirections/subshells/mutating command families.
- Uploaded files are not auto-executed.
- The current disposable-VPS deployment runs the control API as root so it can validate arbitrary host repositories and clean Git worktrees; it exposes no generic shell route. For a multi-tenant/non-disposable server, split repository lifecycle into a narrow privileged helper and run the browser-facing API unprivileged.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。