Skip to content

vmcp/session: expose a pluggable backendConnector on NewSessionFactory #4929

@JAORMX

Description

@JAORMX

Problem

session.NewSessionFactory(registry, opts...) at pkg/vmcp/session/factory.go:187 is the only public constructor for MultiSessionFactory. It hardcodes backend.NewHTTPConnector(registry) as the connector.

The internal plumbing for a custom connector exists:

  • backendConnector type at factory.go:117 (unexported)
  • newSessionFactoryWithConnector at factory.go:194 (unexported, appears test-only)
  • backend.Session + backend.NewHTTPConnector live under pkg/vmcp/session/internal/backend/ — Go's internal path rule prevents external use.

Use case

Embedders whose gateway already resolves per-backend capability lists (for conflict resolution, ACL filtering, static catalog composition) need the session factory to present those pre-resolved capabilities instead of re-fetching them over HTTP at every session initialize. Similarly, embedders with stateless dispatch models do not want the factory to open N live MCP client connections per session.

Proposed API

Export the backendConnector interface (or lift it to pkg/vmcp/session/types next to MultiSession), and add a functional option:

func WithBackendConnector(conn BackendConnector) MultiSessionFactoryOption

When supplied, NewSessionFactory uses it instead of backend.NewHTTPConnector. The default stays unchanged.

Separately, expose backend.Session (or a narrower interface specifically for connector implementations) via pkg/vmcp/session/types so external implementations have a target type to return.

Scope

  • Additive. No change to the existing HTTP-connector default.
  • May require widening backend.Session to live outside internal/ — suggest moving just the interface, not the HTTP implementation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestgoPull requests that update go codevmcpVirtual MCP Server related issues

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions