mcp

package
v0.8.7 Latest Latest
Warning

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

Go to latest
Published: May 1, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Close added in v0.0.31

func Close(session *ClientSession) error

func Completions added in v0.8.6

func Completions(values []string) *mcp.CompleteResult

func CompletionsPage added in v0.8.6

func CompletionsPage(values []string, hasMore bool, total int) *mcp.CompleteResult

func ErrorResult

func ErrorResult(msg string) any

func GetPrompt added in v0.8.6

func GetPrompt(ctx context.Context, session *ClientSession, name string, args map[string]string) (*mcp.GetPromptResult, error)

func New

func New(name string, version string) *mcp.Server

func NewWithCompletion added in v0.8.6

func NewWithCompletion(name string, version string, handler CompletionHandler) *mcp.Server

func Prompt added in v0.8.6

func Prompt(server *mcp.Server, name string, description string, args []PromptArg, handler PromptHandler)

func ReadResource added in v0.8.6

func ReadResource(ctx context.Context, session *ClientSession, uri string) ([]*mcp.ResourceContents, error)

func Required

func Required(schema map[string]any, names []string) map[string]any

func Resource added in v0.8.6

func Resource(server *mcp.Server, uri string, name string, description string, mimeType string, handler ResourceHandler)

func ResourceTemplate added in v0.8.6

func ResourceTemplate(server *mcp.Server, uriTemplate string, name string, description string, mimeType string, handler ResourceHandler)

func Schema

func Schema(props []SchemaProperty) map[string]any

func Serve

func Serve(server *mcp.Server) error

func ServeHTTP added in v0.8.6

func ServeHTTP(server *mcp.Server, addr string) error

func TextResource added in v0.8.6

func TextResource(server *mcp.Server, uri string, name string, description string, fn TextResourceFunc)

func TextResourceTemplate added in v0.8.6

func TextResourceTemplate(server *mcp.Server, uriTemplate string, name string, description string, fn TextResourceFunc)

func TextResult

func TextResult(text string) any

func Tool

func Tool(server *mcp.Server, name string, description string, schema any, handler ToolHandler)

func ToolRich added in v0.8.6

func ToolRich(server *mcp.Server, name string, description string, schema any, handler ToolRichHandler)

func ToolWithOpts added in v0.8.6

func ToolWithOpts(server *mcp.Server, name string, description string, schema any, opts ToolOpts, handler ToolHandler)

func ToolWithSampling added in v0.1.5

func ToolWithSampling(server *mcp.Server, name string, description string, schema any, handler ToolSamplingHandler)

func UserPrompt added in v0.8.6

func UserPrompt(server *mcp.Server, name string, description string, args []PromptArg, fn UserPromptFunc)

Types

type AudioContent added in v0.1.7

type AudioContent = mcp.AudioContent

type CallToolParams added in v0.1.5

type CallToolParams = mcp.CallToolParams

type CallToolResult added in v0.0.31

type CallToolResult struct {
	Text    string
	IsError bool
	Content []any
}

func CallTool added in v0.0.31

func CallTool(ctx context.Context, session *ClientSession, name string, args map[string]any) (CallToolResult, error)

type Client added in v0.1.5

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

func NewClientWithSampling added in v0.1.5

func NewClientWithSampling(name string, version string, handler SamplingHandler) *Client

func NewClientWithSamplingTools added in v0.1.5

func NewClientWithSamplingTools(name string, version string, handler SamplingWithToolsHandler) *Client

func (*Client) Connect added in v0.1.5

func (c *Client) Connect(ctx context.Context, endpoint string) (*ClientSession, error)

func (*Client) ConnectWith added in v0.1.5

func (c *Client) ConnectWith(ctx context.Context, endpoint string, httpClient *http.Client) (*ClientSession, error)

type ClientPrompt added in v0.8.6

type ClientPrompt struct {
	Name        string
	Description string
	Arguments   []PromptArg
}

func ListPrompts added in v0.8.6

