Documentation
¶
Index ¶
- func ConvertDbMCPServerToOpenapi(dbServer models.MCPServer) *openapi.MCPServer
- func ConvertDbMCPServerWithToolsToOpenapi(dbServer models.MCPServer, tools []models.MCPServerTool) *openapi.MCPServer
- func ConvertDbMCPToolToOpenapi(dbTool models.MCPServerTool) *openapi.MCPTool
- func ConvertOpenapiMCPServerToDb(openapiServer *openapi.MCPServer) models.MCPServer
- func ConvertOpenapiMCPToolToDb(openapiTool *openapi.MCPTool) models.MCPServerTool
- func UnqualifyToolName(name string) string
- type PropertyAccessor
- func (pa *PropertyAccessor) GetBoolPtr(name string) *bool
- func (pa *PropertyAccessor) GetInt(name string) int64
- func (pa *PropertyAccessor) GetString(name string) string
- func (pa *PropertyAccessor) GetStringArray(name string) []string
- func (pa *PropertyAccessor) GetStringPtr(name string) *string
- func (pa *PropertyAccessor) HasAny(names ...string) bool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConvertDbMCPServerToOpenapi ¶
ConvertDbMCPServerToOpenapi converts a database MCPServer model to an OpenAPI MCPServer. This extracts all properties from the database model and populates the OpenAPI struct. It does NOT populate ToolCount or the Tools array — callers MUST set ToolCount (e.g. via CountByParentIDs) to avoid returning an incorrect zero value.
func ConvertDbMCPServerWithToolsToOpenapi ¶
func ConvertDbMCPServerWithToolsToOpenapi(dbServer models.MCPServer, tools []models.MCPServerTool) *openapi.MCPServer
ConvertDbMCPServerWithToolsToOpenapi converts a database MCPServer to OpenAPI representation with accurate tool count and tools array populated from the provided tools.
Parameters:
- dbServer: The database server entity to convert
- tools: Associated tools (can be nil or empty for toolCount=0)
This is the preferred method when tools have been loaded via repository queries.
func ConvertDbMCPToolToOpenapi ¶
func ConvertDbMCPToolToOpenapi(dbTool models.MCPServerTool) *openapi.MCPTool
ConvertDbMCPToolToOpenapi converts a database MCPServerTool to OpenAPI MCPTool.
func ConvertOpenapiMCPServerToDb ¶
ConvertOpenapiMCPServerToDb converts an OpenAPI MCPServer to a database MCPServer model. This sets all properties from the OpenAPI struct into the database model's Properties field.
func ConvertOpenapiMCPToolToDb ¶
func ConvertOpenapiMCPToolToDb(openapiTool *openapi.MCPTool) models.MCPServerTool
ConvertOpenapiMCPToolToDb converts an OpenAPI MCPTool to database MCPServerTool.
func UnqualifyToolName ¶
UnqualifyToolName strips the "serverName@version:" prefix from a qualified tool name, returning just the tool name portion. If the name contains no colon, it is returned unchanged.
Types ¶
type PropertyAccessor ¶
type PropertyAccessor struct {
// contains filtered or unexported fields
}
PropertyAccessor provides O(1) access to database properties via map lookup. This improves performance when multiple properties need to be accessed from the same properties slice, avoiding O(n²) complexity from repeated linear scans.
The accessor is safe for concurrent read operations after construction.
func NewPropertyAccessor ¶
func NewPropertyAccessor(props *[]dbmodels.Properties) *PropertyAccessor
NewPropertyAccessor creates a property accessor from a properties slice. Returns a nil-safe accessor even if props is nil.
Time complexity: O(n) where n is the number of properties. Subsequent lookups via Get* methods are O(1).
func (*PropertyAccessor) GetBoolPtr ¶
func (pa *PropertyAccessor) GetBoolPtr(name string) *bool
GetBoolPtr retrieves a boolean property as a pointer. Returns nil if the property doesn't exist or has no value.
func (*PropertyAccessor) GetInt ¶
func (pa *PropertyAccessor) GetInt(name string) int64
GetInt retrieves an int64 property value (converts from int32 storage). Returns 0 if the property doesn't exist or has no value.
func (*PropertyAccessor) GetString ¶
func (pa *PropertyAccessor) GetString(name string) string
GetString retrieves a string property value. Returns empty string if the property doesn't exist or has no value.
func (*PropertyAccessor) GetStringArray ¶
func (pa *PropertyAccessor) GetStringArray(name string) []string
GetStringArray retrieves a JSON-encoded string array property. Returns nil if the property doesn't exist, is empty, or cannot be unmarshaled.
func (*PropertyAccessor) GetStringPtr ¶
func (pa *PropertyAccessor) GetStringPtr(name string) *string
GetStringPtr retrieves a string property as a pointer. Returns nil if the property doesn't exist, has no value, or is an empty string.
func (*PropertyAccessor) HasAny ¶
func (pa *PropertyAccessor) HasAny(names ...string) bool
HasAny returns true if any of the specified property names exist in the property map. This is useful for checking if a group of optional properties has at least one value.