倾斜MCP服务器
用于Tilt CLI集成的MCP(模型上下文协议)服务器,使AI助手能够与Tilt开发工作流进行交互。
特性
- 状态监测:具有汇总计数的Tilt资源的实时状态
- 资源管理:列出、描述、启用、禁用和触发资源
- 日志访问:通过ANSI剥离、尾部限制和可选的客户端搜索从Tilt资源访问日志
- 详细行动:可选
verbose控制工具返回更新资源状态的响应 - WebSocket客户端:通过Tilt的WebSocket API实时更新
- 安全执行:具有超时和缓冲区限制的Secure CLI包装器
- LLM优化响应:精简资源格式、分页和状态过滤
可用工具
| 工具 | 说明 |
|---|---|
tilt_status | 获取Tilt会话状态摘要(按状态+错误计数) |
tilt_get_resources | 使用过滤、分页和精简/详细模式列出资源 |
tilt_describe_resource | 获取资源的详细信息(已清理格式) |
tilt_logs | 查看资源中的日志(纯文本输出);支持客户端搜索; level 过滤器仅倾斜系统消息(不包括应用程序日志);请参阅docs/log-filtering behavior.md |
tilt_trigger | 手动触发资源更新(添加 verbose 以包括更新的资源状态) |
tilt_enable | 启用已禁用的资源(添加 verbose 以包括更新的资源状态) |
tilt_disable | 禁用资源(添加 verbose 以包括更新的资源状态) |
tilt_args | 设置或清除Tiltfile参数 |
tilt_wait | 等待资源达到就绪状态(添加 verbose 获取精简状态摘要) |
ℹ️ tilt_dump 已实施和测试,但故意未注册MCP使用,因为原始发动机状态可能超过6MB,需要进一步调整以适应代理消耗。仅在为客户定制输出后使用。
🚦 连接配置:设置 TILT_PORT 在你的 .mcp.json 服务器配置(在 env)或者将其导出到您的shell中。 TILT_HOST 默认为 localhost 如果没有设置。如果端口丢失,工具将很快发生故障;主机/端口输入不公开,以避免跨实例错误。 🔎 发现笔记:上一篇 tilt_discover 助手被移除。配置 TILT_PORT/TILT_HOST 明确地而不是依赖于发现。
先决条件
安装
bun installClaude代码的快速安装
将此MCP服务器与Claude Code一起使用的最快方法是通过 npx 或 bunx:
# Using npx (npm)
claude mcp add --transport stdio tilt \
--env TILT_PORT=10350 \
-- npx -y @0xbigboss/tilt-mcp
# Using bunx (Bun)
claude mcp add --transport stdio tilt \
--env TILT_PORT=10350 \
-- bunx @0xbigboss/tilt-mcp理解命令:
--transport stdio:作为本地进程运行(基于stdio的MCP服务器需要)--env TILT_PORT=10350:设置倾斜度API端口(必需;如果倾斜度使用其他端口,则进行调整)--:将Claude的标志与MCP服务器命令分开npx -y @0xbigboss/tilt-mcp或bunx @0xbigboss/tilt-mcp:自动下载并运行最新版本
可选环境变量:
# Connect to a remote Tilt instance
claude mcp add --transport stdio tilt \
--env TILT_PORT=10350 \
--env TILT_HOST=tilt.example.com \
-- npx -y @0xbigboss/tilt-mcp验证安装:
# List configured MCP servers
claude mcp list
# Check server status in Claude Code
> /mcp使用工具:
安装后,您可以要求Claude Code与Tilt交互:
> "Show me the status of all Tilt resources"
> "Get logs from the api service"
> "Trigger a rebuild of the frontend resource"注: 这需要将包发布到npm。有关当地发展,请参阅 构建独立可执行文件 下面的部分。
用法
作为MCP服务器
服务器通过stdio传输进行通信:
# Development (watch, no build required)
bun run dev
# Production (requires build first)
bun run build
bun run start在Claude桌面中配置
添加到您的Claude Desktop MCP配置中:
{
"mcpServers": {
"tilt": {
"command": "bun",
"args": ["run", "/path/to/tilt-mcp/dist/server.js"],
"env": {
"TILT_PORT": "10350"
}
}
}
}注: TILT_HOST 默认为 localhost。仅当连接到远程Tilt实例时才显式设置它。
连接配置
- 必填:定义
TILT_PORT在您的MCP服务器中env挡住.mcp.json(或在启动服务器之前导出)。 - 可选:
TILT_HOST默认为localhost如果没有明确设置。 - 典型的本地设置:
TILT_PORT=10350(主机默认为localhost) - 工具做 不 接受主机/端口参数;在配置中设置一次,以避免跨实例错误。
- 如果端口丢失或无效,值将被验证,服务器将快速失败。
构建独立可执行文件
要创建可以添加到PATH中的独立可执行文件,请执行以下操作:
# Build the standalone executable
bun run build:standalone
# The executable will be created at dist/tilt-mcp
# Add it to your PATH by creating a symlink or copying it
ln -s $(pwd)/dist/tilt-mcp /usr/local/bin/tilt-mcp
# Or copy it directly
cp dist/tilt-mcp /usr/local/bin/tilt-mcp独立的可执行文件包括Bun运行时和所有依赖项,使其易于移植和分发。
使用独立可执行文件
安装到PATH后,您可以直接运行它:
# Run the MCP server
tilt-mcp
# Configure in Claude Desktop with the absolute path
{
"mcpServers": {
"tilt": {
"command": "/usr/local/bin/tilt-mcp",
"env": {
"TILT_PORT": "10350"
}
}
}
}发展
# Build (creates dist/server.js)
bun run build
# Build standalone executable (creates dist/tilt-mcp)
bun run build:standalone
# Development mode (watch)
bun run dev
# Run tests
bun test
# Run tests in watch mode
bun run test:watch
# Type checking (uses tsgo - native TypeScript)
bun run typecheck
# Linting (uses Biome)
bun run lint
bun run lint:fix常用工具示例
- 用简短的摘要列出资源:
tilt_get_resources没有参数(addstatus: "error"或verbose: true根据需要)。 - 仅提供尾部倾斜提示:
tilt_logs随着level: "error"(过滤倾斜系统消息;应用程序日志未经过滤返回)。 - 安全管理Tiltfile参数:
tilt_args随着mode: "get"查看,mode: "set", args: ["arg1=value"]更新,或mode: "clear"重置(避免在没有参数的情况下运行)。 - 在一次调用中触发并检查资源:
tilt_trigger随着verbose: true以包括更新的资源状态。 - 使用状态后快照等待:
tilt_wait随着resources: ["api"], verbose: true等待后收到一份简短的准备情况摘要。
项目结构
tilt-mcp/
├── src/
│ ├── server.ts # MCP server entry point
│ ├── tools/ # MCP tool implementations
│ │ ├── status.ts # tilt_status
│ │ ├── resources.ts # tilt_get_resources
│ │ ├── describe.ts # tilt_describe_resource
│ │ ├── logs.ts # tilt_logs
│ │ ├── trigger.ts # tilt_trigger
│ │ ├── enable.ts # tilt_enable
│ │ ├── disable.ts # tilt_disable
│ │ ├── args.ts # tilt_args
│ │ ├── wait.ts # tilt_wait
│ │ ├── transformers.ts # Response transformers (slim format, ANSI strip)
│ │ └── schemas.ts # Zod validation schemas
│ └── tilt/ # Tilt integration layer
│ ├── cli-client.ts # Safe CLI command execution
│ ├── ws-client.ts # WebSocket client for real-time updates
│ ├── connection.ts # Connection management
│ ├── types.ts # TypeScript type definitions
│ └── errors.ts # Error types
├── tests/
│ ├── tools/ # Tool unit tests
│ ├── tilt/ # Client tests
│ ├── integration/ # MCP protocol integration tests
│ └── fixtures/ # Test fixtures and mocks
└── docs/ # SDK reference documentation建筑
CLI客户端
这 TiltCliClient 提供安全的命令执行:
- 不执行shell:用途
spawn()带参数数组 - 超时处理:可配置的进程终止超时
- 缓冲区限制:默认10MB,日志50MB
- 解析错误:类型错误(TiltNotRunningError、TiltResourceNotFoundError等)
响应设计
- 默认情况下为Slim:资源以紧凑的“Slim”格式返回,可选
verbose包括全部细节。 - 定制日志:默认ANSI剥离
tailLines帽;level过滤器仅倾斜系统消息。 - 降低噪音:构建历史记录被截断为最后两个条目,重复端点被重复删除。
- 带状态的控制工具:
tilt_enable,tilt_disable,tilt_trigger,以及tilt_wait接受verbose以返回动作后状态。
WebSocket客户端
这 TiltWebSocketClient 连接到Tilt的WebSocket API以进行实时更新:
- 日志行流式传输
- 资源状态更新
- 支持取消订阅的事件回调
输入验证
所有工具输入都使用Zod模式进行验证:
- 资源名称:Kubernetes命名约定(加上特殊的Tilt
(Tiltfile)) - 论点:防止外壳注入
测试
该项目包括综合测试:
- 所有工具和客户端的单元测试
- MCP协议合规性集成测试
- Tilt CLI响应的模拟夹具
# Run all tests
bun test
# Run specific test file
bun test tests/tools/status.test.ts
# Run integration tests only
bun run test:integration故障排除
- Tiltfile args夹具:如果Tilt报告
You specified some resources that could not be found: "--foo", "bar",通过清除存储的Tiltfile参数tilt_args(mode="clear").此场景用于QA覆盖范围,以验证错误处理,而不是代码缺陷。 - 日志级别过滤:
level旗上tilt_logs过滤器仅倾斜系统消息。应用程序日志未经过滤返回;看见docs/log-filtering-behavior.md有关详细信息、搜索示例和限制。
许可证
麻省理工学院
