server

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2025 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package server provides the core MCP server implementation for the Firebolt MCP. It defines interfaces for tools, prompts, and resource templates that can be registered with the server, as well as methods for serving the MCP over different transports.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

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.ResourceContents, 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" or "sse").
  • transportSSEAddress: The address to listen on when using SSE transport.
  • 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 with its name, description, parameters, etc.
	Tool() mcp.Tool
	// Handler processes tool call requests and returns results.
	Handler(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error)
}

Tool represents a callable tool that can be registered with the MCP server. It provides methods to define the tool metadata and handle tool calls.

Jump to

Keyboard shortcuts

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