Documentation
¶
Overview ¶
Package ctl 实现 Gately 的命令行客户端与 MCP 服务器:二者都通过 HTTP + API 令牌调用运行中的实例, 不重复任何业务逻辑,接口清单直接来自实例的 OpenAPI 文档。
Index ¶
- Constants
- func ConfigPath() string
- func RunCtl(args []string, stdout, stderr io.Writer) int
- func RunMCP(args []string, stdin io.Reader, stdout, stderr io.Writer) int
- func ServeMCP(ctx context.Context, c *Client, opts MCPOptions, r io.Reader, w io.Writer, ...) error
- type APIError
- type Client
- type Config
- type MCPOptions
- type Operation
- type Tool
Constants ¶
const DefaultURL = "http://127.0.0.1:16680"
DefaultURL 是未指定地址时连接的本机管理地址。
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client 是调用管理 API 的客户端。
type Config ¶
type Config struct {
URL string `json:"url"`
Token string `json:"token"`
// Insecure 跳过 HTTPS 证书校验,仅用于自签名证书的内网实例
Insecure bool `json:"insecure,omitempty"`
}
Config 是连接配置。
func LoadConfig ¶
func LoadConfig() Config
LoadConfig 依次读取配置文件、环境变量(GATELY_URL / GATELY_TOKEN),后者优先。
type MCPOptions ¶
type MCPOptions struct {
// AllowWrite 为 false 时只暴露只读(GET)接口
AllowWrite bool
}
MCPOptions 控制暴露哪些工具。
type Operation ¶
type Operation struct {
Method string
Path string
Tag string
Summary string
Desc string
// Scope 为所需令牌权限(如 ddns:write),空表示任意令牌
Scope string
// PathParams 为路径中的参数名
PathParams []string
// Body 为请求体的 JSON Schema(已展开引用),nil 表示无请求体
Body any
// HasBody 表示接口接受请求体(Body 可能为空对象)
HasBody bool
}
Operation 是 OpenAPI 文档中的一个接口。
func ParseOperations ¶
ParseOperations 解析 OpenAPI JSON。
func (Operation) IsReadOnly ¶ added in v0.6.0
IsReadOnly 判断接口是否真正只读:GET 但需要写权限的接口(取回密码明文的 secrets、 容器 exec、私钥下载等)不算只读,MCP 默认只读模式下不暴露。