backend

package
v0.11.1 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package backend defines the Session interface for a single persistent backend connection and provides the HTTP-based implementation used in production. It is internal to pkg/vmcp/session.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewHTTPConnector

func NewHTTPConnector(registry vmcpauth.OutgoingAuthRegistry) func(
	ctx context.Context,
	target *vmcp.BackendTarget,
	identity *auth.Identity,
) (Session, *vmcp.CapabilityList, error)

NewHTTPConnector returns a function that creates an HTTP-based (streamable-HTTP or SSE) persistent backend Session for each backend.

registry provides the authentication strategy for outgoing backend requests. Pass a registry configured with the "unauthenticated" strategy to disable auth.

Types

type Session

type Session interface {
	// CallTool invokes toolName on the backend.
	// arguments contains the tool input parameters.
	// meta contains protocol-level metadata (_meta) forwarded from the client.
	CallTool(
		ctx context.Context,
		toolName string,
		arguments map[string]any,
		meta map[string]any,
	) (*vmcp.ToolCallResult, error)

	// ReadResource retrieves the resource identified by uri from the backend.
	ReadResource(ctx context.Context, uri string) (*vmcp.ResourceReadResult, error)

	// GetPrompt retrieves the named prompt from the backend.
	// arguments contains the prompt input parameters.
	GetPrompt(
		ctx context.Context,
		name string,
		arguments map[string]any,
	) (*vmcp.PromptGetResult, error)

	// Close releases all resources held by this session. Implementations must
	// be idempotent: calling Close multiple times returns nil.
	Close() error

	// SessionID returns the backend-assigned session ID (if any).
	// Returns "" if the backend did not assign a session ID.
	SessionID() string
}

Session abstracts a persistent, initialised MCP connection to a single backend server. It is created once per backend during session creation and reused for the lifetime of the parent MultiSession.

Each Session is bound to exactly one backend at creation time — callers do not need to pass a routing target to individual method calls.

Caller validation happens at the MultiSession level, not here. These methods perform the actual I/O operations without authentication checks.

Implementations must be safe for concurrent use.

Jump to

Keyboard shortcuts

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