Help us shape the future of Go! Take the 2026 Go Developer Survey

mcpserver

package
v0.2.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 25, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package mcpserver exposes dbq's service layer over the Model Context Protocol.

Tool names are prefixed with "dbq_" so they stay distinguishable when an agent has several database MCP servers connected at once.

Index

Constants

View Source
const ToolPrefix = "dbq_"

ToolPrefix namespaces every tool dbq registers.

Variables

This section is empty.

Functions

func Handler

func Handler(server *mcp.Server, opts Options) http.Handler

Handler returns the streamable HTTP handler to mount on the web server.

The same *mcp.Server instance is reused for every session: it holds no per-client state, and the SDK explicitly supports getServer returning the same server multiple times.

func New

func New(svc *service.Service, opts Options) *mcp.Server

New builds an MCP server exposing dbq's tools.

Types

type Options

type Options struct {
	// Name and Version identify the server to clients.
	Name    string
	Version string
	// Scope limits which connections are exposed and what may be run on them.
	Scope service.Scope
	// MaxSchemaTables caps dbq_schema_context. Zero uses the service default.
	MaxSchemaTables int
	// Stateless disables MCP session state, required behind a load balancer.
	Stateless bool
	// JSONResponse returns application/json instead of text/event-stream.
	JSONResponse bool
	// SessionTimeout closes idle sessions. Zero means never.
	SessionTimeout time.Duration
	// Logger receives MCP protocol logs. Nil disables them.
	Logger *slog.Logger
	// Exports stores generated SQL outside the model context. Nil disables export.
	Exports *artifact.Store
	// ExportBaseURL is prepended to artifact download paths. Empty keeps them relative.
	ExportBaseURL string
	// MaxExportRows caps rows written to one artifact.
	MaxExportRows int
	// AllowedOrigins permits exact cross-origin browser clients.
	AllowedOrigins []string
}

Options configures the MCP server.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL