mcp

package
v1.6.3 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2026 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MaxStdioMessageSize sets the upper limit for a single JSON-RPC message line (16MB).
	MaxStdioMessageSize = 16 * 1024 * 1024
)
View Source
const ServerInstructions = store.DefaultServerInstructions

ServerInstructions is the fallback constant pointing to store.DefaultServerInstructions

Variables

This section is empty.

Functions

func RunStdio added in v1.2.0

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

RunStdio runs the stdio loop for the given MCP Server until EOF or ctx cancellation.

Types

type CredentialContext added in v1.1.0

type CredentialContext struct {
	CredentialID   uint
	CredentialName string
	HostName       string
	TokenString    string
	BaseURL        string
	Permissions    model.Permissions
	Source         string // "db_credential", "env_token", "open_access", "local_stdio"
}

func CredentialFromContext added in v1.1.0

func CredentialFromContext(ctx context.Context) *CredentialContext

func LocalStdioCredential added in v1.2.0

func LocalStdioCredential(defaultHost ...string) *CredentialContext

LocalStdioCredential returns the trusted local stdio credential context with full permissions.

type RPCExecutionResult added in v1.2.0

type RPCExecutionResult struct {
	Response       *jsonRPCResponse
	IsNotification bool
}

RPCExecutionResult represents the outcome of an RPC call.

type Server

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

func NewServer

func NewServer(cfg *config.Config, st *store.Store, onUpdate func(eventType string, data any)) *Server

func (*Server) GetActiveWaiterInfo

func (s *Server) GetActiveWaiterInfo(sessionID string) (bool, *time.Time, int)

func (*Server) GetLastKeepaliveTime

func (s *Server) GetLastKeepaliveTime(sessionID string) *time.Time

func (*Server) HandleRPCRequest added in v1.2.0

func (s *Server) HandleRPCRequest(ctx context.Context, credCtx *CredentialContext, req *jsonRPCRequest) RPCExecutionResult

HandleRPCRequest processes a parsed JSON-RPC request in a transport-neutral manner.

func (*Server) HasActiveWaiter

func (s *Server) HasActiveWaiter(sessionID string) bool

func (*Server) NotifySessionCompleted

func (s *Server) NotifySessionCompleted(sess *model.FeedbackSession)

func (*Server) RecordKeepaliveResponse

func (s *Server) RecordKeepaliveResponse(sessionID string)

func (*Server) ServeHTTP

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

type StdioTransport added in v1.2.0

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

StdioTransport manages the stdio JSON-RPC loop with concurrent execution, write serialization, and cancellation.

func NewStdioTransport added in v1.2.0

func NewStdioTransport(server *Server, in io.Reader, out io.Writer) *StdioTransport

NewStdioTransport creates a new StdioTransport instance.

func (*StdioTransport) Run added in v1.2.0

func (t *StdioTransport) Run(ctx context.Context) error

Run executes the stdio read loop until EOF or ctx cancellation.

type ToolDefinition

type ToolDefinition struct {
	Name        string          `json:"name"`
	Description string          `json:"description"`
	InputSchema json.RawMessage `json:"inputSchema"`
}

func GetToolDefinitionsForPermissions added in v1.1.0

func GetToolDefinitionsForPermissions(perms model.Permissions) []ToolDefinition

Jump to

Keyboard shortcuts

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