Documentation
¶
Index ¶
- Variables
- type Builder
- func (f *Builder) BuildFxApp() (*fx.App, error)
- func (f *Builder) Err() error
- func (f *Builder) Run() error
- func (f *Builder) WithExtraServerOptions(extraOptions ...server.ServerOption) *Builder
- func (f *Builder) WithFxOptions(opts ...fx.Option) *Builder
- func (f *Builder) WithName(name string) *Builder
- func (f *Builder) WithPrompt(newPrompt any) *Builder
- func (f *Builder) WithResource(newResource any) *Builder
- func (f *Builder) WithResourceProvider(newResourceProvider any) *Builder
- func (f *Builder) WithServerCapabilities(serverCapabilities *mcp.ServerCapabilities) *Builder
- func (f *Builder) WithTool(newTool any) *Builder
- func (f *Builder) WithTransport(transport server.Transport) *Builder
- func (f *Builder) WithVersion(version string) *Builder
- type ServerLifecycleParams
Constants ¶
This section is empty.
Variables ¶
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
BuildFxApp builds the fx.App instance as configured by `With*` methods
func (*Builder) Run ¶ added in v0.0.13
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
WithFxOptions adds additional fx.Options to fx.App instance
func (*Builder) WithName ¶ added in v0.0.13
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
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
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
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
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
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
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"`
}