Documentation
¶
Overview ¶
Package mcp contains the core types and interfaces for the Model Context Protocol.
This package defines the fundamental types used across all MCP specification versions and provides utilities for working with them.
Index ¶
- Constants
- Variables
- func GetCompatibilityMatrix() map[string][]string
- func GetSupportedVersions() []string
- func NormalizeVersion(version string) string
- type SpecVersion
- type VersionAdapter
- type VersionDetector
- func (d *VersionDetector) DetectVersion(message []byte) (string, error)
- func (d *VersionDetector) GetVersionAdapter(fromVersion, toVersion string) (interface{}, error)
- func (d *VersionDetector) IsVersionCompatible(v1, v2 string) bool
- func (d *VersionDetector) NegotiateVersion(clientVersions []string, serverVersions []string) (string, error)
- func (d *VersionDetector) ValidateVersion(version string) (string, error)
- type VersionSupport
Constants ¶
const ( VersionDraft = "draft" Version20241105 = "2024-11-05" Version20250326 = "2025-03-26" )
Known MCP specification versions
Variables ¶
var SupportedVersions = []string{ VersionDraft, Version20250326, Version20241105, }
SupportedVersions is a list of all supported MCP specification versions in order of preference (newest first)
Functions ¶
func GetCompatibilityMatrix ¶
GetCompatibilityMatrix returns a map showing which versions are compatible with each other
func GetSupportedVersions ¶
func GetSupportedVersions() []string
GetSupportedVersions returns a list of all versions supported by this library
func NormalizeVersion ¶
NormalizeVersion normalizes a version string for comparison
Types ¶
type SpecVersion ¶
type SpecVersion string
SpecVersion represents an MCP specification version
const ( SpecVersion20241105 SpecVersion = "2024-11-05" SpecVersion20250326 SpecVersion = "2025-03-26" SpecVersionDraft SpecVersion = "draft" )
Supported MCP specification versions
type VersionAdapter ¶
VersionAdapter is a placeholder for future version adaptation functionality
func (*VersionAdapter) AdaptMessage ¶
func (a *VersionAdapter) AdaptMessage(message []byte) ([]byte, error)
AdaptMessage is a placeholder for adapting a message from one version to another
type VersionDetector ¶
type VersionDetector struct {
DefaultVersion string // Default version to use when none is specified
Supported []string // Supported versions in order of preference (newest first)
}
VersionDetector detects and negotiates MCP versions
func NewVersionDetector ¶
func NewVersionDetector() *VersionDetector
NewVersionDetector creates a new version detector with default settings
func (*VersionDetector) DetectVersion ¶
func (d *VersionDetector) DetectVersion(message []byte) (string, error)
DetectVersion determines the appropriate MCP version based on a message
func (*VersionDetector) GetVersionAdapter ¶
func (d *VersionDetector) GetVersionAdapter(fromVersion, toVersion string) (interface{}, error)
GetVersionAdapter returns an adapter for converting between versions This is a placeholder for future version adaptation functionality
func (*VersionDetector) IsVersionCompatible ¶
func (d *VersionDetector) IsVersionCompatible(v1, v2 string) bool
IsVersionCompatible checks if two versions are compatible
func (*VersionDetector) NegotiateVersion ¶
func (d *VersionDetector) NegotiateVersion(clientVersions []string, serverVersions []string) (string, error)
NegotiateVersion handles version negotiation between client and server
func (*VersionDetector) ValidateVersion ¶
func (d *VersionDetector) ValidateVersion(version string) (string, error)
ValidateVersion checks if a version is supported and returns a normalized version string
type VersionSupport ¶
VersionSupport represents which MCP specification versions are supported
func AllVersions ¶
func AllVersions() VersionSupport
AllVersions returns a VersionSupport with all versions enabled
Directories
¶
| Path | Synopsis |
|---|---|
|
Package draft implements the latest draft version of the MCP specification.
|
Package draft implements the latest draft version of the MCP specification. |
|
Package v20241105 implements the 2024-11-05 version of the MCP specification.
|
Package v20241105 implements the 2024-11-05 version of the MCP specification. |
|
Package v20250326 implements the 2025-03-26 version of the MCP specification.
|
Package v20250326 implements the 2025-03-26 version of the MCP specification. |