mcpbridge

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2026 License: Apache-2.0 Imports: 5 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package mcpbridge serves MemSpace's MCP tools to a local agent over stdio, forwarding every call to the server's streamable HTTP endpoint.

Agents then only need a command in their configuration (`memspace mcp stdio`): the bridge reads the device's credentials itself, so no token is written into agent configs or the shell environment, and a rotated token or a moved server needs no change on the agent side.

Both legs use the MCP SDK, so each negotiates its own protocol version and headers; the bridge mirrors the server's tools and instructions as they are when it starts.

Index

Constants

View Source
const ConnectTimeout = 8 * time.Second

ConnectTimeout bounds reaching the server at start-up. Agents give MCP servers only a few seconds to start.

Variables

This section is empty.

Functions

func Connect

func Connect(ctx context.Context, opts Options) (*mcp.ClientSession, error)

Connect opens a client session to the server's MCP endpoint.

func Mirror

func Mirror(ctx context.Context, remote *mcp.ClientSession, version string) (*mcp.Server, error)

Mirror returns a server that offers remote's tools and instructions and forwards each tool call to remote.

func Run

func Run(ctx context.Context, opts Options, t mcp.Transport) error

Run connects to the server, then serves its tools on t until the agent disconnects or ctx is cancelled.

Types

type Options

type Options struct {
	// URL is the server's MCP endpoint, e.g. http://host:8765/mcp.
	URL string
	// Token is sent as a bearer token (the device's read-only MCP token).
	Token string
	// Transport carries the HTTP requests (e.g. one that skips proxies for
	// private hosts). Nil means http.DefaultTransport.
	Transport http.RoundTripper
	// Version is reported to both sides.
	Version string
}

Options configure a bridge.

Jump to

Keyboard shortcuts

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