bridge

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package bridge serves tools to agent processes over MCP on localhost.

Each agent gets its own namespace (/mcp/<agent>) holding the shared tools plus any the agent contributes via agent.ToolProvider. A tool call is routed to the Handler of the conversation that made it.

Index

Constants

View Source
const Name = "pocketagent"

Name is the MCP server name agents see.

Variables

View Source
var SendFile = agent.Tool{
	Name: "send_file",
	Description: "Send a file from this machine to the user's chat. Images (png/jpg/gif/webp) " +
		"are shown inline; anything else is sent as a document. Use it when the user asks to " +
		"see a screenshot, chart, image or file.",
	Schema: map[string]any{
		"type":     "object",
		"required": []string{"path"},
		"properties": map[string]any{
			"path":    map[string]any{"type": "string", "description": "absolute path of the file to send"},
			"caption": map[string]any{"type": "string", "description": "optional short caption"},
		},
	},
	Call: func(ctx context.Context, h agent.Handler, args json.RawMessage) (string, error) {
		var in struct {
			Path    string `json:"path"`
			Caption string `json:"caption"`
		}
		if err := json.Unmarshal(args, &in); err != nil {
			return "", err
		}
		if !filepath.IsAbs(in.Path) {
			return "", fmt.Errorf("path must be absolute")
		}
		if err := h.SendFile(ctx, in.Path, in.Caption); err != nil {
			return "", err
		}
		return "sent", nil
	},
}

SendFile lets an agent send a file from this machine to the conversation.

Functions

This section is empty.

Types

type Bridge

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

func Start

func Start(host string, shared ...agent.Tool) (*Bridge, error)

Start listens on a random port. host is how agents reach it: "" or 127.0.0.1 normally, host.docker.internal for agents in containers. shared tools are offered to every agent.

func (*Bridge) AddAgent added in v0.6.0

func (b *Bridge) AddAgent(name string, extra []agent.Tool)

AddAgent creates the namespace for an agent with the shared tools plus extra.

func (*Bridge) Attach added in v0.6.0

func (b *Bridge) Attach(conv string, h agent.Handler) (detach func())

Attach routes tool calls from conv's agent to h until detach is called.

func (*Bridge) Server

func (b *Bridge) Server(agentName, conv string) *agent.ToolServer

Server is how agentName, running for conv, connects.

Jump to

Keyboard shortcuts

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