Documentation
¶
Index ¶
- Constants
- func CreateServer(version string, cfg *config.File, st stats.StatsConfig, opts ServerOptions) (*mcp.Server, error)
- func NewStreamableHTTPHandler(server *mcp.Server, authToken string) (http.Handler, error)
- func NewStreamableHTTPHandlerWithTimeout(server *mcp.Server, authToken string, timeout time.Duration) (http.Handler, error)
- func WriteAllowed(serverAllowsWrite, profileAllowsWrite bool) bool
- type ProfileShowInput
- type QueryInput
- type SchemaDescribeTableInput
- type SchemaDumpInput
- type SchemaListTablesInput
- type ServerOptions
- type ToolHandler
- func (h *ToolHandler) ProfileList(ctx context.Context, req *mcp.CallToolRequest, input struct{}) (*mcp.CallToolResult, any, error)
- func (h *ToolHandler) ProfileShow(ctx context.Context, req *mcp.CallToolRequest, input ProfileShowInput) (*mcp.CallToolResult, any, error)
- func (h *ToolHandler) Query(ctx context.Context, req *mcp.CallToolRequest, input QueryInput) (*mcp.CallToolResult, any, error)
- func (h *ToolHandler) RegisterTools(server *mcp.Server)
- func (h *ToolHandler) SchemaDescribeTable(ctx context.Context, req *mcp.CallToolRequest, input SchemaDescribeTableInput) (*mcp.CallToolResult, any, error)
- func (h *ToolHandler) SchemaDump(ctx context.Context, req *mcp.CallToolRequest, input SchemaDumpInput) (*mcp.CallToolResult, any, error)
- func (h *ToolHandler) SchemaListTables(ctx context.Context, req *mcp.CallToolRequest, input SchemaListTablesInput) (*mcp.CallToolResult, any, error)
Constants ¶
const ( TransportStdio = "stdio" TransportStreamableHTTP = "streamable_http" )
const (
DefaultHTTPTimeout = 60 * time.Second
)
Variables ¶
This section is empty.
Functions ¶
func CreateServer ¶
func CreateServer(version string, cfg *config.File, st stats.StatsConfig, opts ServerOptions) (*mcp.Server, error)
CreateServer creates a new MCP server
func NewStreamableHTTPHandler ¶ added in v0.0.6
func NewStreamableHTTPHandlerWithTimeout ¶ added in v0.0.10
func WriteAllowed ¶ added in v1.21.0
WriteAllowed reports whether MCP query tool may bypass read-only protections. Dual authorization matches CLI/TUI: both the MCP server entrypoint and the profile must explicitly opt in.
Types ¶
type ProfileShowInput ¶
type ProfileShowInput struct {
Name string `json:"name" jsonschema:"Profile name"`
}
ProfileShowInput represents the input for the profile_show tool
type QueryInput ¶
type QueryInput struct {
SQL string `json:"sql" jsonschema:"SQL query to execute"`
Profile string `json:"profile" jsonschema:"Profile name to use"`
MaxRows *int `json:"max_rows,omitempty" jsonschema:"Maximum rows to return (0 = default; clamped by mcp.max_rows_limit; MCP default 500)"`
}
QueryInput represents the input for the query tool
type SchemaDescribeTableInput ¶ added in v1.21.0
type SchemaDescribeTableInput struct {
Profile string `json:"profile" jsonschema:"Profile name to use"`
Schema string `json:"schema,omitempty" jsonschema:"Schema name (PostgreSQL; optional for MySQL)"`
Table string `json:"table" jsonschema:"Table name"`
}
SchemaDescribeTableInput is input for schema_describe_table.
type SchemaDumpInput ¶ added in v1.21.0
type SchemaDumpInput struct {
Profile string `json:"profile" jsonschema:"Profile name to use"`
TablePattern string `json:"table_pattern,omitempty" jsonschema:"Table name filter (* and ? wildcards)"`
IncludeSystem bool `json:"include_system,omitempty" jsonschema:"Include system tables"`
}
SchemaDumpInput is input for schema_dump.
type SchemaListTablesInput ¶ added in v1.21.0
type SchemaListTablesInput struct {
Profile string `json:"profile" jsonschema:"Profile name to use"`
TablePattern string `json:"table_pattern,omitempty" jsonschema:"Table name filter (* and ? wildcards)"`
IncludeSystem bool `json:"include_system,omitempty" jsonschema:"Include system tables"`
}
SchemaListTablesInput is input for schema_list_tables.
type ServerOptions ¶ added in v1.21.0
type ServerOptions struct {
UnsafeAllowWrite bool // server-level write opt-in (dual auth with profile)
}
ServerOptions configures MCP server behavior passed from the CLI entrypoint.
type ToolHandler ¶
type ToolHandler struct {
// contains filtered or unexported fields
}
ToolHandler manages MCP tools
func NewToolHandler ¶
func NewToolHandler(cfg *config.File, st stats.StatsConfig, opts ServerOptions) *ToolHandler
NewToolHandler creates a new tool handler
func (*ToolHandler) ProfileList ¶
func (h *ToolHandler) ProfileList(ctx context.Context, req *mcp.CallToolRequest, input struct{}) (*mcp.CallToolResult, any, error)
ProfileList lists all profiles
func (*ToolHandler) ProfileShow ¶
func (h *ToolHandler) ProfileShow(ctx context.Context, req *mcp.CallToolRequest, input ProfileShowInput) (*mcp.CallToolResult, any, error)
ProfileShow shows profile details
func (*ToolHandler) Query ¶
func (h *ToolHandler) Query(ctx context.Context, req *mcp.CallToolRequest, input QueryInput) (*mcp.CallToolResult, any, error)
Query executes a SQL query via internal/app.
func (*ToolHandler) RegisterTools ¶
func (h *ToolHandler) RegisterTools(server *mcp.Server)
RegisterTools registers all tools with the MCP server
func (*ToolHandler) SchemaDescribeTable ¶ added in v1.21.0
func (h *ToolHandler) SchemaDescribeTable(ctx context.Context, req *mcp.CallToolRequest, input SchemaDescribeTableInput) (*mcp.CallToolResult, any, error)
SchemaDescribeTable describes one table via internal/app.
func (*ToolHandler) SchemaDump ¶ added in v1.21.0
func (h *ToolHandler) SchemaDump(ctx context.Context, req *mcp.CallToolRequest, input SchemaDumpInput) (*mcp.CallToolResult, any, error)
SchemaDump dumps schema via internal/app.
func (*ToolHandler) SchemaListTables ¶ added in v1.21.0
func (h *ToolHandler) SchemaListTables(ctx context.Context, req *mcp.CallToolRequest, input SchemaListTablesInput) (*mcp.CallToolResult, any, error)
SchemaListTables lists tables via internal/app.