mcp

package
v0.44.0 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2026 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

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.

func ProcessMcpServerBlock

func ProcessMcpServerBlock(config *cfg.Config, block *hcl.Block, remainingBody hcl.Body) (cfg.Listener, hcl.Diagnostics)

ProcessMcpServerBlock parses an "server mcp" block and creates an McpServer.

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

func (s *McpServer) GetHandler() http.Handler

func (*McpServer) Start

func (s *McpServer) Start() error

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

func (s *Server) GetDefRange() hcl.Range

GetDefRange returns the HCL source range of the server block definition.

func (*Server) GetName

func (s *Server) GetName() string

GetName returns the server's config block name.

func (*Server) HTTPHandler

func (s *Server) HTTPHandler() http.Handler

HTTPHandler returns the http.Handler for this server. Used when the MCP server is mounted under an HTTP server block.

func (*Server) SDKServer

func (s *Server) SDKServer() *sdkmcp.Server

SDKServer returns the underlying MCP SDK server. Intended for use in tests.

func (*Server) Start

func (s *Server) Start() error

Start begins listening for connections on the configured address.

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.

type ToolDef

type ToolDef struct {
	Name        string
	Description string
	Params      []ParamDef
	Action      hcl.Expression
}

ToolDef holds the parsed definition of a single MCP tool.

Jump to

Keyboard shortcuts

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