server

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2025 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MethodExecutor

type MethodExecutor interface {
	ExecuteMethod(serviceName, methodName string, params map[string]interface{}) (interface{}, error)
}

MethodExecutor defines the interface for executing methods

type Server

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

func NewServer

func NewServer(opts ...ServerOpts) *Server

func (*Server) ExecuteMethod

func (s *Server) ExecuteMethod(serviceName, methodName string, params map[string]any) (any, error)

ExecuteMethod executes a method through the method executor

func (*Server) GetMethodExecutor

func (s *Server) GetMethodExecutor() MethodExecutor

GetMethodExecutor returns the method executor

func (*Server) GetToolRegistry

func (s *Server) GetToolRegistry() ToolRegistry

GetToolRegistry returns the tool registry

func (*Server) GetTransport

func (s *Server) GetTransport() Transport

GetTransport returns the underlying transport

func (*Server) HTTPHandler

func (s *Server) HTTPHandler() any

HTTPHandler returns the HTTP handler if the transport supports it

func (*Server) ListenAndServe

func (s *Server) ListenAndServe(addr string) error

func (*Server) RegisterMethod

func (s *Server) RegisterMethod(serviceName, methodName, description string, parameters map[string]any) error

RegisterMethod registers a method as a tool

func (*Server) RegisterMethodLLM

func (s *Server) RegisterMethodLLM(methodName, description string, returns ...string) error

RegisterMethodLLM registers a method using LLM-friendly combined description. This method provides an alternative to RegisterMethod that allows for more flexible parameter descriptions suitable for LLM consumption. The description parameter should contain all necessary information for an LLM to understand how to call the method, including parameter schemas, examples, and natural language guidance.

The methodName should be in the format "ServiceName.MethodName". The optional returns parameter specifies the return type description.

func (*Server) RegisterService

func (s *Server) RegisterService(service any) error

RegisterService registers a service with the underlying transport if it supports service registration

type ServerOpts

type ServerOpts func(*Server)

func WithMethodExecutor

func WithMethodExecutor(executor MethodExecutor) ServerOpts

func WithToolRegistry

func WithToolRegistry(registry ToolRegistry) ServerOpts

func WithTransport

func WithTransport(transport Transport, opts ...TransportOpts) ServerOpts

type ToolRegistry

type ToolRegistry interface {
	RegisterMethod(serviceName, methodName, description string, parameters map[string]interface{}) error
	// RegisterMethodLLM registers a method using LLM-friendly combined description
	RegisterMethodLLM(methodName, description string, returns ...string) error
}

ToolRegistry defines the interface for tool registration

type Transport

type Transport interface {
	ListenAndServe(addr string) error
}

type TransportOpts

type TransportOpts func(Transport) Transport

Directories

Path Synopsis
http provides adapters and functionality to serve the server over HTTP It wires up the stdlib's http functionality to the server package's connection type
http provides adapters and functionality to serve the server over HTTP It wires up the stdlib's http functionality to the server package's connection type
Package tools handles the registration and storage of available tools in the agent server
Package tools handles the registration and storage of available tools in the agent server

Jump to

Keyboard shortcuts

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