Documentation
¶
Overview ¶
Package serv provides an API to include and use the GraphJin service with your own code. For detailed documentation visit https://graphjin.com
Example usage:
package main
import (
"database/sql"
"fmt"
"time"
"github.com/dosco/graphjin/core/v3"
_ "github.com/jackc/pgx/v5/stdlib"
)
func main() {
conf := serv.Config{ AppName: "Test App" }
conf.DB.Host := "127.0.0.1"
conf.DB.Port := 5432
conf.DB.DBName := "test_db"
conf.DB.User := "postgres"
conf.DB.Password := "postgres"
gjs, err := serv.NewGraphJinService(conf)
if err != nil {
log.Fatal(err)
}
if err := gjs.Start(); err != nil {
log.Fatal(err)
}
}
Index ¶
- Variables
- func GetConfigName() string
- func InitAdmin(db *sql.DB, dbtype string) error
- func InitTelemetry(context context.Context, exporter trace.SpanExporter, ...) error
- func NewDB(conf *Config, openDB bool, log *zap.SugaredLogger, fs core.FS) (*sql.DB, error)
- type AggregationInfo
- type AggregationsSyntax
- type ApplyDatabaseSetupResult
- type ApplyVerification
- type Auth
- type CacheEntry
- type CacheMetrics
- type CachingConfig
- type ColumnConfigInput
- type ColumnTypeInfo
- type Config
- type ConfigField
- type ConfigSection
- type ConfigUpdateRequest
- type ConfigUpdateResult
- type ConnectDisconnect
- type ConnectionTestResult
- type Core
- type CursorCache
- type DDLApplyResult
- type DDLOperationInfo
- type DDLPreviewResult
- type DDLSummary
- type Database
- type DatabaseConfigInput
- type DatabaseConnection
- type DeleteConfigInput
- type DiscoverResult
- type DiscoverSummary
- type DiscoverTarget
- type DiscoveredDatabase
- type DockerDBInfo
- type EnhancedError
- type ErrorInfo
- type ExampleQuery
- type ExecuteResult
- type FilterOperators
- type FunctionConfigInput
- type HealthResult
- type HookFn
- type HttpService
- func (s *HttpService) Attach(mux Mux) error
- func (s *HttpService) AttachWithNS(mux Mux, namespace string) error
- func (s *HttpService) Deploy(conf *Config, options ...Option) error
- func (s *HttpService) GetDB() *sql.DB
- func (s *HttpService) GetGraphJin() *core.GraphJin
- func (s *HttpService) GraphQL(ah auth.HandlerFunc) http.Handler
- func (s *HttpService) GraphQLWithNS(ah auth.HandlerFunc, ns string) http.Handler
- func (s *HttpService) MCPHandler() http.Handler
- func (s *HttpService) MCPHandlerWithAuth(ah auth.HandlerFunc) http.Handler
- func (s *HttpService) MCPMessageHandler() http.Handler
- func (s *HttpService) MCPMessageHandlerWithAuth(ah auth.HandlerFunc) http.Handler
- func (s *HttpService) OpenAPI() http.Handler
- func (s *HttpService) OpenAPIWithNS(ns string) http.Handler
- func (s *HttpService) REST(ah auth.HandlerFunc) http.Handler
- func (s *HttpService) RESTWithNS(ah auth.HandlerFunc, ns string) http.Handler
- func (s *HttpService) Reload() error
- func (s *HttpService) RunMCPStdio(ctx context.Context) error
- func (s *HttpService) Start() error
- func (s *HttpService) WebUI(routePrefix, gqlEndpoint string) http.Handler
- func (s *HttpService) Workflows(ah auth.HandlerFunc) http.Handler
- func (s *HttpService) WorkflowsWithNS(ah auth.HandlerFunc, ns string) http.Handler
- type InsertConfigInput
- type JSRuntimeAPI
- type JSRuntimeFunction
- type JSRuntimeGlobal
- type JWTConfig
- type ListDatabasesResult
- type MCPConfig
- type MCPConfigResponse
- type MemoryCache
- func (mc *MemoryCache) Close() error
- func (mc *MemoryCache) Get(ctx context.Context, key string) ([]byte, bool, bool)
- func (mc *MemoryCache) InvalidateRows(ctx context.Context, refs []core.RowRef) error
- func (mc *MemoryCache) Metrics() *CacheMetrics
- func (mc *MemoryCache) Set(ctx context.Context, key string, data []byte, refs []core.RowRef, ...) error
- type MemoryCursorCache
- type MistakeExample
- type MutationOperations
- type MutationSyntaxReference
- type Mux
- type NestedMutationInfo
- type NextGuidance
- type NextOption
- type OnboardingStatusResult
- type Option
- type OrderingSyntax
- type PaginationSyntax
- type Payload
- type PoolStatsInfo
- type QueryConfigInput
- type QueryExample
- type QueryExamplesForSyntax
- type QuerySyntaxReference
- type RateLimiter
- type RecursiveSyntax
- type RedisCache
- func (c *RedisCache) Close() error
- func (c *RedisCache) Get(ctx context.Context, key string) ([]byte, bool, bool)
- func (c *RedisCache) InvalidateRows(ctx context.Context, refs []core.RowRef) error
- func (c *RedisCache) Metrics() *CacheMetrics
- func (c *RedisCache) Set(ctx context.Context, key string, data []byte, refs []core.RowRef, ...) error
- type RedisConfig
- type RedisCursorCache
- type RefreshJob
- type ResolverConfigInput
- type ResponseCache
- type ReturningInfo
- type RoleConfigInput
- type RoleInfo
- type RoleTableConfigInput
- type SWRWorkerPool
- type Serv
- type SetHeaderInput
- type SetupPlanResult
- type TableConfigInput
- type TableSchemaWithAggregations
- type UpdateConfigInput
- type UpsertConfigInput
- type ValidationSyntax
- type VariablesSyntax
- type WhereValidationError
- type WhereValidationResult
- type WorkflowGuide
Constants ¶
This section is empty.
Variables ¶
var ErrGraphJinNotInitialized = errors.New("GraphJin not initialized - no database configured")
ErrGraphJinNotInitialized is returned when GraphJin core is not initialized
Functions ¶
func GetConfigName ¶
func GetConfigName() string
GetConfigName returns the name of the configuration
func InitTelemetry ¶
func InitTelemetry( context context.Context, exporter trace.SpanExporter, serviceName, serviceInstanceID string, ) error
InitTelemetry initializes the OpenTelemetry SDK with the given exporter and service name.
Types ¶
type AggregationInfo ¶ added in v3.2.1
AggregationInfo describes available aggregation functions for a table
type AggregationsSyntax ¶ added in v3.2.1
type AggregationsSyntax struct {
Functions []string `json:"functions"`
Usage string `json:"usage"`
WithGroup string `json:"with_group"`
}
AggregationsSyntax describes available aggregation functions
type ApplyDatabaseSetupResult ¶ added in v3.10.3
type ApplyDatabaseSetupResult struct {
Applied bool `json:"applied"`
Success bool `json:"success"`
Message string `json:"message"`
DatabaseAlias string `json:"database_alias,omitempty"`
TableCount int `json:"table_count"`
Tables []string `json:"tables,omitempty"`
Verification ApplyVerification `json:"verification"`
Errors []string `json:"errors,omitempty"`
Next *NextGuidance `json:"next,omitempty"`
}
type ApplyVerification ¶ added in v3.10.3
type CacheEntry ¶ added in v3.2.1
type CacheEntry struct {
Data []byte `json:"d"`
Compressed bool `json:"c,omitempty"`
OriginalSize int `json:"o,omitempty"`
FreshUntil int64 `json:"f"`
StaleUntil int64 `json:"s"`
}
CacheEntry represents a cached response with metadata
type CacheMetrics ¶ added in v3.2.1
type CacheMetrics struct {
Hits atomic.Int64
Misses atomic.Int64
Invalidations atomic.Int64
BytesCached atomic.Int64
BytesSaved atomic.Int64 // Compression savings
Errors atomic.Int64
SWRRefreshes atomic.Int64
}
CacheMetrics tracks cache performance
func (*CacheMetrics) HitRate ¶ added in v3.2.1
func (m *CacheMetrics) HitRate() float64
HitRate returns the cache hit rate (0.0 to 1.0)
func (*CacheMetrics) Snapshot ¶ added in v3.2.1
func (m *CacheMetrics) Snapshot() map[string]int64
Snapshot returns a point-in-time snapshot of metrics
type CachingConfig ¶ added in v3.2.1
type CachingConfig struct {
// Disable response caching (caching is enabled by default)
Disable bool `mapstructure:"disable" jsonschema:"title=Disable Caching,default=false"`
// Default TTL for cached responses in seconds (hard TTL)
TTL int `mapstructure:"ttl" jsonschema:"title=Cache TTL,default=3600"`
// Soft TTL for stale-while-revalidate in seconds (0 = disabled)
FreshTTL int `mapstructure:"fresh_ttl" jsonschema:"title=Fresh TTL for SWR,default=300"`
// Tables to exclude from caching
ExcludeTables []string `mapstructure:"exclude_tables" jsonschema:"title=Exclude Tables"`
}
CachingConfig configures response caching Caching is enabled by default using in-memory LRU cache Configure redis.url to use Redis for distributed caching Responses are cached with automatic invalidation when mutations modify related tables
type ColumnConfigInput ¶ added in v3.2.1
type ColumnConfigInput struct {
Name string `json:"name"`
Type string `json:"type,omitempty"`
Primary bool `json:"primary,omitempty"`
Array bool `json:"array,omitempty"`
FullText bool `json:"full_text,omitempty"`
ForeignKey string `json:"related_to,omitempty"`
}
ColumnConfigInput represents a column config for input
type ColumnTypeInfo ¶ added in v3.2.1
type ColumnTypeInfo struct {
Type string `json:"type"`
ValidOperators []string `json:"valid_operators"`
}
ColumnTypeInfo provides information about a column's type and valid operators
type Config ¶
type Config struct {
// Configuration for the GraphJin compiler core
Core `mapstructure:",squash" jsonschema:"title=Compiler Configuration"`
// Configuration for the GraphJin Service
Serv `mapstructure:",squash" jsonschema:"title=Service Configuration"`
// contains filtered or unexported fields
}
Configuration for the GraphJin service
func NewConfig ¶
NewConfig function creates a new GraphJin configuration from the provided config string
func ReadInConfig ¶
ReadInConfig function reads in the config file for the environment specified in the GO_ENV environment variable. This is the best way to create a new GraphJin config.
func ReadInConfigFS ¶
ReadInConfigFS is the same as ReadInConfig but it also takes a filesytem as an argument
func (*Config) AbsolutePath ¶
AbsolutePath returns the absolute path of the file
func (*Config) ShouldUseJSONLogs ¶ added in v3.2.1
ShouldUseJSONLogs returns true if logs should be in JSON format. Returns true if log_format is "json" OR if log_format is "auto" and production mode is enabled. Returns false otherwise (colored console output for dev mode).
type ConfigField ¶ added in v3.2.1
type ConfigField struct {
Key string `json:"key"`
Label string `json:"label"`
Value interface{} `json:"value"`
Type string `json:"type"` // string, bool, int, duration, array, object, role, table
Sensitive bool `json:"sensitive,omitempty"`
Description string `json:"description,omitempty"`
}
ConfigField represents a single config field with metadata for dynamic rendering
type ConfigSection ¶ added in v3.2.1
type ConfigSection struct {
Name string `json:"name"`
Title string `json:"title"`
Description string `json:"description,omitempty"`
Fields []ConfigField `json:"fields"`
}
ConfigSection represents a group of related config fields for the Web UI
type ConfigUpdateRequest ¶ added in v3.2.1
type ConfigUpdateRequest struct {
Databases map[string]DatabaseConfigInput `json:"databases,omitempty"`
Tables []TableConfigInput `json:"tables,omitempty"`
Roles []RoleConfigInput `json:"roles,omitempty"`
Blocklist []string `json:"blocklist,omitempty"`
Functions []FunctionConfigInput `json:"functions,omitempty"`
}
ConfigUpdateRequest represents the update request structure
type ConfigUpdateResult ¶ added in v3.2.1
type ConfigUpdateResult struct {
Success bool `json:"success"`
Message string `json:"message"`
Changes []string `json:"changes,omitempty"`
Errors []string `json:"errors,omitempty"`
Databases []string `json:"databases,omitempty"`
Next *NextGuidance `json:"next,omitempty"`
}
ConfigUpdateResult represents the result of a config update
type ConnectDisconnect ¶ added in v3.2.1
type ConnectDisconnect struct {
Connect string `json:"connect"`
Disconnect string `json:"disconnect"`
}
ConnectDisconnect shows connect/disconnect syntax
type ConnectionTestResult ¶ added in v3.10.3
type ConnectionTestResult struct {
Success bool `json:"success"`
Candidate DiscoveredDatabase `json:"candidate"`
RecommendedDB string `json:"recommended_dbname,omitempty"`
Next *NextGuidance `json:"next,omitempty"`
}
type CursorCache ¶ added in v3.2.1
type CursorCache interface {
// Set stores a cursor and returns a short numeric ID
Set(ctx context.Context, cursor string) (uint64, error)
// Get retrieves a cursor by its numeric ID
Get(ctx context.Context, id uint64) (string, error)
// Close releases resources
Close() error
}
CursorCache is the interface for MCP cursor caching It maps short numeric IDs to encrypted cursor strings for LLM-friendly pagination
func NewCursorCache ¶ added in v3.2.1
NewCursorCache creates a cursor cache using Redis if available, otherwise in-memory
type DDLApplyResult ¶ added in v3.3.0
type DDLApplyResult struct {
Success bool `json:"success"`
OperationsApplied int `json:"operations_applied"`
TablesCreated []string `json:"tables_created,omitempty"`
ColumnsAdded []string `json:"columns_added,omitempty"`
Message string `json:"message"`
}
DDLApplyResult is the response from apply_schema_changes
type DDLOperationInfo ¶ added in v3.3.0
type DDLOperationInfo struct {
Type string `json:"type"`
Table string `json:"table"`
Column string `json:"column,omitempty"`
SQL string `json:"sql"`
Destructive bool `json:"destructive"`
}
DDLOperationInfo describes a single schema operation for JSON response
type DDLPreviewResult ¶ added in v3.3.0
type DDLPreviewResult struct {
Operations []DDLOperationInfo `json:"operations"`
Summary DDLSummary `json:"summary"`
}
DDLPreviewResult is the response from preview_schema_changes
type DDLSummary ¶ added in v3.3.0
type DDLSummary struct {
Total int `json:"total"`
TablesToCreate int `json:"tables_to_create"`
ColumnsToAdd int `json:"columns_to_add"`
IndexesToAdd int `json:"indexes_to_add"`
DestructiveOps int `json:"destructive_count"`
}
DDLSummary summarizes the schema changes
type Database ¶
type Database struct {
ConnString string `mapstructure:"connection_string" jsonschema:"title=Connection String"`
Type string `jsonschema:"title=Type,enum=postgres,enum=mysql,enum=mariadb,enum=mssql,enum=sqlite,enum=oracle,enum=mongodb"`
Host string `jsonschema:"title=Host"`
Port uint16 `jsonschema:"title=Port"`
DBName string `jsonschema:"title=Database Name"`
User string `jsonschema:"title=User"`
Password string `jsonschema:"title=Password"`
Schema string `jsonschema:"title=Postgres Schema"`
// File path for SQLite databases
Path string `jsonschema:"title=File Path (SQLite)"`
// Size of database connection pool
PoolSize int `mapstructure:"pool_size" jsonschema:"title=Connection Pool Size"`
// Max number of active database connections allowed
MaxConnections int `mapstructure:"max_connections" jsonschema:"title=Maximum Connections"`
// Max time after which idle database connections are closed
MaxConnIdleTime time.Duration `mapstructure:"max_connection_idle_time" jsonschema:"title=Connection Idel Time"`
// Max time after which database connections are not reused
MaxConnLifeTime time.Duration `mapstructure:"max_connection_life_time" jsonschema:"title=Connection Life Time"`
// Database ping timeout is used for db health checking
PingTimeout time.Duration `mapstructure:"ping_timeout" jsonschema:"title=Healthcheck Ping Timeout"`
// Set up an secure TLS encrypted database connection
EnableTLS bool `mapstructure:"enable_tls" jsonschema:"title=Enable TLS"`
// Required for TLS. For example with Google Cloud SQL it's
// <gcp-project-id>:<cloud-sql-instance>
ServerName string `mapstructure:"server_name" jsonschema:"title=TLS Server Name"`
// Required for TLS. Can be a file path or the contents of the PEM file
ServerCert string `mapstructure:"server_cert" jsonschema:"title=Server Certificate"`
// Required for TLS. Can be a file path or the contents of the PEM file
ClientCert string `mapstructure:"client_cert" jsonschema:"title=Client Certificate"`
// Required for TLS. Can be a file path or the contents of the pem file
ClientKey string `mapstructure:"client_key" jsonschema:"title=Client Key"`
// MSSQL: disable TLS encryption (default: true in go-mssqldb)
Encrypt *bool `mapstructure:"encrypt" jsonschema:"title=MSSQL Encrypt"`
// MSSQL: trust server certificate without validation
TrustServerCertificate *bool `mapstructure:"trust_server_certificate" jsonschema:"title=MSSQL Trust Server Certificate"`
}
Database configuration
type DatabaseConfigInput ¶ added in v3.2.1
type DatabaseConfigInput struct {
Type string `json:"type"`
ConnString string `json:"connection_string,omitempty"`
Host string `json:"host,omitempty"`
Port int `json:"port,omitempty"`
DBName string `json:"dbname,omitempty"`
User string `json:"user,omitempty"`
Password string `json:"password,omitempty"`
Path string `json:"path,omitempty"`
Schema string `json:"schema,omitempty"`
ReadOnly bool `json:"read_only,omitempty"`
}
DatabaseConfigInput represents a database config for input
type DatabaseConnection ¶ added in v3.10.2
type DatabaseConnection struct {
Name string `json:"name"`
Type string `json:"type"`
Host string `json:"host"`
Databases []string `json:"databases"`
Active bool `json:"active"`
Error string `json:"error,omitempty"`
}
DatabaseConnection represents a single database server connection for list_databases
type DeleteConfigInput ¶ added in v3.2.1
type DeleteConfigInput struct {
Filters []string `json:"filters,omitempty"`
Columns []string `json:"columns,omitempty"`
Block bool `json:"block,omitempty"`
}
DeleteConfigInput represents delete permissions
type DiscoverResult ¶ added in v3.9.0
type DiscoverResult struct {
Databases []DiscoveredDatabase `json:"databases"`
Summary DiscoverSummary `json:"summary"`
DockerStatus string `json:"docker_status"`
Next *NextGuidance `json:"next,omitempty"`
}
DiscoverResult is the top-level response structure
type DiscoverSummary ¶ added in v3.9.0
type DiscoverSummary struct {
TotalFound int `json:"total_found"`
DatabaseTypes []string `json:"database_types"`
ScanDurationMs int64 `json:"scan_duration_ms"`
}
DiscoverSummary summarizes the discovery scan
type DiscoverTarget ¶ added in v3.10.3
type DiscoverTarget struct {
Type string `json:"type,omitempty"`
Host string `json:"host"`
Port int `json:"port,omitempty"`
SourceLabel string `json:"source_label,omitempty"`
User string `json:"user,omitempty"`
Password string `json:"password,omitempty"`
DBName string `json:"dbname,omitempty"`
}
DiscoverTarget is an explicit host target to probe (local or remote).
type DiscoveredDatabase ¶ added in v3.9.0
type DiscoveredDatabase struct {
Type string `json:"type"`
Host string `json:"host,omitempty"`
Port int `json:"port,omitempty"`
FilePath string `json:"file_path,omitempty"`
CandidateID string `json:"candidate_id,omitempty"`
Rank int `json:"rank,omitempty"`
Confidence string `json:"confidence,omitempty"`
Reasons []string `json:"reasons,omitempty"`
NextActions []string `json:"next_actions,omitempty"`
ProbeStatus string `json:"probe_status_code,omitempty"`
Source string `json:"source"`
Status string `json:"status"`
Databases []string `json:"databases,omitempty"`
AuthStatus string `json:"auth_status,omitempty"`
AuthUser string `json:"auth_user,omitempty"`
AuthError string `json:"auth_error,omitempty"`
DockerInfo *DockerDBInfo `json:"docker_info,omitempty"`
ConfigSnippet map[string]any `json:"config_snippet"`
}
DiscoveredDatabase represents a database found during discovery
type DockerDBInfo ¶ added in v3.9.0
type DockerDBInfo struct {
ContainerID string `json:"container_id"`
ContainerName string `json:"container_name"`
Image string `json:"image"`
Ports string `json:"ports"`
}
DockerDBInfo holds Docker container details for a discovered database
type EnhancedError ¶ added in v3.2.1
type EnhancedError struct {
Message string `json:"message"`
Suggestion string `json:"suggestion,omitempty"`
RelatedTool string `json:"related_tool,omitempty"`
}
EnhancedError represents an error with recovery suggestions
type ErrorInfo ¶ added in v3.2.1
type ErrorInfo struct {
Message string `json:"message"`
}
ErrorInfo represents an error from query execution
type ExampleQuery ¶ added in v3.10.2
ExampleQuery represents an example GraphQL query for a table
type ExecuteResult ¶ added in v3.2.1
type ExecuteResult struct {
Data json.RawMessage `json:"data"`
Errors []ErrorInfo `json:"errors,omitempty"`
}
ExecuteResult represents the result of a query execution
type FilterOperators ¶ added in v3.2.1
type FilterOperators struct {
Comparison []string `json:"comparison"`
List []string `json:"list"`
Null []string `json:"null"`
Text []string `json:"text"`
JSON []string `json:"json"`
Spatial []string `json:"spatial"`
}
FilterOperators groups filter operators by category
type FunctionConfigInput ¶ added in v3.2.1
type FunctionConfigInput struct {
Name string `json:"name"`
Schema string `json:"schema,omitempty"`
ReturnType string `json:"return_type"`
}
FunctionConfigInput represents a function config for input
type HealthResult ¶ added in v3.10.2
type HealthResult struct {
Status string `json:"status"`
DatabaseType string `json:"database_type,omitempty"`
PingLatency string `json:"ping_latency,omitempty"`
SchemaReady bool `json:"schema_ready"`
TableCount int `json:"table_count"`
PoolStats *PoolStatsInfo `json:"pool_stats,omitempty"`
Error string `json:"error,omitempty"`
}
HealthResult represents the health check response
type HttpService ¶
func NewGraphJinService ¶
func NewGraphJinService(conf *Config, options ...Option) (*HttpService, error)
NewGraphJinService a new service
func (*HttpService) Attach ¶
func (s *HttpService) Attach(mux Mux) error
Attach route to the internal http service
func (*HttpService) AttachWithNS ¶
func (s *HttpService) AttachWithNS(mux Mux, namespace string) error
AttachWithNS a namespaced route to the internal http service
func (*HttpService) Deploy ¶
func (s *HttpService) Deploy(conf *Config, options ...Option) error
Deploy a new configuration
func (*HttpService) GetDB ¶
func (s *HttpService) GetDB() *sql.DB
GetDB fetching internal db client (returns any connection from the pool)
func (*HttpService) GetGraphJin ¶
func (s *HttpService) GetGraphJin() *core.GraphJin
GetGraphJin fetching internal GraphJin core
func (*HttpService) GraphQL ¶
func (s *HttpService) GraphQL(ah auth.HandlerFunc) http.Handler
GraphQLis the http handler the GraphQL endpoint
func (*HttpService) GraphQLWithNS ¶
func (s *HttpService) GraphQLWithNS(ah auth.HandlerFunc, ns string) http.Handler
GraphQLWithNS is the http handler the namespaced GraphQL endpoint
func (*HttpService) MCPHandler ¶ added in v3.2.1
func (s *HttpService) MCPHandler() http.Handler
MCPHandler returns an HTTP handler for MCP HTTP transport (stateless) This uses StreamableHTTPServer which handles POST requests directly
func (*HttpService) MCPHandlerWithAuth ¶ added in v3.2.1
func (s *HttpService) MCPHandlerWithAuth(ah auth.HandlerFunc) http.Handler
MCPHandlerWithAuth returns an HTTP handler for MCP HTTP transport with authentication This wraps the MCP handler with the same auth middleware as GraphQL/REST endpoints
func (*HttpService) MCPMessageHandler ¶ added in v3.2.1
func (s *HttpService) MCPMessageHandler() http.Handler
MCPMessageHandler returns an HTTP handler for MCP HTTP transport (stateless) This uses StreamableHTTPServer which handles POST requests directly without SSE
func (*HttpService) MCPMessageHandlerWithAuth ¶ added in v3.2.1
func (s *HttpService) MCPMessageHandlerWithAuth(ah auth.HandlerFunc) http.Handler
MCPMessageHandlerWithAuth returns an HTTP handler for MCP HTTP transport with authentication
func (*HttpService) OpenAPI ¶ added in v3.2.1
func (s *HttpService) OpenAPI() http.Handler
OpenAPI is the http handler for the OpenAPI specification endpoint
func (*HttpService) OpenAPIWithNS ¶ added in v3.2.1
func (s *HttpService) OpenAPIWithNS(ns string) http.Handler
OpenAPIWithNS is the http handler for the namespaced OpenAPI specification endpoint
func (*HttpService) REST ¶
func (s *HttpService) REST(ah auth.HandlerFunc) http.Handler
REST is the http handler the REST endpoint
func (*HttpService) RESTWithNS ¶
func (s *HttpService) RESTWithNS(ah auth.HandlerFunc, ns string) http.Handler
RESTWithNS is the http handler the namespaced REST endpoint
func (*HttpService) Reload ¶
func (s *HttpService) Reload() error
Reload re-runs database discover and reinitializes service.
func (*HttpService) RunMCPStdio ¶ added in v3.2.1
func (s *HttpService) RunMCPStdio(ctx context.Context) error
RunMCPStdio runs the MCP server using stdio transport (for CLI/Claude Desktop) Auth credentials can be provided via environment variables: - GRAPHJIN_USER_ID: User ID for the session - GRAPHJIN_USER_ROLE: User role for the session
func (*HttpService) Start ¶
func (s *HttpService) Start() error
Start the service listening on the configured port
func (*HttpService) WebUI ¶
func (s *HttpService) WebUI(routePrefix, gqlEndpoint string) http.Handler
WebUI is the http handler the web ui endpoint
func (*HttpService) Workflows ¶ added in v3.12.0
func (s *HttpService) Workflows(ah auth.HandlerFunc) http.Handler
Workflows is the http handler for named JS workflows.
func (*HttpService) WorkflowsWithNS ¶ added in v3.12.0
func (s *HttpService) WorkflowsWithNS(ah auth.HandlerFunc, ns string) http.Handler
WorkflowsWithNS is the namespaced http handler for named JS workflows.
type InsertConfigInput ¶ added in v3.2.1
type InsertConfigInput struct {
Filters []string `json:"filters,omitempty"`
Columns []string `json:"columns,omitempty"`
Presets map[string]string `json:"presets,omitempty"`
Block bool `json:"block,omitempty"`
}
InsertConfigInput represents insert permissions
type JSRuntimeAPI ¶ added in v3.12.0
type JSRuntimeAPI struct {
Runtime string `json:"runtime"`
RuntimeStatus string `json:"runtime_status"`
EntryPoint string `json:"entry_point"`
Globals []JSRuntimeGlobal `json:"globals"`
Functions []JSRuntimeFunction `json:"functions"`
Notes []string `json:"notes,omitempty"`
}
JSRuntimeAPI describes the functions exposed in the GraphJin JS runtime.
type JSRuntimeFunction ¶ added in v3.12.0
type JSRuntimeFunction struct {
Name string `json:"name"`
Tool string `json:"tool,omitempty"`
Description string `json:"description,omitempty"`
Arguments map[string]any `json:"arguments,omitempty"`
Required []string `json:"required,omitempty"`
}
JSRuntimeFunction describes one callable function in the JS runtime.
type JSRuntimeGlobal ¶ added in v3.12.0
type JSRuntimeGlobal struct {
Name string `json:"name"`
Type string `json:"type"`
Description string `json:"description"`
}
JSRuntimeGlobal describes one global in the JS runtime.
type ListDatabasesResult ¶ added in v3.10.2
type ListDatabasesResult struct {
Connections []DatabaseConnection `json:"connections"`
TotalDatabases int `json:"total_databases"`
}
ListDatabasesResult is the response from list_databases
type MCPConfig ¶ added in v3.2.1
type MCPConfig struct {
// Disable the MCP server (MCP is enabled by default)
Disable bool `jsonschema:"title=Disable MCP Server,default=false"`
// Enable search functionality for saved queries and fragments
EnableSearch bool `mapstructure:"enable_search" jsonschema:"title=Enable Query Search,default=true"`
// Allow mutation operations via MCP
AllowMutations bool `mapstructure:"allow_mutations" jsonschema:"title=Allow Mutations,default=true"`
// Allow arbitrary GraphQL queries (vs only saved queries from allow-list)
AllowRawQueries bool `mapstructure:"allow_raw_queries" jsonschema:"title=Allow Raw Queries,default=true"`
// Default user ID for stdio transport (CLI). Can be overridden by GRAPHJIN_USER_ID env var.
StdioUserID string `mapstructure:"stdio_user_id" jsonschema:"title=Stdio User ID"`
// Default user role for stdio transport (CLI). Can be overridden by GRAPHJIN_USER_ROLE env var.
StdioUserRole string `mapstructure:"stdio_user_role" jsonschema:"title=Stdio User Role"`
// Run in MCP-only mode - disables GraphQL, REST saved-query API, WebUI, and OpenAPI endpoints.
// Health check, MCP endpoints, and /api/v1/workflows/* remain available.
Only bool `mapstructure:"only" jsonschema:"title=MCP Only Mode,default=false"`
// CursorCacheTTL in seconds for cursor ID cache (default: 1800 = 30 min)
// Cursors are cached to allow short numeric IDs for LLM-friendly pagination
CursorCacheTTL int `mapstructure:"cursor_cache_ttl" jsonschema:"title=Cursor Cache TTL,default=1800"`
// CursorCacheSize max entries for in-memory cursor cache fallback (default: 10000)
CursorCacheSize int `mapstructure:"cursor_cache_size" jsonschema:"title=Cursor Cache Size,default=10000"`
// AllowConfigUpdates enables MCP tools that can modify GraphJin configuration
// WARNING: Allows LLMs to change database connections, table configs, and roles
// Only enable in trusted environments. Default: false
AllowConfigUpdates bool `mapstructure:"allow_config_updates" jsonschema:"title=Allow Config Updates,default=false"`
// AllowSchemaReload enables the MCP reload_schema tool for manual schema refresh
// Useful when user adds tables and wants immediate discovery without waiting for poll
// Default: false (auto-enabled in dev mode if not explicitly set)
AllowSchemaReload bool `mapstructure:"allow_schema_reload" jsonschema:"title=Allow Schema Reload,default=false"`
// AllowSchemaUpdates enables MCP tools to preview and apply database schema changes (DDL)
// Uses db.graphql format. Auto-enabled in dev mode. Default: false
AllowSchemaUpdates bool `mapstructure:"allow_schema_updates" jsonschema:"title=Allow Schema Updates,default=false"`
// AllowDevTools enables advanced introspection MCP tools (explain_query, explore_relationships, audit_role_permissions).
// These expose SQL, relationship graphs, and role permissions — useful for development/debugging.
// Auto-enabled in dev mode. Default: false
AllowDevTools bool `mapstructure:"allow_dev_tools" jsonschema:"title=Allow Dev Tools,default=false"`
// DefaultDBAllowed when true allows configuring and discovering system/default
// databases (e.g. postgres, mysql, master). Default: false
DefaultDBAllowed bool `mapstructure:"default_db_allowed" jsonschema:"title=Allow Default Databases,default=false"`
}
MCPConfig configures the Model Context Protocol (MCP) server MCP enables AI assistants to interact with GraphJin via function calling
Transport is implicit based on context: - CLI (`graphjin mcp`) uses stdio transport for Claude Desktop and CLI clients - HTTP service uses SSE/HTTP transport at /api/v1/mcp endpoint
Authentication: - HTTP transport uses the same auth as GraphQL/REST (JWT, headers, etc.) - Stdio transport uses env vars (GRAPHJIN_USER_ID, GRAPHJIN_USER_ROLE) or config values
type MCPConfigResponse ¶ added in v3.2.1
type MCPConfigResponse struct {
ActiveDatabase string `json:"active_database,omitempty"`
Databases map[string]core.DatabaseConfig `json:"databases,omitempty"`
Tables []core.Table `json:"tables,omitempty"`
Roles []RoleInfo `json:"roles,omitempty"`
Blocklist []string `json:"blocklist,omitempty"`
Functions []core.Function `json:"functions,omitempty"`
Resolvers []core.ResolverConfig `json:"resolvers,omitempty"`
}
MCPConfigResponse represents a section of the configuration for MCP
type MemoryCache ¶ added in v3.2.1
type MemoryCache struct {
// contains filtered or unexported fields
}
MemoryCache provides in-memory LRU response caching with row-level invalidation
func NewMemoryCache ¶ added in v3.2.1
func NewMemoryCache(conf CachingConfig, maxEntries int) (*MemoryCache, error)
NewMemoryCache creates a new in-memory LRU cache
func (*MemoryCache) Close ¶ added in v3.2.1
func (mc *MemoryCache) Close() error
Close is a no-op for memory cache
func (*MemoryCache) Get ¶ added in v3.2.1
Get retrieves a cached response Returns (data, isStale, found)
func (*MemoryCache) InvalidateRows ¶ added in v3.2.1
InvalidateRows invalidates cache entries for specific rows
func (*MemoryCache) Metrics ¶ added in v3.2.1
func (mc *MemoryCache) Metrics() *CacheMetrics
Metrics returns the cache metrics
type MemoryCursorCache ¶ added in v3.2.1
type MemoryCursorCache struct {
// contains filtered or unexported fields
}
MemoryCursorCache uses in-memory LRU as fallback
func NewMemoryCursorCache ¶ added in v3.2.1
func NewMemoryCursorCache(maxEntries int, ttl time.Duration) *MemoryCursorCache
NewMemoryCursorCache creates a new in-memory cursor cache
func (*MemoryCursorCache) Close ¶ added in v3.2.1
func (c *MemoryCursorCache) Close() error
Close stops the cleanup goroutine
type MistakeExample ¶ added in v3.2.1
type MistakeExample struct {
Wrong string `json:"wrong"`
Right string `json:"right"`
Reason string `json:"reason"`
}
MistakeExample shows a common mistake and how to fix it
type MutationOperations ¶ added in v3.2.1
type MutationOperations struct {
Insert string `json:"insert"`
BulkInsert string `json:"bulk_insert"`
Update string `json:"update"`
BulkUpdate string `json:"bulk_update"`
UpdateWhere string `json:"update_where"`
Upsert string `json:"upsert"`
Delete string `json:"delete"`
}
MutationOperations shows mutation operation syntax
type MutationSyntaxReference ¶ added in v3.2.1
type MutationSyntaxReference struct {
Operations MutationOperations `json:"operations"`
NestedMutations NestedMutationInfo `json:"nested_mutations"`
ConnectDisconnect ConnectDisconnect `json:"connect_disconnect"`
Returning ReturningInfo `json:"returning"`
Validation ValidationSyntax `json:"validation"`
CommonMistakes []MistakeExample `json:"common_mistakes"`
Examples []QueryExample `json:"examples"`
}
MutationSyntaxReference contains the GraphJin mutation DSL reference
type NestedMutationInfo ¶ added in v3.2.1
type NestedMutationInfo struct {
Description string `json:"description"`
Example string `json:"example"`
}
NestedMutationInfo describes nested mutations
type NextGuidance ¶ added in v3.11.0
type NextGuidance struct {
StateCode string `json:"state_code"`
RecommendedTool string `json:"recommended_tool,omitempty"`
Options []NextOption `json:"options,omitempty"`
}
NextGuidance contains the recommended next MCP tool call and alternatives.
type NextOption ¶ added in v3.11.0
type NextOption struct {
Tool string `json:"tool"`
Priority int `json:"priority"`
Reason string `json:"reason,omitempty"`
When string `json:"when,omitempty"`
RequiredArgs []string `json:"required_args,omitempty"`
OptionalArgs []string `json:"optional_args,omitempty"`
}
NextOption is a machine-readable next-step option for MCP orchestration.
type OnboardingStatusResult ¶ added in v3.10.3
type OnboardingStatusResult struct {
ConfiguredDatabases []string `json:"configured_databases"`
ActiveDatabase string `json:"active_database,omitempty"`
SchemaReady bool `json:"schema_ready"`
TableCount int `json:"table_count"`
Warnings []string `json:"warnings,omitempty"`
Next *NextGuidance `json:"next,omitempty"`
}
type Option ¶
type Option func(*graphjinService) error
func OptionSetDB ¶
OptionSetDB sets a new db client. The connection is stored under the DefaultDBName key in the dbs map for backward compatibility.
func OptionSetHookFunc ¶
OptionSetHookFunc sets a function to be called on every request
func OptionSetLogOutput ¶ added in v3.2.1
func OptionSetLogOutput(output zapcore.WriteSyncer) Option
OptionSetLogOutput sets the log output writer (e.g., os.Stderr for MCP stdio mode)
func OptionSetNamespace ¶
OptionSetNamespace sets service namespace
func OptionSetZapLogger ¶
OptionSetZapLogger sets service structured logger
type OrderingSyntax ¶ added in v3.2.1
type OrderingSyntax struct {
Simple string `json:"simple"`
Multiple string `json:"multiple"`
Nested string `json:"nested"`
CustomList string `json:"custom_list"`
NullsFirst string `json:"nulls_first"`
NullsLast string `json:"nulls_last"`
}
OrderingSyntax shows ordering options
type PaginationSyntax ¶ added in v3.2.1
type PaginationSyntax struct {
LimitOffset string `json:"limit_offset"`
ForwardCursor string `json:"forward_cursor"`
BackwardCursor string `json:"backward_cursor"`
CursorField string `json:"cursor_field"`
Distinct string `json:"distinct"`
}
PaginationSyntax shows pagination options
type Payload ¶
type Payload struct {
Data json.RawMessage `json:"data,omitempty"`
Errors []core.Error `json:"errors,omitempty"`
}
type PoolStatsInfo ¶ added in v3.10.2
type PoolStatsInfo struct {
MaxOpenConnections int `json:"max_open_connections"`
OpenConnections int `json:"open_connections"`
InUse int `json:"in_use"`
Idle int `json:"idle"`
WaitCount int64 `json:"wait_count"`
WaitDuration string `json:"wait_duration"`
}
PoolStatsInfo represents database connection pool statistics
type QueryConfigInput ¶ added in v3.2.1
type QueryConfigInput struct {
Limit int `json:"limit,omitempty"`
Filters []string `json:"filters,omitempty"`
Columns []string `json:"columns,omitempty"`
DisableFunctions bool `json:"disable_functions,omitempty"`
Block bool `json:"block,omitempty"`
}
QueryConfigInput represents query permissions
type QueryExample ¶ added in v3.2.1
type QueryExample struct {
Description string `json:"description"`
Query string `json:"query"`
Variables string `json:"variables,omitempty"`
}
QueryExample represents an annotated query example
type QueryExamplesForSyntax ¶ added in v3.2.1
type QueryExamplesForSyntax struct {
Basic []QueryExample `json:"basic"`
Filtering []QueryExample `json:"filtering"`
Relationships []QueryExample `json:"relationships"`
Pagination []QueryExample `json:"pagination"`
Aggregations []QueryExample `json:"aggregations"`
Recursive []QueryExample `json:"recursive"`
Spatial []QueryExample `json:"spatial"`
RemoteJoins []QueryExample `json:"remote_joins"`
}
QueryExamplesForSyntax contains categorized query examples
type QuerySyntaxReference ¶ added in v3.2.1
type QuerySyntaxReference struct {
FilterOperators FilterOperators `json:"filter_operators"`
LogicalOperators []string `json:"logical_operators"`
Pagination PaginationSyntax `json:"pagination"`
Ordering OrderingSyntax `json:"ordering"`
Aggregations AggregationsSyntax `json:"aggregations"`
Recursive RecursiveSyntax `json:"recursive"`
FullTextSearch string `json:"full_text_search"`
Directives map[string]string `json:"directives"`
Variables VariablesSyntax `json:"variables"`
JSONPaths string `json:"json_paths"`
CommonMistakes []MistakeExample `json:"common_mistakes"`
Examples QueryExamplesForSyntax `json:"examples"`
}
QuerySyntaxReference contains the complete GraphJin query DSL reference
type RateLimiter ¶
type RateLimiter struct {
// The number of events per second
Rate float64 `jsonschema:"title=Connection Rate"`
// Bucket a burst of at most 'bucket' number of events
Bucket int `jsonschema:"title=Bucket Size"`
// The header that contains the client ip
IPHeader string `mapstructure:"ip_header" jsonschema:"title=IP From HTTP Header,example=X-Forwarded-For"`
}
RateLimiter sets the API rate limits
type RecursiveSyntax ¶ added in v3.2.1
type RecursiveSyntax struct {
FindParents string `json:"find_parents"`
FindChildren string `json:"find_children"`
}
RecursiveSyntax shows recursive query options
type RedisCache ¶ added in v3.2.1
type RedisCache struct {
// contains filtered or unexported fields
}
RedisCache provides Redis-based response caching with row-level invalidation
func NewRedisCache ¶ added in v3.2.1
func NewRedisCache(redisURL string, conf CachingConfig) (*RedisCache, error)
NewRedisCache creates a new Redis cache instance
func (*RedisCache) Close ¶ added in v3.2.1
func (c *RedisCache) Close() error
Close closes the Redis connection and worker pool
func (*RedisCache) Get ¶ added in v3.2.1
Get retrieves a cached response Returns (data, isStale, found)
func (*RedisCache) InvalidateRows ¶ added in v3.2.1
InvalidateRows invalidates cache entries for specific rows (called after mutations)
func (*RedisCache) Metrics ¶ added in v3.2.1
func (c *RedisCache) Metrics() *CacheMetrics
Metrics returns the cache metrics
type RedisConfig ¶ added in v3.2.1
type RedisConfig struct {
// Redis connection URL (e.g., redis://localhost:6379/0)
URL string `mapstructure:"url" jsonschema:"title=Redis URL"`
}
RedisConfig configures Redis connection
type RedisCursorCache ¶ added in v3.2.1
type RedisCursorCache struct {
// contains filtered or unexported fields
}
RedisCursorCache uses Redis for distributed cursor caching
func NewRedisCursorCache ¶ added in v3.2.1
func NewRedisCursorCache(redisURL string, ttl time.Duration) (*RedisCursorCache, error)
NewRedisCursorCache creates a new Redis cursor cache
func (*RedisCursorCache) Close ¶ added in v3.2.1
func (c *RedisCursorCache) Close() error
Close closes the Redis connection
type RefreshJob ¶ added in v3.2.1
RefreshJob represents a background cache refresh task
type ResolverConfigInput ¶ added in v3.6.0
type ResolverConfigInput struct {
Name string `json:"name"`
Type string `json:"type"`
Schema string `json:"schema,omitempty"`
Table string `json:"table"`
Column string `json:"column,omitempty"`
StripPath string `json:"strip_path,omitempty"`
URL string `json:"url,omitempty"`
Debug bool `json:"debug,omitempty"`
PassHeaders []string `json:"pass_headers,omitempty"`
SetHeaders []SetHeaderInput `json:"set_headers,omitempty"`
}
ResolverConfigInput represents a resolver config for input
type ResponseCache ¶ added in v3.2.1
type ResponseCache interface {
// Get retrieves a cached response
// Returns (data, isStale, found)
Get(ctx context.Context, key string) ([]byte, bool, bool)
// Set stores a response with row-level indices for invalidation
Set(ctx context.Context, key string, data []byte, refs []core.RowRef, queryStartTime time.Time) error
// InvalidateRows invalidates cache entries for specific rows (called after mutations)
InvalidateRows(ctx context.Context, refs []core.RowRef) error
// Metrics returns the cache metrics
Metrics() *CacheMetrics
// Close releases resources
Close() error
}
ResponseCache defines the interface for response caching backends Both RedisCache and MemoryCache implement this interface
type ReturningInfo ¶ added in v3.2.1
type ReturningInfo struct {
Description string `json:"description"`
Example string `json:"example"`
}
ReturningInfo describes the returning clause behavior
type RoleConfigInput ¶ added in v3.2.1
type RoleConfigInput struct {
Name string `json:"name"`
Comment string `json:"comment,omitempty"`
Match string `json:"match,omitempty"`
Tables []RoleTableConfigInput `json:"tables,omitempty"`
}
RoleConfigInput represents a role config for input
type RoleInfo ¶ added in v3.2.1
type RoleInfo struct {
Name string `json:"name"`
Comment string `json:"comment,omitempty"`
Match string `json:"match,omitempty"`
Tables []core.RoleTable `json:"tables,omitempty"`
}
RoleInfo provides role information safe for JSON serialization
type RoleTableConfigInput ¶ added in v3.2.1
type RoleTableConfigInput struct {
Name string `json:"name"`
Schema string `json:"schema,omitempty"`
ReadOnly bool `json:"read_only,omitempty"`
Query *QueryConfigInput `json:"query,omitempty"`
Insert *InsertConfigInput `json:"insert,omitempty"`
Update *UpdateConfigInput `json:"update,omitempty"`
Upsert *UpsertConfigInput `json:"upsert,omitempty"`
Delete *DeleteConfigInput `json:"delete,omitempty"`
}
RoleTableConfigInput represents a role table config for input
type SWRWorkerPool ¶ added in v3.2.1
type SWRWorkerPool struct {
// contains filtered or unexported fields
}
SWRWorkerPool manages background refresh workers for stale-while-revalidate
func NewSWRWorkerPool ¶ added in v3.2.1
func NewSWRWorkerPool(size int, cache *RedisCache) *SWRWorkerPool
NewSWRWorkerPool creates a new SWR worker pool
func (*SWRWorkerPool) Shutdown ¶ added in v3.2.1
func (p *SWRWorkerPool) Shutdown()
Shutdown gracefully shuts down the worker pool
func (*SWRWorkerPool) TrySubmit ¶ added in v3.2.1
func (p *SWRWorkerPool) TrySubmit(job RefreshJob) bool
TrySubmit attempts to submit a job, returns false if pool is busy
type Serv ¶
type Serv struct {
// Application name is used in log and debug messages
AppName string `mapstructure:"app_name" jsonschema:"title=Application Name"`
// When enabled runs the service with production level security defaults.
// For example allow lists are enforced.
Production bool `jsonschema:"title=Production Mode,default=false"`
// The default path to find all configuration files and scripts
ConfigPath string `mapstructure:"config_path" jsonschema:"title=Config Path"`
// Logging level must be one of debug, error, warn, info
LogLevel string `mapstructure:"log_level" jsonschema:"title=Log Level,enum=debug,enum=error,enum=warn,enum=info"`
// Logging Format: "auto" (default, colored console in dev, JSON in production),
// "json" (always JSON), or "simple" (always colored console)
LogFormat string `mapstructure:"log_format" jsonschema:"title=Logging Format,enum=auto,enum=json,enum=simple"`
// The host and port the service runs on. Example localhost:8080
HostPort string `mapstructure:"host_port" jsonschema:"title=Host and Port"`
// Host to run the service on
Host string `jsonschema:"title=Host"`
// Port to run the service on
Port string `jsonschema:"title=Port"`
// Enables HTTP compression
HTTPGZip bool `mapstructure:"http_compress" jsonschema:"title=Enable Compression,default=true"`
// Sets the API rate limits
RateLimiter RateLimiter `mapstructure:"rate_limiter" jsonschema:"title=Set API Rate Limiting"`
// Enables the Server-Timing HTTP header
ServerTiming bool `mapstructure:"server_timing" jsonschema:"title=Server Timing HTTP Header,default=true"`
// Enable the web UI. Disabled in production
WebUI bool `mapstructure:"web_ui" jsonschema:"title=Enable Web UI,default=false"`
// Enable OpenTrace request tracing
EnableTracing bool `mapstructure:"enable_tracing" jsonschema:"title=Enable Tracing,default=true"`
// Enables reloading the service on config changes. Disabled in production
WatchAndReload bool `mapstructure:"reload_on_config_change" jsonschema:"title=Reload Config"`
// Enable blocking requests with a HTTP 401 on auth failure
AuthFailBlock bool `mapstructure:"auth_fail_block" jsonschema:"title=Block Request on Authorization Failure"`
// Sets the HTTP CORS Access-Control-Allow-Origin header
AllowedOrigins []string `mapstructure:"cors_allowed_origins" jsonschema:"title=HTTP CORS Allowed Origins"`
// Sets the HTTP CORS Access-Control-Allow-Headers header
AllowedHeaders []string `mapstructure:"cors_allowed_headers" jsonschema:"title=HTTP CORS Allowed Headers"`
// Enables debug logs for CORS
DebugCORS bool `mapstructure:"cors_debug" jsonschema:"title=Log CORS"`
// Sets the HTTP Cache-Control header
CacheControl string `mapstructure:"cache_control" jsonschema:"title=Enable Cache-Control"`
// Sets the default authentication used by the service
Auth Auth `jsonschema:"title=Authentication"`
// Database configuration
DB Database `mapstructure:"database" jsonschema:"title=Database"`
// MCP (Model Context Protocol) server configuration
MCP MCPConfig `mapstructure:"mcp" jsonschema:"title=MCP Configuration"`
// Redis configuration
Redis RedisConfig `mapstructure:"redis" jsonschema:"title=Redis Configuration"`
// Response caching configuration
Caching CachingConfig `mapstructure:"caching" jsonschema:"title=Caching Configuration"`
}
Configuration for the GraphJin Service
type SetHeaderInput ¶ added in v3.6.0
SetHeaderInput represents a header name-value pair for resolver config
type SetupPlanResult ¶ added in v3.10.3
type SetupPlanResult struct {
Candidates []DiscoveredDatabase `json:"candidates"`
Checklist []string `json:"selection_checklist"`
Recommended string `json:"recommended_candidate_id,omitempty"`
Next *NextGuidance `json:"next,omitempty"`
}
type TableConfigInput ¶ added in v3.2.1
type TableConfigInput struct {
Name string `json:"name"`
Database string `json:"database,omitempty"`
Blocklist []string `json:"blocklist,omitempty"`
Columns []ColumnConfigInput `json:"columns,omitempty"`
OrderBy map[string][]string `json:"order_by,omitempty"`
}
TableConfigInput represents a table config for input
type TableSchemaWithAggregations ¶ added in v3.2.1
type TableSchemaWithAggregations struct {
*core.TableSchema
Aggregations AggregationInfo `json:"aggregations"`
ExampleQueries []ExampleQuery `json:"example_queries,omitempty"`
}
TableSchemaWithAggregations extends TableSchema with aggregation information
type UpdateConfigInput ¶ added in v3.2.1
type UpdateConfigInput struct {
Filters []string `json:"filters,omitempty"`
Columns []string `json:"columns,omitempty"`
Presets map[string]string `json:"presets,omitempty"`
Block bool `json:"block,omitempty"`
}
UpdateConfigInput represents update permissions
type UpsertConfigInput ¶ added in v3.2.1
type UpsertConfigInput struct {
Filters []string `json:"filters,omitempty"`
Columns []string `json:"columns,omitempty"`
Presets map[string]string `json:"presets,omitempty"`
Block bool `json:"block,omitempty"`
}
UpsertConfigInput represents upsert permissions
type ValidationSyntax ¶ added in v3.2.1
type ValidationSyntax struct {
Directive string `json:"directive"`
Options []string `json:"options"`
Example string `json:"example"`
}
ValidationSyntax shows validation directive options
type VariablesSyntax ¶ added in v3.2.1
type VariablesSyntax struct {
Declaration string `json:"declaration"`
Types []string `json:"types"`
Example string `json:"example"`
}
VariablesSyntax shows how to use variables in queries
type WhereValidationError ¶ added in v3.2.1
type WhereValidationError struct {
Path string `json:"path"`
Error string `json:"error"`
Message string `json:"message"`
ColumnType string `json:"column_type,omitempty"`
Suggestion string `json:"suggestion,omitempty"`
}
WhereValidationError represents a single validation error
type WhereValidationResult ¶ added in v3.2.1
type WhereValidationResult struct {
Valid bool `json:"valid"`
Errors []WhereValidationError `json:"errors,omitempty"`
ColumnInfo map[string]ColumnTypeInfo `json:"column_info,omitempty"`
}
WhereValidationResult represents the result of where clause validation
type WorkflowGuide ¶ added in v3.2.1
type WorkflowGuide struct {
QueryWorkflow []string `json:"query_workflow"`
MutationWorkflow []string `json:"mutation_workflow"`
Tips []string `json:"tips"`
ToolSequences map[string]string `json:"tool_sequences"`
}
WorkflowGuide contains the recommended workflow for using GraphJin MCP tools
Source Files
¶
- admin.go
- admin_api.go
- afero.go
- api.go
- cache.go
- cache_memory.go
- cache_redis.go
- client.go
- config.go
- db.go
- deploy.go
- filewatch.go
- fuzz.go
- health.go
- http.go
- init.go
- iplimiter.go
- mcp.go
- mcp_audit.go
- mcp_config.go
- mcp_cursor.go
- mcp_cursor_cache.go
- mcp_db_guard.go
- mcp_ddl.go
- mcp_discover.go
- mcp_explain.go
- mcp_explore.go
- mcp_fragments.go
- mcp_health.go
- mcp_js_runtime.go
- mcp_next.go
- mcp_onboarding.go
- mcp_prompts.go
- mcp_schema.go
- mcp_search.go
- mcp_syntax.go
- mcp_tools.go
- migrate.go
- routes.go
- serv.go
- sqllog.go
- telemetry.go
- webui.go
- workflows.go
- ws.go