vastai-host-mcp
Enables Vast.ai providers to manage hosted machines, update pricing, run self-tests, and automate host operations through natural language.
README
vastai-host-mcp
Production-ready Model Context Protocol (MCP) server for Vast.ai host/provider operations using FastMCP and TypeScript.
This project is the host/provider counterpart to renter-focused tools. For renting GPUs as a customer, use CryDevOk/vastai-mcp.
Table of contents
<!-- TOC -->
- What this server is for
- Feature summary
- Getting started
- Environment variables
- Development workflow
- Connect from MCP clients
- Use with GitHub Copilot
- Where to check Vast API
- Run on Vast.ai machines
- Project layout
- Contributing
- License
<!-- /TOC -->
What this server is for
This MCP server is purpose-built for Vast.ai providers (hosts who own and operate machines). It focuses on host-side workflows including:
- Viewing and managing hosted machines.
- Updating default jobs, pricing, and offer settings.
- Running verification and self-test operations.
- Inspecting reliability, uptime, and host operational signals.
- Managing host scripts and daemon restart workflows.
Feature summary
- TypeScript-first server implementation with strict compiler settings.
- FastMCP tool definitions with rich tool metadata and strict Zod schemas.
- Singleton Vast.ai host client with:
- Bearer token API auth
/api/v0/...endpoint targeting- robust error handling
- timestamped logging via Pino
- API-first execution with optional Vast CLI fallback for host commands.
- stdio and httpStream transport support.
- Host automation helper rules for pricing and reliability recommendations.
Getting started
Prerequisites
- Node.js 20+
- pnpm 9+
- Vast.ai API key with host/provider permissions
Install and run
- Install dependencies:
pnpm install
- Copy environment file and edit values:
cp .env.example .env
-
Set at least
VAST_API_KEYin.env. -
Start development server (FastMCP dev mode):
pnpm dev
- Inspect tools interactively:
pnpm inspect
- Build and run production bundle:
pnpm build
pnpm start
Environment variables
| Variable | Required | Default | Purpose |
|---|---|---|---|
VAST_API_KEY |
Yes | none | Vast.ai API token for host/provider operations |
VAST_SERVER_URL |
No | https://console.vast.ai |
Vast.ai API base URL |
MCP_TRANSPORT |
No | stdio |
Transport mode: stdio or httpStream |
MCP_HTTP_HOST |
No | 0.0.0.0 |
Host bind for httpStream transport |
MCP_HTTP_PORT |
No | 8080 |
Port for httpStream transport |
VAST_REQUEST_TIMEOUT_MS |
No | 30000 |
API and CLI timeout in milliseconds |
VAST_USE_CLI_FALLBACK |
No | true |
Enable CLI fallback for host operations |
VAST_CLI_PATH |
No | vastai |
Vast CLI executable path |
VAST_AUTO_PRICING_ENABLED |
No | false |
Toggle automation hints for price workflows |
VAST_AUTO_RELIABILITY_GUARD |
No | false |
Toggle automation hints for reliability workflows |
LOG_LEVEL |
No | info |
Pino log level |
Development workflow
Default local development workflow (warning-free in pnpm-managed environments):
pnpm dev
FastMCP terminal harness workflow (optional):
pnpm dev:fastmcp
pnpm inspect
Codespaces inspector workflow:
# If you had a prior inspector run, free default ports first
pkill -f mcp-inspector || true
# Start inspector with Codespaces-safe host and origin settings
pnpm inspect:codespaces
# If token/auth forwarding is problematic, use no-auth mode in dev only
pnpm inspect:codespaces:noauth
If the browser opens but cannot connect, ensure both forwarded ports are active:
- 6274 (Inspector UI)
- 6277 (Inspector proxy)
If the UI still shows Disconnected, use these manual values in Inspector:
- Transport Type:
STDIO - Command:
pnpm - Arguments:
exec tsx src/index.ts - Then click
Connect
If auth is enabled, open Auth Settings and paste the MCP_PROXY_AUTH_TOKEN printed in terminal.
Production build workflow:
pnpm build
pnpm start
Key host tools currently implemented:
vastai_host_show_machinesvastai_host_set_defjobvastai_host_upsert_offervastai_host_set_min_bidvastai_host_verification_statusvastai_host_self_test_machinevastai_host_get_statsvastai_host_recommend_pricingvastai_host_update_scriptvastai_host_restart_daemonvastai_host_search_offersvastai_host_show_logsvastai_host_network_statusvastai_host_reliability_actions
Connect from MCP clients
Use stdio transport for desktop tools unless you specifically need network transport.
Claude Desktop example
{
"mcpServers": {
"vastai-host": {
"command": "pnpm",
"args": ["start"],
"cwd": "/absolute/path/to/vastai-host-mcp",
"env": {
"VAST_API_KEY": "YOUR_VAST_API_KEY",
"VAST_SERVER_URL": "https://console.vast.ai",
"MCP_TRANSPORT": "stdio"
}
}
}
}
Cursor example
{
"mcpServers": {
"vastai-host": {
"command": "pnpm",
"args": ["start"],
"cwd": "/absolute/path/to/vastai-host-mcp",
"env": {
"VAST_API_KEY": "YOUR_VAST_API_KEY",
"MCP_TRANSPORT": "stdio"
}
}
}
}
VS Code MCP example
{
"servers": {
"vastai-host": {
"type": "stdio",
"command": "pnpm",
"args": ["start"],
"cwd": "/absolute/path/to/vastai-host-mcp",
"env": {
"VAST_API_KEY": "YOUR_VAST_API_KEY"
}
}
}
}
Use with GitHub Copilot
For GitHub Copilot Chat in VS Code, this repository already includes a workspace MCP config at .vscode/mcp.json.
Recommended flow:
- Set your real
VAST_API_KEYin.vscode/mcp.json. - Stop any manually running local server process (
pnpm dev) so VS Code can own the MCP process lifecycle. - In VS Code, reload MCP servers from the Command Palette.
- In Copilot Chat, test a tool call such as
vastai_host_show_machines.
Note: For VS Code MCP usage, you usually do not need to run pnpm dev manually.
Where to check Vast API
Use these sources to validate endpoint existence and request format:
- API docs index: llms.txt
- API intro: Vast API Reference
- Machines: show machines
- Machines: set min-bid
- Machines: set defjob
- Machines: list machine
- Search: search offers
The current endpoint mapping used by this MCP server is implemented in src/client/VastAIHostClient.ts.
Quick local checks:
pnpm build
pnpm inspect
When using the Inspector, a command returning HTTP 404 is usually a route mismatch, while HTTP 400/403/500 generally means the route exists and your payload, permissions, or backend state should be checked.
Run on Vast.ai machines
When deploying this MCP server inside a Vast.ai instance:
- Keep API keys in environment variables only. Never hardcode secrets.
- Use
stdiomode for local desktop tunneling workflows. - Use
httpStreamonly behind trusted network boundaries or a reverse proxy. - Install Vast CLI in the runtime if you want CLI fallback behavior.
- Monitor logs with your preferred process manager (systemd, pm2, supervisord).
For onboarding guidance, see Building your first MCP server on Vast.ai.
Project layout
.
├── src/
│ ├── client/
│ │ └── VastAIHostClient.ts
│ ├── rules/
│ │ └── MCPRules.ts
│ ├── tools/
│ │ └── hostTools.ts
│ ├── config.ts
│ ├── index.ts
│ └── logger.ts
├── .env.example
├── package.json
├── tsconfig.json
└── README.md
Contributing
- Open an issue describing the host/provider workflow or API gap.
- Keep additions host-focused (not renter workflow features).
- Add or update tool descriptions so they remain LLM-friendly and explicit.
- Run local checks before opening a PR.
Repository-wide conventions and agent behavior are documented in AGENTS.md.
License
This project is licensed under the MIT License. See LICENSE.
<!-- Named links -->
推荐服务器
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 模型以安全和受控的方式获取实时的网络信息。