dispatcher

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetSessionID

func GetSessionID(ctx context.Context) (string, bool)

GetSessionID retrieves the session ID from the context

func MustGetSessionID

func MustGetSessionID(ctx context.Context) string

MustGetSessionID retrieves the session ID from the context, panicking if not found

func NewErrorResponse

func NewErrorResponse(id json.RawMessage, code int, message string, data interface{}) (*protocol.Response, error)

NewErrorResponse creates a new error response

func NewSuccessResponse

func NewSuccessResponse(id json.RawMessage, result interface{}) (*protocol.Response, error)

NewSuccessResponse creates a new success response with the given result

func WithSessionID

func WithSessionID(ctx context.Context, sessionID string) context.Context

WithSessionID adds a session ID to the context

Types

type Dispatcher

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

Dispatcher handles the MCP protocol methods and dispatches them to appropriate services

func NewDispatcher

NewDispatcher creates a new dispatcher instance

func (*Dispatcher) Dispatch

func (d *Dispatcher) Dispatch(ctx context.Context, request protocol.Request) (*protocol.Response, error)

Dispatch handles an incoming request and returns a response

type ListPromptsResult

type ListPromptsResult struct {
	Prompts    []protocol.Prompt `json:"prompts"`
	NextCursor string            `json:"nextCursor"`
}

Common result types

type ListResourcesResult

type ListResourcesResult struct {
	Resources  []protocol.Resource `json:"resources"`
	NextCursor string              `json:"nextCursor"`
}

type ListToolsResult

type ListToolsResult struct {
	Tools      []protocol.Tool `json:"tools"`
	NextCursor string          `json:"nextCursor"`
}

type PromptResult

type PromptResult struct {
	Description string                   `json:"description"`
	Messages    []protocol.PromptMessage `json:"messages"`
}

type ResourceResult

type ResourceResult struct {
	Contents []protocol.ResourceContent `json:"contents"`
}

Jump to

Keyboard shortcuts

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