mcp.Instance
Go
- Python Unavailable
- Ruby Unavailable
- Lua Unavailable
- TypeScript Unavailable
- Rust Unavailable
- Go
- Java Unavailable
- .NET Unavailable
- C++ Unavailable
- Swift Unavailable
-
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.
Discussed in Go MCP API
Members
- Connect ( ctx : context.Context , transport : sdk.Transport , options : *sdk.ServerSessionOptions ) (*ServerSession, error)
-
Connect starts and tracks one client session. It requires tmux 3.2a or newer and rejects an opaque transport unless
AssumeResponseCommitmarks its response-write contract. Incoming messages remain gated until the SDK session has an installed scope.Discussed in Go MCP API
- Run ( ctx : context.Context , transport : sdk.Transport ) error
-
Run serves one tracked session until the client, context, or instance ends. Its transport requirements are the same as
Instance.Connect.
-
Close starts shutdown and waits on a bounded internal context.
- CloseContext ( ctx : context.Context ) error
-
CloseContext starts shutdown unconditionally. ctx bounds only this call's wait; a later call can resume waiting for the same shutdown.