Documentation
¶
Index ¶
- Constants
- type ArgConfig
- type Auth
- type CORSConfig
- type ChangePasswordRequest
- type ChangePasswordResponse
- type CreateTenantRequest
- type CreateUserRequest
- type InitializeRequest
- type ItemsConfig
- type LoginRequest
- type LoginResponse
- type MCPConfig
- type MCPServer
- type MCPServerConfig
- type ProxyConfig
- type RouterConfig
- type ServerConfig
- type TenantResponse
- type TenantUserRequest
- type Tool
- type ToolCall
- type ToolCallResponse
- type ToolConfig
- type ToolFunction
- type ToolParameters
- type ToolResult
- type UpdateTenantRequest
- type UpdateUserRequest
- type UserInfo
- type UserResponse
- type UserTenantRequest
- type WebSocketMessage
- type WebSocketResponse
Constants ¶
const ( MsgTypeMessage = "message" MsgTypeStream = "stream" MsgTypeToolCall = "tool_call" MsgTypeToolResult = "tool_result" )
MsgType represents the type of WebSocket message
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ArgConfig ¶ added in v0.5.0
type ArgConfig struct {
Name string `json:"name"`
Position string `json:"position"` // header, query, path, body
Required bool `json:"required"`
Type string `json:"type"`
Description string `json:"description"`
Default string `json:"default"`
Items ItemsConfig `json:"items,omitempty"`
}
func FromArgConfigs ¶ added in v0.5.0
FromArgConfigs converts a slice of config.ArgConfig to dto.ArgConfig
type Auth ¶ added in v0.6.0
type Auth struct {
Mode string `json:"mode"`
}
func FromAuthConfig ¶ added in v0.6.0
FromAuthConfig converts a config.Auth to dto.Auth
type CORSConfig ¶ added in v0.5.0
type CORSConfig struct {
AllowOrigins []string `json:"allowOrigins,omitempty"`
AllowMethods []string `json:"allowMethods,omitempty"`
AllowHeaders []string `json:"allowHeaders,omitempty"`
ExposeHeaders []string `json:"exposeHeaders,omitempty"`
AllowCredentials bool `json:"allowCredentials"`
}
func FromCORSConfig ¶ added in v0.5.0
func FromCORSConfig(cfg *config.CORSConfig) *CORSConfig
FromCORSConfig converts a config.CORSConfig to dto.CORSConfig
type ChangePasswordRequest ¶ added in v0.3.2
type ChangePasswordRequest struct {
OldPassword string `json:"oldPassword" binding:"required"`
NewPassword string `json:"newPassword" binding:"required"`
}
ChangePasswordRequest represents a request to change password
type ChangePasswordResponse ¶ added in v0.3.2
type ChangePasswordResponse struct {
Success bool `json:"success"`
}
ChangePasswordResponse represents a response to change password
type CreateTenantRequest ¶ added in v0.4.0
type CreateTenantRequest struct {
Name string `json:"name" binding:"required"`
Prefix string `json:"prefix" binding:"required"`
Description string `json:"description"`
}
CreateTenantRequest represents a request to create a new tenant
type CreateUserRequest ¶ added in v0.3.2
type CreateUserRequest struct {
Username string `json:"username" binding:"required"`
Password string `json:"password" binding:"required"`
Role string `json:"role" binding:"required,oneof=admin normal"`
TenantIDs []uint `json:"tenantIds,omitempty"`
}
CreateUserRequest represents a request to create a new user
type InitializeRequest ¶ added in v0.3.1
type InitializeRequest struct {
Username string `json:"username"`
Password string `json:"password"`
}
InitializeRequest represents an initialization request
type ItemsConfig ¶ added in v0.5.0
func FromItemsConfig ¶ added in v0.5.0
func FromItemsConfig(cfg config.ItemsConfig) ItemsConfig
FromItemsConfig converts a config.ItemsConfig to dto.ItemsConfig
type LoginRequest ¶ added in v0.3.1
LoginRequest represents a login request
type LoginResponse ¶ added in v0.3.1
type LoginResponse struct {
Token string `json:"token"`
}
LoginResponse represents a login response
type MCPConfig ¶ added in v0.5.0
type MCPConfig struct {
Name string `json:"name"`
Tenant string `json:"tenant"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
DeletedAt time.Time `json:"deletedAt,omitempty"`
Routers []RouterConfig `json:"routers,omitempty"`
Servers []ServerConfig `json:"servers,omitempty"`
Tools []ToolConfig `json:"tools,omitempty"`
McpServers []MCPServerConfig `json:"mcpServers,omitempty"`
}
type MCPServer ¶
type MCPServer struct {
Name string `json:"name"`
Tenant string `json:"tenant"`
McpServers []MCPServerConfig `json:"mcpServers,omitempty"`
Tools []ToolConfig `json:"tools,omitempty"`
Servers []ServerConfig `json:"servers,omitempty"`
Routers []RouterConfig `json:"routers,omitempty"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
}
func FromConfig ¶ added in v0.5.0
FromConfig converts a config.MCPConfig to dto.MCPServer
type MCPServerConfig ¶ added in v0.5.0
type MCPServerConfig struct {
Type string `json:"type"` // sse, stdio and streamable-http
Name string `json:"name"` // server name
Command string `json:"command,omitempty"` // for stdio
Args []string `json:"args,omitempty"` // for stdio
Env map[string]string `json:"env,omitempty"` // for stdio
URL string `json:"url,omitempty"` // for sse and streamable-http
Policy string `json:"policy"` // onStart or onDemand
Preinstalled bool `json:"preinstalled"` // whether to install this MCP server when mcp-gateway starts
}
func FromMCPServerConfigs ¶ added in v0.5.0
func FromMCPServerConfigs(cfgs []config.MCPServerConfig) []MCPServerConfig
FromMCPServerConfigs converts a slice of config.MCPServerConfig to dto.MCPServerConfig
type ProxyConfig ¶ added in v0.5.0
type ProxyConfig struct {
Host string `json:"host"`
Port int `json:"port"`
Type string `json:"type"` // http, https, socks5
}
func FromProxyConfig ¶ added in v0.5.0
func FromProxyConfig(cfg *config.ProxyConfig) *ProxyConfig
FromProxyConfig converts a config.ProxyConfig to dto.ProxyConfig
type RouterConfig ¶ added in v0.5.0
type RouterConfig struct {
Server string `json:"server"`
Prefix string `json:"prefix"`
SSEPrefix string `json:"ssePrefix,omitempty"`
CORS *CORSConfig `json:"cors,omitempty"`
Auth *Auth `json:"auth,omitempty"`
}
func FromRouterConfigs ¶ added in v0.5.0
func FromRouterConfigs(cfgs []config.RouterConfig) []RouterConfig
FromRouterConfigs converts a slice of config.RouterConfig to dto.RouterConfig
type ServerConfig ¶ added in v0.5.0
type ServerConfig struct {
Name string `json:"name"`
Description string `json:"description"`
AllowedTools []string `json:"allowedTools,omitempty"`
Config map[string]string `json:"config,omitempty"`
}
func FromServerConfigs ¶ added in v0.5.0
func FromServerConfigs(cfgs []config.ServerConfig) []ServerConfig
FromServerConfigs converts a slice of config.ServerConfig to dto.ServerConfig
type TenantResponse ¶ added in v0.4.0
type TenantResponse struct {
ID uint `json:"id"`
Name string `json:"name"`
Prefix string `json:"prefix"`
Description string `json:"description"`
IsActive bool `json:"isActive"`
}
TenantResponse represents a tenant information response
type TenantUserRequest ¶ added in v0.4.0
type TenantUserRequest struct {
TenantID uint `json:"tenantId" binding:"required"`
UserIDs []uint `json:"userIds" binding:"required"`
}
TenantUserRequest represents a request to add or remove user associations
type Tool ¶
type Tool struct {
Name string `json:"name"`
Description string `json:"description"`
Parameters ToolParameters `json:"parameters"`
}
Tool represents a tool that can be called by the LLM
type ToolCall ¶
type ToolCall struct {
ID string `json:"id"`
Type string `json:"type"`
Function ToolFunction `json:"function"`
}
ToolCall represents a tool call from the LLM
type ToolCallResponse ¶
type ToolCallResponse struct {
Name string `json:"name"`
Arguments map[string]interface{} `json:"arguments"`
}
ToolCallResponse represents the response for a tool call
type ToolConfig ¶ added in v0.5.0
type ToolConfig struct {
Name string `json:"name"`
Description string `json:"description,omitempty"`
Method string `json:"method"`
Endpoint string `json:"endpoint"`
Proxy *ProxyConfig `json:"proxy,omitempty"`
Headers map[string]string `json:"headers,omitempty"`
Args []ArgConfig `json:"args,omitempty"`
RequestBody string `json:"requestBody"`
ResponseBody string `json:"responseBody"`
InputSchema map[string]any `json:"inputSchema,omitempty"`
}
func FromToolConfigs ¶ added in v0.5.0
func FromToolConfigs(cfgs []config.ToolConfig) []ToolConfig
FromToolConfigs converts a slice of config.ToolConfig to dto.ToolConfig
type ToolFunction ¶
ToolFunction represents the function details of a tool call
type ToolParameters ¶
type ToolParameters struct {
Properties map[string]interface{} `json:"properties"`
Required []string `json:"required"`
}
ToolParameters represents the parameters of a tool
type ToolResult ¶
type ToolResult struct {
Name string `json:"name"`
Result string `json:"result"`
ToolCallID string `json:"toolCallId"`
}
ToolResult represents the result of a tool call
type UpdateTenantRequest ¶ added in v0.4.0
type UpdateTenantRequest struct {
Name string `json:"name" binding:"required"`
Prefix string `json:"prefix,omitempty"`
Description string `json:"description,omitempty"`
IsActive *bool `json:"isActive,omitempty"`
}
UpdateTenantRequest represents a request to update a tenant
type UpdateUserRequest ¶ added in v0.3.2
type UpdateUserRequest struct {
Username string `json:"username" binding:"required"`
Password string `json:"password,omitempty"`
Role string `json:"role,omitempty" binding:"omitempty,oneof=admin normal"`
IsActive *bool `json:"isActive,omitempty"`
TenantIDs []uint `json:"tenantIds,omitempty"`
}
UpdateUserRequest represents a request to update a user
type UserInfo ¶ added in v0.3.2
type UserInfo struct {
ID uint `json:"id"`
Username string `json:"username"`
Role string `json:"role"`
}
UserInfo represents the user information stored in the context
type UserResponse ¶ added in v0.4.0
type UserResponse struct {
ID uint `json:"id"`
Username string `json:"username"`
Role string `json:"role"`
IsActive bool `json:"isActive"`
Tenants []*TenantResponse `json:"tenants,omitempty"`
}
UserResponse represents a user with their associated tenants
type UserTenantRequest ¶ added in v0.4.0
type UserTenantRequest struct {
UserID uint `json:"userId" binding:"required"`
TenantIDs []uint `json:"tenantIds" binding:"required"`
}
UserTenantRequest represents a request to add or remove tenant associations
type WebSocketMessage ¶
type WebSocketMessage struct {
Type string `json:"type"`
Content string `json:"content"`
Sender string `json:"sender"`
Timestamp int64 `json:"timestamp"`
ID string `json:"id"`
Tools []Tool `json:"tools,omitempty"`
ToolResult *ToolResult `json:"toolResult,omitempty"`
}
WebSocketMessage represents a message sent over WebSocket
type WebSocketResponse ¶
type WebSocketResponse struct {
Type string `json:"type"`
Content string `json:"content"`
Sender string `json:"sender"`
Timestamp int64 `json:"timestamp"`
ID string `json:"id"`
ToolCalls []ToolCall `json:"toolCalls,omitempty"`
}
WebSocketResponse represents a response sent over WebSocket