app

package
v0.0.14 Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2024 License: MIT Imports: 6 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoTransportSpecified = errors.New("no transport specified, please use WithTransport to specify a transport")
)

Functions

This section is empty.

Types

type Builder added in v0.0.13

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

Builder wraps fx.App and provides a more user-friendly interface for building and running your MCP server

You would be calling WithTool, WithResource, WithResourceProvider, WithPrompt to register your tools, resources, resource providers and prompts and then calling Run to start the server, or you can instead call BuildFxApp to get the fx.App instance and run it yourself. You must set transport using WithTransport. Unless you configure server using WithName and WithVersion, it will use default values "my-foxy-contexts-server" and "0.0.1". Finally you can use WithFxOptions to pass additional fx.Options to the fx.App instance before it is built.

func NewBuilder added in v0.0.13

func NewBuilder() *Builder

func (*Builder) BuildFxApp added in v0.0.13

func (f *Builder) BuildFxApp() (*fx.App, error)

BuildFxApp builds the fx.App instance as configured by `With*` methods

func (*Builder) Err added in v0.0.13

func (f *Builder) Err() error

func (*Builder) Run added in v0.0.13

func (f *Builder) Run() error

Run builds and runs the fx.App instance as configured by `With*` methods

func (*Builder) WithExtraServerOptions added in v0.0.13

func (f *Builder) WithExtraServerOptions(extraOptions ...server.ServerOption) *Builder

func (*Builder) WithFxOptions added in v0.0.13

func (f *Builder) WithFxOptions(opts ...fx.Option) *Builder

WithFxOptions adds additional fx.Options to fx.App instance

func (*Builder) WithName added in v0.0.13

func (f *Builder) WithName(name string) *Builder

WithName sets the name of the server

The name would be returned to client during the initialization phase, if not set, it would default to "my-foxy-contexts-server"

func (*Builder) WithPrompt added in v0.0.13

func (f *Builder) WithPrompt(newPrompt any) *Builder

WithPrompt adds a prompt to the app

newPrompt must be a function that returns a fxctx.Prompt it can also take in any dependencies that you want to inject into the prompt, that will be resolved by the fx framework

func (*Builder) WithResource added in v0.0.13

func (f *Builder) WithResource(newResource any) *Builder

WithResource adds a resource to the app

newResource must be a function that returns a fxctx.Resource it can also take in any dependencies that you want to inject into the resource, that will be resolved by the fx framework

func (*Builder) WithResourceProvider added in v0.0.13

func (f *Builder) WithResourceProvider(newResourceProvider any) *Builder

WithResourceProvider adds a resource provider to the app

newResourceProvider must be a function that returns a fxctx.ResourceProvider it can also take in any dependencies that you want to inject into the resource provider, that will be resolved by the fx framework

func (*Builder) WithServerCapabilities added in v0.0.13

func (f *Builder) WithServerCapabilities(serverCapabilities *mcp.ServerCapabilities) *Builder

WithServerCapabilities sets the server capabilities

serverCapabilities is a struct that defines the capabilities of the server that would be returned to the client during the initialization phase if not set, it would default to an empty struct, which could cause clients to not work as expected, so it is recommended to set this

func (*Builder) WithTool added in v0.0.13

func (f *Builder) WithTool(newTool any) *Builder

WithTool adds a tool to the app

newTool must be a function that returns a fxctx.Tool it can also take in any dependencies that you want to inject into the tool, that will be resolved by the fx framework

func (*Builder) WithTransport added in v0.0.13

func (f *Builder) WithTransport(transport server.Transport) *Builder

WithStdioTransport sets up the server to use stdio transport

options can be used to configure the stdio transport

func (*Builder) WithVersion added in v0.0.13

func (f *Builder) WithVersion(version string) *Builder

WithVersion sets the version of the server

The version would be returned to client during the initialization phase, if not set, it would default to "0.0.1"

type ServerLifecycleParams

type ServerLifecycleParams struct {
	fx.In

	ToolMux     fxctx.ToolMux     `optional:"true"`
	ResourceMux fxctx.ResourceMux `optional:"true"`
	PromptMux   fxctx.PromptMux   `optional:"true"`
	CompleteMux fxctx.CompleteMux `optional:"true"`
}

Jump to

Keyboard shortcuts

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