mcpclient

package
v0.0.0-...-444abac Latest Latest
Warning

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

Go to latest
Published: May 5, 2026 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxMetaListItems      = 2000
	MaxMetaToolReplyRunes = 120_000
)
View Source
const DefaultToolsListCacheTTL = 2 * time.Minute

Variables

This section is empty.

Functions

func CallTool

func CallTool(ctx context.Context, srv *domain.MCPServer, mcpToolName string, arguments json.RawMessage, notify ...*ToolsListCache) (string, error)

func CallToolResultString

func CallToolResultString(r *mcp.CallToolResult) string

func LogServerMessages

func LogServerMessages() bool

func MCPCountersMap

func MCPCountersMap() map[string]uint64

func ParseToolAlias

func ParseToolAlias(normalized string) (serverID int64, mcpToolName string, ok bool)

func RootsFromConfigStrings

func RootsFromConfigStrings(rows []string) ([]*mcp.Root, error)

func SamplingEnabled

func SamplingEnabled() bool

func SetActiveServerCatalogProvider

func SetActiveServerCatalogProvider(p ActiveServerCatalogProvider)

func SetCallToolTransportRetry

func SetCallToolTransportRetry(enabled bool)

func SetHTTPHostPolicy

func SetHTTPHostPolicy(p func(host string) bool)

func SetHTTPReuseSessions

func SetHTTPReuseSessions(v bool)

func SetHTTPSessionMaxIdleSec

func SetHTTPSessionMaxIdleSec(sec int)

func SetListRequestCoalescing

func SetListRequestCoalescing(enabled bool)

func SetLogServerMessages

func SetLogServerMessages(v bool)

func SetMaxTrackedCallStatServerIDs

func SetMaxTrackedCallStatServerIDs(n int)

func SetSamplingEnabled

func SetSamplingEnabled(v bool)

func SetSessionRoots

func SetSessionRoots(roots []*mcp.Root)

func SetToolsListCacheForNotifications

func SetToolsListCacheForNotifications(c *ToolsListCache)

func ToolAlias

func ToolAlias(serverID int64, mcpToolName string) string

func TruncateLLMReply

func TruncateLLMReply(s string, maxRunes int) string

func WithSamplingRunner

func WithSamplingRunner(ctx context.Context, sr *SamplingRunner) context.Context

func WritePrometheusMetrics

func WritePrometheusMetrics(w io.Writer) error

Types

type ActiveServerCatalogProvider

type ActiveServerCatalogProvider func() []ActiveServerDescriptor

type ActiveServerDescriptor

type ActiveServerDescriptor struct {
	ID   int64
	Name string
}

type CallToolServerCounters

type CallToolServerCounters struct {
	OK           uint64
	TransportErr uint64
	MCPError     uint64
}

type DeclaredPrompt

type DeclaredPrompt struct {
	Name          string
	Title         string
	Description   string
	ArgumentsJSON string
}

func ListPrompts

func ListPrompts(ctx context.Context, srv *domain.MCPServer) ([]DeclaredPrompt, error)

type DeclaredResource

type DeclaredResource struct {
	URI         string
	Name        string
	Title       string
	Description string
	MIMEType    string
}

func ListResources

func ListResources(ctx context.Context, srv *domain.MCPServer) ([]DeclaredResource, error)

type DeclaredTool

type DeclaredTool struct {
	Name           string
	Description    string
	ParametersJSON string
}

func ListTools

func ListTools(ctx context.Context, srv *domain.MCPServer) ([]DeclaredTool, error)

type MCPServerSLORow

type MCPServerSLORow struct {
	ServerID        int64   `json:"server_id"`
	ServerName      string  `json:"server_name,omitempty"`
	CallTotal       uint64  `json:"call_total"`
	SuccessTotal    uint64  `json:"success_total"`
	TransportErrors uint64  `json:"transport_errors"`
	MCPErrors       uint64  `json:"mcp_errors"`
	SuccessRatio    float64 `json:"success_ratio"`
	ErrorRatio      float64 `json:"error_ratio"`
	TargetRatio     float64 `json:"target_ratio"`
	TargetMet       bool    `json:"target_met"`
	UpdatedAt       string  `json:"updated_at"`
}

func MCPServerSLODashboard

func MCPServerSLODashboard() []MCPServerSLORow

type SamplingRunner

type SamplingRunner struct {
	LLM            domain.LLMRepository
	SessionID      int64
	RunnerAddr     string
	Model          string
	StopSequences  []string
	TimeoutSeconds int32
	GenParams      *domain.GenerationParams
}

type ServerProbe

type ServerProbe struct {
	ProtocolVersion string
	ServerName      string
	ServerVersion   string
	Instructions    string
	HasTools        bool
	HasResources    bool
	HasPrompts      bool
}

func ProbeServer

func ProbeServer(ctx context.Context, srv *domain.MCPServer, notify *ToolsListCache) (*ServerProbe, error)

type ToolsListCache

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

func NewToolsListCache

func NewToolsListCache() *ToolsListCache

func (*ToolsListCache) InvalidateServerID

func (c *ToolsListCache) InvalidateServerID(id int64)

func (*ToolsListCache) InvalidateServerPrompts

func (c *ToolsListCache) InvalidateServerPrompts(id int64)

func (*ToolsListCache) InvalidateServerResources

func (c *ToolsListCache) InvalidateServerResources(id int64)

func (*ToolsListCache) InvalidateServerTools

func (c *ToolsListCache) InvalidateServerTools(id int64)

func (*ToolsListCache) ListPromptsCached

func (c *ToolsListCache) ListPromptsCached(ctx context.Context, srv *domain.MCPServer, ttl time.Duration) ([]DeclaredPrompt, error)

func (*ToolsListCache) ListResourcesCached

func (c *ToolsListCache) ListResourcesCached(ctx context.Context, srv *domain.MCPServer, ttl time.Duration) ([]DeclaredResource, error)

func (*ToolsListCache) ListToolsCached

func (c *ToolsListCache) ListToolsCached(ctx context.Context, srv *domain.MCPServer, ttl time.Duration) ([]DeclaredTool, error)

Jump to

Keyboard shortcuts

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