builder

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: May 15, 2025 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package builder provides the Builder pattern for creating MCP servers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithToolHandler

func WithToolHandler(toolName string, handler ToolHandlerFunc) stdio.StdioOption

WithToolHandler returns a stdio option to handle a specific tool. This allows you to register custom handlers for tools.

Types

type ServerBuilder

type ServerBuilder struct {
	// contains filtered or unexported fields
}

ServerBuilder implements the Builder pattern for creating MCP servers.

func NewServerBuilder

func NewServerBuilder() *ServerBuilder

NewServerBuilder creates a new server builder with default values.

func (*ServerBuilder) AddPrompt

func (b *ServerBuilder) AddPrompt(ctx context.Context, prompt *types.Prompt) *ServerBuilder

AddPrompt adds a prompt to the server's prompt repository.

func (*ServerBuilder) AddResource

func (b *ServerBuilder) AddResource(ctx context.Context, resource *types.Resource) *ServerBuilder

AddResource adds a resource to the server's resource repository.

func (*ServerBuilder) AddTool

func (b *ServerBuilder) AddTool(ctx context.Context, tool *types.Tool) *ServerBuilder

AddTool adds a tool to the server's tool repository.

func (*ServerBuilder) ServeStdio

func (b *ServerBuilder) ServeStdio(opts ...stdio.StdioOption) error

ServeStdio builds and starts serving a stdio server.

func (*ServerBuilder) WithAddress

func (b *ServerBuilder) WithAddress(address string) *ServerBuilder

WithAddress sets the server address.

func (*ServerBuilder) WithInstructions

func (b *ServerBuilder) WithInstructions(instructions string) *ServerBuilder

WithInstructions sets the server instructions.

func (*ServerBuilder) WithName

func (b *ServerBuilder) WithName(name string) *ServerBuilder

WithName sets the server name.

func (*ServerBuilder) WithNotificationSender

func (b *ServerBuilder) WithNotificationSender(sender types.NotificationSender) *ServerBuilder

WithNotificationSender sets the notification sender.

func (*ServerBuilder) WithPromptRepository

func (b *ServerBuilder) WithPromptRepository(repo types.PromptRepository) *ServerBuilder

WithPromptRepository sets the prompt repository.

func (*ServerBuilder) WithResourceRepository

func (b *ServerBuilder) WithResourceRepository(repo types.ResourceRepository) *ServerBuilder

WithResourceRepository sets the resource repository.

func (*ServerBuilder) WithSessionRepository

func (b *ServerBuilder) WithSessionRepository(repo types.SessionRepository) *ServerBuilder

WithSessionRepository sets the session repository.

func (*ServerBuilder) WithToolRepository

func (b *ServerBuilder) WithToolRepository(repo types.ToolRepository) *ServerBuilder

WithToolRepository sets the tool repository.

func (*ServerBuilder) WithVersion

func (b *ServerBuilder) WithVersion(version string) *ServerBuilder

WithVersion sets the server version.

type ToolHandlerFunc

type ToolHandlerFunc func(ctx context.Context, params map[string]interface{}, session *domain.ClientSession) (interface{}, error)

ToolHandlerFunc is an adapter function for handling tool calls in the MCP server. This wraps a custom handler function in the format expected by the internal APIs.

Jump to

Keyboard shortcuts

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