Documentation
¶
Overview ¶
Copyright 2026 Teradata
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Package transport implements HTTP/SSE transport for MCP servers.
Copyright 2026 Teradata ¶
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Package transport implements stream resumption for streamable-http transport.
Copyright 2026 Teradata ¶
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Package transport implements session management for streamable-http transport.
Copyright 2026 Teradata ¶
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Package transport implements SSE parsing for streamable-http transport.
Copyright 2026 Teradata ¶
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Package transport implements stdio transport for MCP servers.
Copyright 2026 Teradata ¶
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Package transport implements streamable-http transport for MCP servers.
Copyright 2026 Teradata ¶
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Package transport implements the communication layer for MCP protocol.
Index ¶
- Variables
- type HTTPConfig
- type HTTPTransport
- type ReadWriteCloser
- type SSEEvent
- type SSEParser
- type SessionManager
- type StdioConfig
- type StdioTransport
- type StreamResumption
- type StreamableHTTPConfig
- type StreamableHTTPTransport
- func (t *StreamableHTTPTransport) Close() error
- func (t *StreamableHTTPTransport) GetSessionID() string
- func (t *StreamableHTTPTransport) Receive(ctx context.Context) ([]byte, error)
- func (t *StreamableHTTPTransport) Send(ctx context.Context, message []byte) error
- func (t *StreamableHTTPTransport) SetSessionID(id string) error
- type Transport
Constants ¶
This section is empty.
Variables ¶
var ErrSessionExpired = errors.New("session expired")
ErrSessionExpired indicates the server session has expired (HTTP 404).
Functions ¶
This section is empty.
Types ¶
type HTTPConfig ¶
type HTTPConfig struct {
Endpoint string // HTTP endpoint
Headers map[string]string // Custom headers
SSEPath string // SSE endpoint path (default: /sse)
Logger *zap.Logger // Logger
}
HTTPConfig configures HTTP transport
type HTTPTransport ¶
type HTTPTransport struct {
// contains filtered or unexported fields
}
HTTPTransport implements Transport over HTTP/SSE
func NewHTTPTransport ¶
func NewHTTPTransport(config HTTPConfig) (*HTTPTransport, error)
NewHTTPTransport creates a new HTTP/SSE transport
type ReadWriteCloser ¶
ReadWriteCloser wraps standard I/O interfaces
type SSEParser ¶ added in v1.1.0
type SSEParser struct {
// contains filtered or unexported fields
}
SSEParser parses Server-Sent Events from an HTTP response body.
func NewSSEParser ¶ added in v1.1.0
NewSSEParser creates a new SSE parser.
func (*SSEParser) ParseBatch ¶ added in v1.1.0
ParseBatch reads multiple events until a blank line or EOF. This is useful for batch responses where multiple events are sent together.
func (*SSEParser) ParseEvent ¶ added in v1.1.0
ParseEvent reads and parses the next SSE event from the stream. Returns io.EOF when the stream is closed.
SSE format:
id: <event-id>
event: message
data: {"jsonrpc":"2.0",...}
(blank line terminates event)
type SessionManager ¶ added in v1.1.0
type SessionManager struct {
// contains filtered or unexported fields
}
SessionManager manages MCP session IDs for streamable-http transport. Per the MCP spec, session IDs are globally unique, cryptographically secure, and consist only of visible ASCII characters (0x21 to 0x7E).
func NewSessionManager ¶ added in v1.1.0
func NewSessionManager() *SessionManager
NewSessionManager creates a new session manager.
func (*SessionManager) ClearSession ¶ added in v1.1.0
func (s *SessionManager) ClearSession()
ClearSession clears the session ID (used during re-initialization).
func (*SessionManager) GetSessionID ¶ added in v1.1.0
func (s *SessionManager) GetSessionID() string
GetSessionID returns the current session ID.
func (*SessionManager) HasSession ¶ added in v1.1.0
func (s *SessionManager) HasSession() bool
HasSession returns true if a session ID is set.
func (*SessionManager) SetSessionID ¶ added in v1.1.0
func (s *SessionManager) SetSessionID(id string) error
SetSessionID sets the session ID from the server's Mcp-Session-Id header.
type StdioConfig ¶
type StdioConfig struct {
Command string // Command to execute
Args []string // Command arguments
Env map[string]string // Environment variables
Dir string // Working directory
Logger *zap.Logger // Logger for stderr output
}
StdioConfig configures the stdio transport
type StdioTransport ¶
type StdioTransport struct {
// contains filtered or unexported fields
}
StdioTransport implements Transport over stdin/stdout for subprocess communication
func NewStdioTransport ¶
func NewStdioTransport(config StdioConfig) (*StdioTransport, error)
NewStdioTransport creates a new stdio transport for subprocess communication
func (*StdioTransport) Close ¶
func (s *StdioTransport) Close() error
Close implements Transport by closing pipes and waiting for process
type StreamResumption ¶ added in v1.1.0
type StreamResumption struct {
// contains filtered or unexported fields
}
StreamResumption manages event buffering for stream resumption. Per MCP spec, event IDs are globally unique across all streams in a session, and servers MAY replay messages after a given event ID on the same stream.
func NewStreamResumption ¶ added in v1.1.0
func NewStreamResumption(bufferSize int) *StreamResumption
NewStreamResumption creates a new stream resumption manager.
func (*StreamResumption) AddEvent ¶ added in v1.1.0
func (s *StreamResumption) AddEvent(event SSEEvent)
AddEvent adds an event to the buffer for potential replay.
func (*StreamResumption) Clear ¶ added in v1.1.0
func (s *StreamResumption) Clear()
Clear clears the event buffer and last event ID.
func (*StreamResumption) GetEventsAfter ¶ added in v1.1.0
func (s *StreamResumption) GetEventsAfter(afterEventID string) []SSEEvent
GetEventsAfter retrieves events after a given event ID. Returns nil if no events found or if event ID is not in buffer.
func (*StreamResumption) GetLastEventID ¶ added in v1.1.0
func (s *StreamResumption) GetLastEventID() string
GetLastEventID returns the last received event ID.
func (*StreamResumption) UpdateLastEventID ¶ added in v1.1.0
func (s *StreamResumption) UpdateLastEventID(id string)
UpdateLastEventID updates the last received event ID.
type StreamableHTTPConfig ¶ added in v1.1.0
type StreamableHTTPConfig struct {
Endpoint string // MCP endpoint URL
Headers map[string]string // Custom headers
EnableSessions bool // Enable session management
EnableResumption bool // Enable stream resumption
Logger *zap.Logger // Logger
}
StreamableHTTPConfig configures streamable-http transport.
type StreamableHTTPTransport ¶ added in v1.1.0
type StreamableHTTPTransport struct {
// contains filtered or unexported fields
}
StreamableHTTPTransport implements the MCP streamable-http transport. This is the modern MCP transport (2025-03-26 spec) with session management and stream resumption support.
func NewStreamableHTTPTransport ¶ added in v1.1.0
func NewStreamableHTTPTransport(config StreamableHTTPConfig) (*StreamableHTTPTransport, error)
NewStreamableHTTPTransport creates a new streamable-http transport.
func (*StreamableHTTPTransport) Close ¶ added in v1.1.0
func (t *StreamableHTTPTransport) Close() error
Close implements Transport.
func (*StreamableHTTPTransport) GetSessionID ¶ added in v1.1.0
func (t *StreamableHTTPTransport) GetSessionID() string
GetSessionID returns the current session ID.
func (*StreamableHTTPTransport) Receive ¶ added in v1.1.0
func (t *StreamableHTTPTransport) Receive(ctx context.Context) ([]byte, error)
Receive implements Transport by receiving the next message.
func (*StreamableHTTPTransport) Send ¶ added in v1.1.0
func (t *StreamableHTTPTransport) Send(ctx context.Context, message []byte) error
Send implements Transport by sending a JSON-RPC message via POST.
func (*StreamableHTTPTransport) SetSessionID ¶ added in v1.1.0
func (t *StreamableHTTPTransport) SetSessionID(id string) error
SetSessionID sets the session ID (used after initialization).
type Transport ¶
type Transport interface {
// Send sends a message
Send(ctx context.Context, message []byte) error
// Receive receives the next message (blocking)
Receive(ctx context.Context) ([]byte, error)
// Close closes the transport
Close() error
}
Transport defines the communication layer interface for MCP. Implementations include stdio (subprocess), HTTP/SSE, and WebSocket.