func ListPrompts(ctx context.Context, session *ClientSession) ([]ClientPrompt, error)

type ClientResource added in v0.8.6

type ClientResource struct {
	URI         string
	Name        string
	Description string
	MIMEType    string
}

func ListResources added in v0.8.6

func ListResources(ctx context.Context, session *ClientSession) ([]ClientResource, error)

type ClientResourceTemplate added in v0.8.6

type ClientResourceTemplate struct {
	URITemplate string
	Name        string
	Description string
	MIMEType    string
}

func ListResourceTemplates added in v0.8.6

func ListResourceTemplates(ctx context.Context, session *ClientSession) ([]ClientResourceTemplate, error)

type ClientSession added in v0.0.31

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

func BearerConnect added in v0.1.3

func BearerConnect(ctx context.Context, endpoint string, token string) (*ClientSession, error)

func Connect added in v0.0.31

func Connect(ctx context.Context, endpoint string) (*ClientSession, error)

func ConnectFromSession added in v0.1.7

func ConnectFromSession(inner *mcp.ClientSession) *ClientSession

func ConnectWithClient added in v0.1.3

func ConnectWithClient(ctx context.Context, endpoint string, httpClient *http.Client) (*ClientSession, error)

type ClientTool added in v0.0.31

type ClientTool struct {
	Name        string
	Description string
	InputSchema map[string]any
}

func ListTools added in v0.0.31

func ListTools(ctx context.Context, session *ClientSession) ([]ClientTool, error)

type CompleteParams added in v0.8.6

type CompleteParams = mcp.CompleteParams

type CompleteRequest added in v0.8.6

type CompleteRequest = mcp.CompleteRequest

type CompleteResult added in v0.8.6

type CompleteResult = mcp.CompleteResult

type CompletionHandler added in v0.8.6

type CompletionHandler func(context.Context, *mcp.CompleteRequest) (*mcp.CompleteResult, error)

type CompletionResultDetails added in v0.8.6

type CompletionResultDetails = mcp.CompletionResultDetails

type CompletionRouter added in v0.8.6

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

func NewRouter added in v0.8.6

func NewRouter() *CompletionRouter

func (*CompletionRouter) AddPrompt added in v0.8.6

func (r *CompletionRouter) AddPrompt(promptName string, completer PromptCompleter)

func (*CompletionRouter) AddResource added in v0.8.6

func (r *CompletionRouter) AddResource(resourceURI string, completer ResourceCompleter)

func (*CompletionRouter) Handler added in v0.8.6

func (r *CompletionRouter) Handler() CompletionHandler

type CreateMessageParams added in v0.1.5

type CreateMessageParams = mcp.CreateMessageParams

type CreateMessageResult added in v0.1.5

type CreateMessageResult = mcp.CreateMessageResult

type CreateMessageWithToolsParams added in v0.1.5

type CreateMessageWithToolsParams = mcp.CreateMessageWithToolsParams

type CreateMessageWithToolsResult added in v0.1.5

type CreateMessageWithToolsResult = mcp.CreateMessageWithToolsResult

type ElicitParams added in v0.8.6

type ElicitParams = mcp.ElicitParams

type ElicitResult added in v0.8.6

type ElicitResult = mcp.ElicitResult

type EmbeddedResource added in v0.1.7

type EmbeddedResource = mcp.EmbeddedResource

type GetPromptRequest added in v0.8.6

type GetPromptRequest = mcp.GetPromptRequest

type GetPromptResult added in v0.8.6

type GetPromptResult = mcp.GetPromptResult

type ImageContent added in v0.1.5

type ImageContent = mcp.ImageContent

type LoggingMessageParams added in v0.8.6

type LoggingMessageParams = mcp.LoggingMessageParams

type ProgressNotificationParams added in v0.8.6

type ProgressNotificationParams = mcp.ProgressNotificationParams

type PromptArg added in v0.8.6

type PromptArg struct {
	Name        string
	Description string
	Required    bool
}

