server

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2026 License: Apache-2.0 Imports: 8 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config added in v0.6.0

type Config struct {
	Transport                 string
	TransportSSEListenAddress string
	DisableResources          bool

	ClientID     string
	ClientSecret string

	Environment string
	CoreURL     string

	SkipDocsProof bool
}

func (Config) Validate added in v0.6.0

func (c Config) Validate() error

type Prompt

type Prompt interface {
	// Prompt returns the MCP prompt definition.
	Prompt() *mcp.Prompt
	// Handler processes prompt requests and returns results.
	Handler(ctx context.Context, request *mcp.GetPromptRequest) (*mcp.GetPromptResult, error)
}

Prompt represents a prompt that can be registered with the MCP server. It provides methods to define the prompt metadata and handle prompt requests.

type ResourceTemplate

type ResourceTemplate interface {
	// ResourceTemplate returns the MCP resource template definition.
	ResourceTemplate() *mcp.ResourceTemplate
	// Handler processes resource read requests and returns resource contents.
	Handler(ctx context.Context, request *mcp.ReadResourceRequest) (*mcp.ReadResourceResult, error)
}

ResourceTemplate represents a resource template that can be registered with the MCP server. It provides methods to define the resource template metadata and handle resource requests.

type Server

type Server interface {
	// Serve starts the server with the provided context and handles MCP requests
	// until the context is canceled or an error occurs.
	Serve(ctx context.Context) error
}

Server represents the interface for the MCP server functionality. It defines the method to start the server and handle MCP requests.

func NewServer

func NewServer(
	logger *slog.Logger,
	version string,
	transport string,
	transportSSEAddress string,
	tools []Tool,
	prompts []Prompt,
	resourceTemplates []ResourceTemplate,
) Server

NewServer creates a new MCP server with the provided configuration. It registers the provided tools, prompts, and resource templates with the server.

Parameters:

  • logger: The structured logger to use for logging.
  • transport: The transport type to use ("stdio", "sse" or "streamable-http").
  • transportSSEAddress: The address to listen on when using an HTTP transport (SSE or Streamable HTTP).
  • tools: The list of tools to register with the server.
  • prompts: The list of prompts to register with the server.
  • resourceTemplates: The list of resource templates to register with the server.

Returns a Server that can be used to start handling MCP requests.

type Tool

type Tool interface {
	// Tool returns the MCP tool definition.
	Tool() *mcp.Tool
	// Register adds the tool to the server using its specific generic types.
	Register(s *mcp.Server)
}

Tool represents a callable tool that can be registered with the MCP server. It provides methods to define the tool metadata and register it in mcp server.

Jump to

Keyboard shortcuts

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