Documentation
¶
Index ¶
- func BuildToolInputSchema(params []ParamDef) (json.RawMessage, error)
- func ParseResourceTemplate(uri string) (*uritemplate.Template, error)
- func ProcessMcpServerBlock(config *cfg.Config, block *hcl.Block, remainingBody hcl.Body) (cfg.Listener, hcl.Diagnostics)
- type McpServer
- type McpServerDefinition
- type ParamDef
- type PromptDef
- type ResourceDef
- type Server
- type ServerConfig
- type ToolDef
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildToolInputSchema ¶
func BuildToolInputSchema(params []ParamDef) (json.RawMessage, error)
BuildToolInputSchema generates a JSON Schema object for the given params, suitable for use as Tool.InputSchema in the MCP SDK.
func ParseResourceTemplate ¶
func ParseResourceTemplate(uri string) (*uritemplate.Template, error)
ParseResourceTemplate parses the URI template if the URI contains '{'. Returns a ResourceDef with Template set, or an error.
Types ¶
type McpServer ¶
type McpServer struct {
cfg.BaseServer
// contains filtered or unexported fields
}
McpServer wraps an mcp.Server and implements the config Listener, Startable, and HandlerServer interfaces so it integrates with the vinculum config system.
func (*McpServer) GetHandler ¶
type McpServerDefinition ¶
type McpServerDefinition struct {
Listen string `hcl:"listen,optional"`
Path string `hcl:"path,optional"`
ServerName string `hcl:"server_name,optional"`
ServerVersion string `hcl:"server_version,optional"`
Disabled bool `hcl:"disabled,optional"`
Tracing hcl.Expression `hcl:"tracing,optional"`
Metrics hcl.Expression `hcl:"metrics,optional"`
TLS *cfg.TLSConfig `hcl:"tls,block"`
Auth *cfg.AuthConfig `hcl:"auth,block"`
Baggage *hclutil.BaggageFilterConfig `hcl:"baggage,block"`
DefRange hcl.Range `hcl:",def_range"`
Resources []mcpResourceDefinition `hcl:"resource,block"`
Tools []mcpToolDefinition `hcl:"tool,block"`
Prompts []mcpPromptDefinition `hcl:"prompt,block"`
}
type ParamDef ¶
type ParamDef struct {
Name string
Type string // "string", "number", "boolean"
Description string
Required bool
DefaultVal any
Enum []any
}
ParamDef describes a single parameter for a tool or prompt.
type PromptDef ¶
type PromptDef struct {
Name string
Description string
Params []ParamDef
Action hcl.Expression
}
PromptDef holds the parsed definition of a single MCP prompt.
type ResourceDef ¶
type ResourceDef struct {
URI string
Name string
Description string
MIMEType string
Action hcl.Expression
// Template is non-nil when URI contains {variables}.
Template *uritemplate.Template
}
ResourceDef holds the parsed definition of a single MCP resource.
func (*ResourceDef) IsTemplate ¶
func (d *ResourceDef) IsTemplate() bool
IsTemplate reports whether this resource uses a URI template.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is a vinculum MCP server. It wraps the MCP SDK server and handles action-based (synchronous) resource, tool, and prompt requests by evaluating HCL expressions with per-request eval contexts.
func New ¶
func New(scfg ServerConfig) (*Server, error)
New creates a new MCP server from the given configuration.
func (*Server) GetDefRange ¶
GetDefRange returns the HCL source range of the server block definition.
func (*Server) HTTPHandler ¶
HTTPHandler returns the http.Handler for this server. Used when the MCP server is mounted under an HTTP server block.
type ServerConfig ¶
type ServerConfig struct {
Name string
DefRange hcl.Range
Listen string
Path string
ServerName string
ServerVersion string
TLSConfig *tls.Config
Auth *cfg.AuthConfig
OtlpClient cfg.OtlpClient
// TracerProvider, when set, overrides the tracer provider used for
// MCP-method spans. When nil, it is derived from OtlpClient (else the
// global provider). Primarily a test injection point.
TracerProvider oteltrace.TracerProvider
MeterProvider otelmetric.MeterProvider
BaggageFilter *hclutil.BaggageFilterConfig
ParentEvalCtx *hcl.EvalContext
Logger *zap.Logger
Resources []ResourceDef
Tools []ToolDef
Prompts []PromptDef
}
ServerConfig holds all parsed configuration needed to create an MCP Server.