github.com/libtmux/libtmux-go/mcp · Source
For MCP client requests, use the tool reference. This page covers language APIs for embedding or extending the server.
The Go MCP module exports a managed server instance. Tool handlers can be private Go functions while their registered names remain public MCP operations.
Embedding lifecycleLink to section
mcp.NewServer(target) accepts a core tmux Server and returns an
Instance plus an error. Close the instance after serving to release
its runtime resources.
Instance.Connect connects a client transport. Custom transports use
AssumeResponseCommit only when a successful write commits exactly one
response. This is a transport contract, not a retry wrapper.
Applications that need the ordinary stdio lifecycle can use
mcp.Run(ctx, target). The
package reference
describes lifecycle, capacity, and transport ownership.
MCP operationsLink to section
The tool reference covers registered names and schemas. Toolsets and exact names filter both listing and invocation.
The static tmux://capabilities resource reports the startup-frozen
surface. Live reads use inspect tools. Workspace construction belongs
to the separate workspace module.
Server registration and agent example connect the language and protocol APIs.
API declarations
Follow a declaration for its signature, members, documentation, and source.
Exports
mcp.AdvertisedTools- AdvertisedTools returns caller-owned descriptions of the startup-selected tools. It performs an in-memory MCP handshake without opening tmux or allocating runtime-owned audit resources.
mcp.AdvertisedToolsFor- AdvertisedToolsFor returns the tools a server started now against target would advertise. defaultMinimal selects RunDefaultMinimal's rule, which grants teardown tools only when that server creates the tmux server, so only when none is answering yet; Run never grants them by default. It asks whether a tmux server is answering and starts nothing.
mcp.AssumeResponseCommit- AssumeResponseCommit marks transport as committing each response before its Connection.Write returns nil. It does not change transport behavior. Use it only for a transport that rejects JSON-RPC batches or writes every response independently; direct IO and stdio transports are handled automatically.
mcp.AuditEnvironmentVariable- AuditEnvironmentVariable names the variable that turns the record on and says where it goes: "stderr", or a path to append to.
mcp.BinaryEnvironmentVariable- BinaryEnvironmentVariable selects the tmux executable.
mcp.CapabilitiesResourceURI- CapabilitiesResourceURI is the only MCP resource exposed by this server.
mcp.CapabilityMetaKey- CapabilityMetaKey is the MCP metadata key carrying the complete capability row that also drives registration and tmux://capabilities.
mcp.ErrInstanceClosed- ErrInstanceClosed identifies work refused after instance shutdown starts.
mcp.ErrRequestCapacity- ErrRequestCapacity identifies a client session closed after it exceeded the server's finite unsettled-call capacity.
mcp.ErrResponseCommitUnknown- ErrResponseCommitUnknown identifies a transport whose successful Write may leave one response buffered behind another response in a JSON-RPC batch.
mcp.ErrRuntimeTargetBound- ErrRuntimeTargetBound identifies a target already bound to a terminal Connection. An MCP runtime must own the connection it creates.
mcp.ExcludeToolsEnvironmentVariable- ExcludeToolsEnvironmentVariable removes exact names after every inclusion.
mcp.HandshakeOrdered- HandshakeOrdered holds the SDK's early tool-list notification until notifications/initialized; strict legacy clients reject the earlier ordering.
mcp.Instance- Instance owns the SDK server, all connected client sessions, and every resource allocated on their behalf. The SDK server is composed so Connect and Run cannot bypass lifecycle tracking.
mcp.MaterializeMinimalConfig- MaterializeMinimalConfig writes the embedded dedicated-server configuration for tmux's -f option. The caller keeps it until the MCP process stops.
mcp.NewServer- NewServer returns a closeable MCP instance exposing target. It rejects an invalid target before allocating instance-owned resources.
mcp.RecipeToolEnvironmentVariable- RecipeToolEnvironmentVariable is rejected because prompt exports were retired.
mcp.Run- Run serves target over stdin and stdout until ctx is done.
mcp.RunDefaultMinimal- RunDefaultMinimal serves a package-created default dedicated target. It starts or joins the daemon with a one-use owner marker and grants default teardown only when the marker proves this process created that daemon.
mcp.SafetyEnvironmentVariable- SafetyEnvironmentVariable is rejected because ordered safety tiers were retired.
mcp.ServerSession- ServerSession owns one SDK session and the resources scoped to its client.
mcp.SocketEnvironmentVariable- SocketEnvironmentVariable selects one named tmux socket.
mcp.SocketPathEnvironmentVariable- SocketPathEnvironmentVariable selects one absolute tmux socket path.
mcp.TmuxConfigEnvironmentVariable- TmuxConfigEnvironmentVariable selects an absolute tmux config path.
mcp.ToolDetails- ToolDetails returns what the named tool does, without the capability disclosure every description opens with. The disclosure is shared across a toolset, so a listing that shows only a description's first sentence would otherwise show the same sentence for every tool in it.
mcp.ToolsEnvironmentVariable- ToolsEnvironmentVariable adds exact tool names after toolset expansion.
mcp.ToolsetsEnvironmentVariable- ToolsetsEnvironmentVariable selects unordered inspect, manage, execute, and teardown groups. A present empty value selects no groups.
mcp.Version- Version is reported during MCP initialization. Installed binaries derive it from build metadata; source builds use fallbackVersion.
mcp.WaitCeilingEnvironmentVariable- WaitCeilingEnvironmentVariable names the variable that raises or lowers the longest wait this server will run, in seconds. It matches the Python server so an operator configuring both writes one thing.