appmcp

package
v0.16.521 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2026 License: AGPL-3.0 Imports: 14 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 appmcp is the stdio side of the harnessly-app MCP server: a child of the agent that passes its JSON-RPC to the runtime over HTTP and outlives the runtime's restarts.

An agent that talks to the runtime's Streamable HTTP endpoint itself loses the server at a release. Claude Code reopens the GET stream once the runtime is gone; a runtime that is still starting answers 405 (it cannot place the caller in a chat yet), which the client takes for "this server has no stream" and never asks again, so tools/list_changed stops for the rest of the chat; and a runtime that stays down past the client's few attempts is dropped altogether. A stdio server stays connected for as long as its process lives, so the waiting is done here: the stream is reopened with pauses for ever, the client is told to ask tools/list again after every reopening, and a call made while the runtime is away waits for it.

Index

Constants

View Source
const (
	EnvURL     = "HARNESSLY_APP_MCP_URL"
	EnvHeaders = "HARNESSLY_APP_MCP_HEADERS"
)

The environment the launch's MCP config gives the proxy (internal/apps launch.go). The token travels there and not on the command line, which every process of the machine can read.

View Source
const (
	KeyHeader    = "X-Harnessly-Call-Key"
	RepeatHeader = "X-Harnessly-Call-Repeat"
	KeysHeader   = "X-Harnessly-Call-Keys"
)

The headers of a tool call's idempotency. The proxy gives every tools/call a key of its own (KeyHeader). The runtime keeps a window's command under that key, so the same call made again finds its command and its answer and makes no second one. A call is made again only when its answer was lost with the connection (the runtime restarted), only to a runtime that says it knows the keys (KeysHeader on its answers), and marked RepeatHeader: the runtime then runs nothing a second time, it answers from its journal or says the answer is lost.

View Source
const (
	// DefaultWait is how long a request waits for a runtime that does not answer before the agent is told so.
	DefaultWait = 20 * time.Second
	// DefaultRetry is the pause between two tries of a request, and the first pause before the stream is reopened.
	DefaultRetry = 300 * time.Millisecond
	// DefaultMaxPause is the longest pause before the stream is reopened.
	DefaultMaxPause = 5 * time.Second
)
View Source
const Command = "app-mcp"

Command is the harnessly subcommand that runs the proxy.

Variables

This section is empty.

Functions

This section is empty.

Types

type Proxy

type Proxy struct {
	// URL is the runtime's MCP endpoint of the server, Headers what every request carries (the token).
	URL     string
	Headers map[string]string
	In      io.Reader
	Out     io.Writer
	// Client makes the requests; nil is one without a deadline (a tool may wait for the person) that gives up a dial
	// after three seconds.
	Client *http.Client
	// Wait, Retry, MaxPause: zero is the default of each.
	Wait, Retry, MaxPause time.Duration
	// contains filtered or unexported fields
}

Proxy passes the JSON-RPC lines of In to the runtime at URL and writes the answers, and what the runtime's stream says, as lines to Out.

func FromEnv

func FromEnv(getenv func(string) string, in io.Reader, out io.Writer) (*Proxy, error)

FromEnv is the proxy the launch's config describes; an error names what the config lacks.

func (*Proxy) Run

func (p *Proxy) Run(ctx context.Context) error

Run serves until In ends (the agent closed the server) or ctx is done; the requests in flight are then given up.

Jump to

Keyboard shortcuts

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