stacklok / stacklok/toolhive

vmcp/session: expose a pluggable backendConnector on NewSessionFactory

Open
#4,929 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement go vmcp
Dominant language
Go
Stars
2.2k
Forks
300
Avg merge
1d 15h
Merged PRs (30d)
184

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in pkg/vmcp/session/factory.go around backendConnector at line 117, NewSessionFactory at line 187, and newSessionFactoryWithConnector at line 194; then inspect backend.Session and NewHTTPConnector under pkg/vmcp/session/internal/backend/. Done means external connector implementations have a public target type and option, while the existing HTTP connector remains the default.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
backend-api-design
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.