Go MCP API
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 lifecycle¶
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 operations¶
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.
Tools
mcp.AdvertisedPrompts- AdvertisedPrompts returns the prompts a server started now would list, from the same startup selection as AdvertisedTools. It starts nothing.
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. It asks whether a tmux server is answering and starts nothing.
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.
Resources and URIs
mcp.CapabilitiesResourceURI- CapabilitiesResourceURI is the static MCP resource that discloses the startup-frozen surface. The tmux:// hierarchy below is offered beside it, one route per selected read tool.
Server and setup
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.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.NewServer- NewServer returns a closeable MCP instance exposing target. It rejects an invalid target before allocating instance-owned resources.
mcp.Run- Run serves target over stdin and stdout until ctx is done.
mcp.ServerSession- ServerSession owns one SDK session and the resources scoped to its client.
mcp.Version- Version is reported during MCP initialization. Installed binaries derive it from build metadata; source builds use fallbackVersion.
Configuration and environment
mcp.AllowAttendedInputEnvironmentVariable- AllowAttendedInputEnvironmentVariable lets the input tools deliver to a pane a tmux client is viewing. The only accepted value is 1, and unset keeps the refusal.
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.CapabilityMetaKey- CapabilityMetaKey is the MCP metadata key carrying the complete capability row that also drives registration and tmux://capabilities.
mcp.ExcludeToolsEnvironmentVariable- ExcludeToolsEnvironmentVariable removes exact names after every inclusion.
mcp.PromptMetaKey- PromptMetaKey is the MCP metadata key carrying the complete prompt row that also drives registration and tmux://capabilities.
mcp.RecipeToolEnvironmentVariable- RecipeToolEnvironmentVariable is rejected because prompt exports were retired.
mcp.SafetyEnvironmentVariable- SafetyEnvironmentVariable is rejected because ordered safety tiers were retired.
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.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.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.
Errors
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.