mcp

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2026 License: GPL-3.0 Imports: 15 Imported by: 1 module, 1 package

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ServeStdio

func ServeStdio(ctx context.Context) error

func WithCredential added in v0.5.0

func WithCredential(ctx context.Context, credential clicore.Credential) context.Context

WithCredential returns ctx carrying the Share2Us credential used by tool handlers. The hosted transport resolves the request bearer to a credential and sets it here before each CallTool.

Types

type ClientFactory

type ClientFactory func(clicore.Credential) Client

type CredentialLoader

type CredentialLoader func() (clicore.Credential, error)

type HTTPCredentialResolver

type HTTPCredentialResolver func(*http.Request) (clicore.Credential, error)

type Option

type Option func(*Server)

func WithClientFactory

func WithClientFactory(factory ClientFactory) Option

func WithCredentialLoader

func WithCredentialLoader(loader CredentialLoader) Option

func WithDisabledTools

func WithDisabledTools(names ...string) Option

func WithHTTPCredentialResolver

func WithHTTPCredentialResolver(resolver HTTPCredentialResolver) Option

func WithPreviewBuilder

func WithPreviewBuilder(builder PreviewBuilder) Option

type PreviewBuilder

type PreviewBuilder func(string) (preflight.Result, error)

type Server

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

func NewServer

func NewServer(options ...Option) *Server

func (*Server) CallTool added in v0.5.0

func (s *Server) CallTool(ctx context.Context, name string, args json.RawMessage) (any, error)

CallTool invokes a registered tool by name with raw JSON arguments and returns the tool's result value (or an error). The caller MUST place the Share2Us credential in ctx with WithCredential first; tool handlers read it to call share2us-api.

func (*Server) Serve

func (s *Server) Serve(ctx context.Context, in io.Reader, out io.Writer) error

func (*Server) ServeHTTP

func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)

func (*Server) Tools added in v0.5.0

func (s *Server) Tools() []ToolDescriptor

Tools returns the enabled tools' descriptors in stable registration order, for a transport that needs to answer tools/list itself.

type Tool

type Tool struct {
	Descriptor ToolDescriptor
	Handler    func(context.Context, json.RawMessage) (any, error)
}

type ToolDescriptor

type ToolDescriptor struct {
	Name        string         `json:"name"`
	Description string         `json:"description"`
	InputSchema map[string]any `json:"inputSchema"`
}

Jump to

Keyboard shortcuts

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