type PromptCompleter added in v0.8.6

type PromptCompleter func(string, string, map[string]string) []string

type PromptHandler added in v0.8.6

type PromptHandler = mcp.PromptHandler

type PromptMessage added in v0.8.6

type PromptMessage = mcp.PromptMessage

type ReadResourceRequest added in v0.8.6

type ReadResourceRequest = mcp.ReadResourceRequest

type ReadResourceResult added in v0.8.6

type ReadResourceResult = mcp.ReadResourceResult

type ResourceCompleter added in v0.8.6

type ResourceCompleter func(string, string, map[string]string) []string

type ResourceContents added in v0.1.7

type ResourceContents = mcp.ResourceContents

type ResourceHandler added in v0.8.6

type ResourceHandler = mcp.ResourceHandler
type ResourceLink = mcp.ResourceLink

type Root added in v0.8.6

type Root = mcp.Root

type SamplingCapabilities added in v0.1.5

type SamplingCapabilities = mcp.SamplingCapabilities

type SamplingHandler added in v0.1.5

type SamplingMessage added in v0.1.5

type SamplingMessage = mcp.SamplingMessage

type SamplingMessageV2 added in v0.1.5

type SamplingMessageV2 = mcp.SamplingMessageV2

type SamplingToolsCapabilities added in v0.1.5

type SamplingToolsCapabilities = mcp.SamplingToolsCapabilities

type SamplingWithToolsHandler added in v0.1.5

type SchemaProperty

type SchemaProperty struct {
	Name        string
	Type        string
	Description string
}

func Prop

func Prop(name string, typ string, description string) SchemaProperty

type Server added in v0.1.9

type Server = mcp.Server

type ServerSession added in v0.1.5

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

func (*ServerSession) CreateMessage added in v0.1.5

func (ss *ServerSession) CreateMessage(ctx context.Context, params *mcp.CreateMessageParams) (*mcp.CreateMessageResult, error)

func (*ServerSession) CreateMessageWithTools added in v0.1.5

type TextContent added in v0.1.5

type TextContent = mcp.TextContent

type TextResourceFunc added in v0.8.6

type TextResourceFunc func(string) (string, error)

type ToolChoice added in v0.1.5

type ToolChoice = mcp.ToolChoice

type ToolContext added in v0.8.6

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

func (*ToolContext) CreateMessage added in v0.8.6

func (tc *ToolContext) CreateMessage(ctx context.Context, params *mcp.CreateMessageParams) (*mcp.CreateMessageResult, error)

func (*ToolContext) Elicit added in v0.8.6

func (tc *ToolContext) Elicit(ctx context.Context, message string, schema any) (string, map[string]any, error)

func (*ToolContext) ListRoots added in v0.8.6

func (tc *ToolContext) ListRoots(ctx context.Context) ([]*mcp.Root, error)

func (*ToolContext) Log added in v0.8.6

func (tc *ToolContext) Log(ctx context.Context, level string, data any) error

func (*ToolContext) Progress added in v0.8.6

func (tc *ToolContext) Progress(ctx context.Context, progress float64, total float64, msg string) error

type ToolHandler

type ToolHandler func(map[string]any) (any, error)

type ToolOpts added in v0.8.6

type ToolOpts struct {
	ReadOnly     bool
	Destructive  bool
	Idempotent   bool
	OutputSchema any
}

type ToolResultContent added in v0.1.5

type ToolResultContent = mcp.ToolResultContent

type ToolRichHandler added in v0.8.6

type ToolRichHandler func(context.Context, *ToolContext, map[string]any) (any, error)

type ToolSamplingHandler added in v0.1.5

type ToolSamplingHandler func(context.Context, *ServerSession, map[string]any) (any, error)

type ToolUseContent added in v0.1.5

type ToolUseContent = mcp.ToolUseContent

type UserPromptFunc added in v0.8.6

type UserPromptFunc func(map[string]string) (string, error)

Jump to

Keyboard shortcuts

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