Documentation
¶
Index ¶
- type ClientBucket
- type LoggerWriter
- type MigrationApplyParams
- type MigrationCreateParams
- type MigrationStatusParams
- type ModelAggregateParams
- type ModelCountParams
- type ModelCreateParams
- type ModelDeleteParams
- type ModelFindManyParams
- type ModelFindUniqueParams
- type ModelUpdateParams
- type PendingSchemaManager
- func (p *PendingSchemaManager) AddSchema(s *schema.Schema)
- func (p *PendingSchemaManager) GetPendingSchemas() map[string]*schema.Schema
- func (p *PendingSchemaManager) ProcessPendingSchemas(ctx context.Context, db types.Database) (*TableCreationResult, error)
- func (p *PendingSchemaManager) RemoveSchema(name string)
- type RateLimiter
- type SDKServer
- type SchemaAddFieldParams
- type SchemaAddRelationParams
- type SchemaCreateParams
- type SchemaDescribeParams
- type SchemaFieldDefinition
- type SchemaFieldUpdate
- type SchemaIndexDefinition
- type SchemaModelsParams
- type SchemaRelationDefinition
- type SchemaRemoveFieldParams
- type SchemaUpdateParams
- type SecurityConfig
- type SecurityManager
- func (sm *SecurityManager) AuthenticateRequest(r *http.Request) error
- func (sm *SecurityManager) CheckRateLimit(clientIP string) error
- func (sm *SecurityManager) CheckReadOnly(operation string) error
- func (sm *SecurityManager) GetStats() map[string]any
- func (sm *SecurityManager) SecurityMiddleware(next http.Handler) http.Handler
- func (sm *SecurityManager) ValidateHost(r *http.Request) error
- type ServerConfig
- type TableCreationResult
- type TransactionOperation
- type TransactionParams
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ClientBucket ¶
type ClientBucket struct {
// contains filtered or unexported fields
}
ClientBucket represents a token bucket for a specific client
type LoggerWriter ¶ added in v0.6.0
type LoggerWriter struct {
// contains filtered or unexported fields
}
LoggerWriter implements io.Writer to bridge MCP's logging to our logger
func NewLoggerWriter ¶ added in v0.6.0
func NewLoggerWriter(l logger.Logger, prefix string) *LoggerWriter
NewLoggerWriter creates a new logger writer
type MigrationApplyParams ¶ added in v0.6.0
type MigrationApplyParams struct {
DryRun *bool `json:"dry_run,omitempty" jsonschema:"Preview without applying"`
}
type MigrationCreateParams ¶ added in v0.6.0
type MigrationStatusParams ¶ added in v0.6.0
type MigrationStatusParams struct{}
type ModelAggregateParams ¶ added in v0.6.0
type ModelAggregateParams struct { Model string `json:"model" jsonschema:"Model name"` Where map[string]any `json:"where,omitempty" jsonschema:"Filter conditions"` Count *bool `json:"count,omitempty"` Avg map[string]bool `json:"avg,omitempty"` Sum map[string]bool `json:"sum,omitempty"` Min map[string]bool `json:"min,omitempty"` Max map[string]bool `json:"max,omitempty"` GroupBy []string `json:"groupBy,omitempty"` }
type ModelCountParams ¶ added in v0.6.0
type ModelCreateParams ¶ added in v0.6.0
type ModelDeleteParams ¶ added in v0.6.0
type ModelFindManyParams ¶ added in v0.6.0
type ModelFindManyParams struct { Model string `json:"model" jsonschema:"Model name"` Where map[string]any `json:"where,omitempty" jsonschema:"Filter conditions"` Include map[string]any `json:"include,omitempty" jsonschema:"Relations to include"` OrderBy map[string]any `json:"orderBy,omitempty" jsonschema:"Sort order"` Take *int `json:"take,omitempty" jsonschema:"Limit results"` Skip *int `json:"skip,omitempty" jsonschema:"Skip results"` }
Tool parameter structs
type ModelFindUniqueParams ¶ added in v0.6.0
type ModelUpdateParams ¶ added in v0.6.0
type PendingSchemaManager ¶ added in v0.6.0
type PendingSchemaManager struct {
// contains filtered or unexported fields
}
PendingSchemaManager manages schemas that are waiting for their dependencies
func NewPendingSchemaManager ¶ added in v0.6.0
func NewPendingSchemaManager(logger logger.Logger) *PendingSchemaManager
NewPendingSchemaManager creates a new pending schema manager
func (*PendingSchemaManager) AddSchema ¶ added in v0.6.0
func (p *PendingSchemaManager) AddSchema(s *schema.Schema)
AddSchema adds a schema to the pending queue
func (*PendingSchemaManager) GetPendingSchemas ¶ added in v0.6.0
func (p *PendingSchemaManager) GetPendingSchemas() map[string]*schema.Schema
GetPendingSchemas returns a copy of all pending schemas
func (*PendingSchemaManager) ProcessPendingSchemas ¶ added in v0.6.0
func (p *PendingSchemaManager) ProcessPendingSchemas(ctx context.Context, db types.Database) (*TableCreationResult, error)
ProcessPendingSchemas attempts to create tables for all pending schemas
func (*PendingSchemaManager) RemoveSchema ¶ added in v0.6.0
func (p *PendingSchemaManager) RemoveSchema(name string)
RemoveSchema removes a schema from the pending queue
type RateLimiter ¶
type RateLimiter struct {
// contains filtered or unexported fields
}
RateLimiter implements token bucket rate limiting
func NewRateLimiter ¶
func NewRateLimiter(requestsPerMin, burstLimit int) *RateLimiter
NewRateLimiter creates a new rate limiter
func (*RateLimiter) Allow ¶
func (rl *RateLimiter) Allow(clientIP string) bool
Allow checks if a request from the given client IP is allowed
func (*RateLimiter) Stop ¶
func (rl *RateLimiter) Stop()
Stop stops the rate limiter cleanup routine
type SDKServer ¶ added in v0.6.0
type SDKServer struct {
// contains filtered or unexported fields
}
SDKServer wraps the MCP SDK server
func NewSDKServer ¶ added in v0.6.0
func NewSDKServer(config ServerConfig) (*SDKServer, error)
NewSDKServer creates a new MCP server using the official SDK
type SchemaAddFieldParams ¶ added in v0.6.0
type SchemaAddFieldParams struct { Model string `json:"model" jsonschema:"Model name"` Field SchemaFieldDefinition `json:"field" jsonschema:"Field definition"` }
type SchemaAddRelationParams ¶ added in v0.6.0
type SchemaAddRelationParams struct { Model string `json:"model" jsonschema:"Model name"` Relation SchemaRelationDefinition `json:"relation" jsonschema:"Relation definition"` }
type SchemaCreateParams ¶ added in v0.6.0
type SchemaCreateParams struct { Model string `json:"model" jsonschema:"Model name"` Fields []SchemaFieldDefinition `json:"fields" jsonschema:"Field definitions"` Relations []SchemaRelationDefinition `json:"relations,omitempty" jsonschema:"Relation definitions"` Indexes []SchemaIndexDefinition `json:"indexes,omitempty" jsonschema:"Index definitions"` TableName string `json:"tableName,omitempty" jsonschema:"Custom table name"` }
Schema modification tool parameters
type SchemaDescribeParams ¶ added in v0.6.0
type SchemaDescribeParams struct {
Model string `json:"model" jsonschema:"Model name"`
}
type SchemaFieldDefinition ¶ added in v0.6.0
type SchemaFieldDefinition struct { Name string `json:"name" jsonschema:"Field name"` Type string `json:"type" jsonschema:"Field type (String, Int, Boolean, DateTime, etc.)"` Optional bool `json:"optional,omitempty" jsonschema:"Is field optional/nullable"` List bool `json:"list,omitempty" jsonschema:"Is field an array"` Unique bool `json:"unique,omitempty" jsonschema:"Is field unique"` PrimaryKey bool `json:"primaryKey,omitempty" jsonschema:"Is primary key"` AutoIncrement bool `json:"autoIncrement,omitempty" jsonschema:"Auto-increment integer"` Default any `json:"default,omitempty" jsonschema:"Default value"` DbType string `json:"dbType,omitempty" jsonschema:"Database-specific type"` }
Helper types for field and relation definitions
type SchemaFieldUpdate ¶ added in v0.6.0
type SchemaIndexDefinition ¶ added in v0.6.0
type SchemaModelsParams ¶ added in v0.6.0
type SchemaModelsParams struct{}
type SchemaRelationDefinition ¶ added in v0.6.0
type SchemaRelationDefinition struct { Name string `json:"name" jsonschema:"Relation field name"` Type string `json:"type" jsonschema:"Relation type (oneToOne, oneToMany, manyToOne, manyToMany)"` Model string `json:"model" jsonschema:"Related model name"` ForeignKey string `json:"foreignKey,omitempty" jsonschema:"Foreign key field"` References string `json:"references,omitempty" jsonschema:"Referenced field"` }
type SchemaRemoveFieldParams ¶ added in v0.6.0
type SchemaUpdateParams ¶ added in v0.6.0
type SchemaUpdateParams struct { Model string `json:"model" jsonschema:"Model name to update"` AddFields []SchemaFieldDefinition `json:"addFields,omitempty" jsonschema:"Fields to add"` RemoveFields []string `json:"removeFields,omitempty" jsonschema:"Field names to remove"` UpdateFields []SchemaFieldUpdate `json:"updateFields,omitempty" jsonschema:"Fields to update"` AddRelations []SchemaRelationDefinition `json:"addRelations,omitempty" jsonschema:"Relations to add"` RemoveRelations []string `json:"removeRelations,omitempty" jsonschema:"Relation names to remove"` }
type SecurityConfig ¶
type SecurityConfig struct { // Authentication EnableAuth bool APIKey string AllowedHosts []string // Rate limiting EnableRateLimit bool RequestsPerMin int BurstLimit int // Permissions ReadOnlyMode bool MaxQueryRows int QueryTimeout time.Duration }
SecurityConfig holds security configuration
type SecurityManager ¶
type SecurityManager struct {
// contains filtered or unexported fields
}
SecurityManager handles authentication, authorization, and rate limiting
func NewSecurityManager ¶
func NewSecurityManager(config SecurityConfig) *SecurityManager
NewSecurityManager creates a new security manager
func (*SecurityManager) AuthenticateRequest ¶
func (sm *SecurityManager) AuthenticateRequest(r *http.Request) error
AuthenticateRequest validates authentication for HTTP requests
func (*SecurityManager) CheckRateLimit ¶
func (sm *SecurityManager) CheckRateLimit(clientIP string) error
CheckRateLimit verifies if the request is within rate limits
func (*SecurityManager) CheckReadOnly ¶ added in v0.6.0
func (sm *SecurityManager) CheckReadOnly(operation string) error
CheckReadOnly checks if an operation is allowed in read-only mode
func (*SecurityManager) GetStats ¶
func (sm *SecurityManager) GetStats() map[string]any
GetStats returns security statistics
func (*SecurityManager) SecurityMiddleware ¶
func (sm *SecurityManager) SecurityMiddleware(next http.Handler) http.Handler
SecurityMiddleware returns an HTTP middleware for security validation
func (*SecurityManager) ValidateHost ¶
func (sm *SecurityManager) ValidateHost(r *http.Request) error
ValidateHost checks if the request comes from an allowed host
type ServerConfig ¶
type ServerConfig struct { DatabaseURI string SchemaPath string Transport string Port int LogLevel string ReadOnly bool Security SecurityConfig Version string // Version of the MCP server }
ServerConfig holds the configuration for the MCP server
type TableCreationResult ¶ added in v0.6.0
type TableCreationResult struct { TablesCreated []string `json:"tables_created"` PendingSchemas []string `json:"pending_schemas"` DependencyInfo map[string][]string `json:"dependency_info"` Errors []string `json:"errors,omitempty"` CircularDeps bool `json:"has_circular_dependencies"` }
TableCreationResult represents the result of attempting to create tables
type TransactionOperation ¶ added in v0.6.0
type TransactionParams ¶ added in v0.6.0
type TransactionParams struct {
Operations []TransactionOperation `json:"operations" jsonschema:"Array of operations to execute"`
}