types

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2025 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package types provides shared types and interfaces for MCP components This avoids circular dependencies between packages

Index

Constants

View Source
const (
	InvalidParams    = -32602
	FileSystemError  = -32001
	LanguageNotFound = -32002
	SyntaxError      = -32003
	TransformFailed  = -32004
)

Error codes for MCP

Variables

This section is empty.

Functions

This section is empty.

Types

type Component

type Component interface {
	Name() string
	Description() string
}

Component represents a registrable MCP component (tool, prompt, resource)

type MCPError

type MCPError struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
	Data    any    `json:"data,omitempty"`
}

MCPError represents an MCP protocol error

func NewMCPError

func NewMCPError(code int, message string, data any) *MCPError

NewMCPError creates a new MCP error

func WrapError

func WrapError(code int, message string, err error) *MCPError

WrapError wraps an error with MCP error code

func (*MCPError) Error

func (e *MCPError) Error() string

Error implements the error interface

type Prompt

type Prompt interface {
	Component
	Content() string
	Arguments() []PromptArgument
}

Prompt represents a system prompt

type PromptArgument

type PromptArgument struct {
	Name        string `json:"name"`
	Description string `json:"description,omitempty"`
	Required    bool   `json:"required,omitempty"`
}

PromptArgument represents an argument for a prompt

type PromptDefinition

type PromptDefinition struct {
	Name        string           `json:"name"`
	Description string           `json:"description,omitempty"`
	Arguments   []PromptArgument `json:"arguments,omitempty"`
}

PromptDefinition describes a prompt for the MCP client

type Resource

type Resource interface {
	Component
	URI() string
	MimeType() string
	Contents() (string, error)
}

Resource represents a readable resource

type ResourceDefinition

type ResourceDefinition struct {
	URI         string `json:"uri"`
	Name        string `json:"name"`
	Description string `json:"description,omitempty"`
	MimeType    string `json:"mimeType,omitempty"`
}

ResourceDefinition describes a resource for the MCP client

type ServerInterface

type ServerInterface interface {
	GetProviders() *providers.Registry
	GetFileProcessor() *core.FileProcessor
	GetStaging() any
	GetSafety() any
}

ServerInterface defines what tools need from the server

type Tool

type Tool interface {
	Component
	Handler() ToolHandler
	InputSchema() map[string]any
}

Tool represents an executable tool with handler

type ToolDefinition

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

ToolDefinition describes a tool for the MCP client

type ToolHandler

type ToolHandler func(params json.RawMessage) (any, error)

ToolHandler represents a function that handles a tool call

Jump to

Keyboard shortcuts

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