# Go MCP API

Source: https://libtmux.org/en/go/latest/mcp/reference/

> Find the Go managed server lifecycle and distinguish exported APIs from wire operations.

For MCP client requests, use the [tool reference](../tools/). 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](https://pkg.go.dev/github.com/libtmux/libtmux-go/mcp)
describes lifecycle, capacity, and transport ownership.

## MCP operations

The [tool reference](../tools/) 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](../../workspace/reference/).

[Server registration](https://github.com/libtmux/libtmux-go/blob/52968a3181c1c9e6d1b26c565d4b170968ae61c0/mcp/server.go)
and [agent example](../examples/) connect the language and protocol APIs.

## API declarations

- [mcp.AdvertisedTools](https://libtmux.org/en/go/latest/mcp/reference/mcp-advertisedtools/)
- [mcp.AdvertisedToolsFor](https://libtmux.org/en/go/latest/mcp/reference/mcp-advertisedtoolsfor/)
- [mcp.AssumeResponseCommit](https://libtmux.org/en/go/latest/mcp/reference/mcp-assumeresponsecommit/)
- [mcp.AuditEnvironmentVariable](https://libtmux.org/en/go/latest/mcp/reference/mcp-auditenvironmentvariable/)
- [mcp.BinaryEnvironmentVariable](https://libtmux.org/en/go/latest/mcp/reference/mcp-binaryenvironmentvariable/)
- [mcp.CapabilitiesResourceURI](https://libtmux.org/en/go/latest/mcp/reference/mcp-capabilitiesresourceuri/)
- [mcp.CapabilityMetaKey](https://libtmux.org/en/go/latest/mcp/reference/mcp-capabilitymetakey/)
- [mcp.ErrInstanceClosed](https://libtmux.org/en/go/latest/mcp/reference/mcp-errinstanceclosed/)
- [mcp.ErrRequestCapacity](https://libtmux.org/en/go/latest/mcp/reference/mcp-errrequestcapacity/)
- [mcp.ErrResponseCommitUnknown](https://libtmux.org/en/go/latest/mcp/reference/mcp-errresponsecommitunknown/)
- [mcp.ErrRuntimeTargetBound](https://libtmux.org/en/go/latest/mcp/reference/mcp-errruntimetargetbound/)
- [mcp.ExcludeToolsEnvironmentVariable](https://libtmux.org/en/go/latest/mcp/reference/mcp-excludetoolsenvironmentvariable/)
- [mcp.HandshakeOrdered](https://libtmux.org/en/go/latest/mcp/reference/mcp-handshakeordered/)
- [mcp.Instance](https://libtmux.org/en/go/latest/mcp/reference/mcp-instance/)
- [mcp.MaterializeMinimalConfig](https://libtmux.org/en/go/latest/mcp/reference/mcp-materializeminimalconfig/)
- [mcp.NewServer](https://libtmux.org/en/go/latest/mcp/reference/mcp-newserver/)
- [mcp.RecipeToolEnvironmentVariable](https://libtmux.org/en/go/latest/mcp/reference/mcp-recipetoolenvironmentvariable/)
- [mcp.Run](https://libtmux.org/en/go/latest/mcp/reference/mcp-run/)
- [mcp.RunDefaultMinimal](https://libtmux.org/en/go/latest/mcp/reference/mcp-rundefaultminimal/)
- [mcp.SafetyEnvironmentVariable](https://libtmux.org/en/go/latest/mcp/reference/mcp-safetyenvironmentvariable/)
- [mcp.ServerSession](https://libtmux.org/en/go/latest/mcp/reference/mcp-serversession/)
- [mcp.SocketEnvironmentVariable](https://libtmux.org/en/go/latest/mcp/reference/mcp-socketenvironmentvariable/)
- [mcp.SocketPathEnvironmentVariable](https://libtmux.org/en/go/latest/mcp/reference/mcp-socketpathenvironmentvariable/)
- [mcp.TmuxConfigEnvironmentVariable](https://libtmux.org/en/go/latest/mcp/reference/mcp-tmuxconfigenvironmentvariable/)
- [mcp.ToolDetails](https://libtmux.org/en/go/latest/mcp/reference/mcp-tooldetails/)
- [mcp.ToolsEnvironmentVariable](https://libtmux.org/en/go/latest/mcp/reference/mcp-toolsenvironmentvariable/)
- [mcp.ToolsetsEnvironmentVariable](https://libtmux.org/en/go/latest/mcp/reference/mcp-toolsetsenvironmentvariable/)
- [mcp.Version](https://libtmux.org/en/go/latest/mcp/reference/mcp-version/)
- [mcp.WaitCeilingEnvironmentVariable](https://libtmux.org/en/go/latest/mcp/reference/mcp-waitceilingenvironmentvariable/)

[Protocol catalog](https://libtmux.org/en/go/latest/mcp/tools.json)
