mcp

package
v1.2.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 21, 2025 License: MIT Imports: 3 Imported by: 0

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

View Source
const (
	VersionDraft    = "draft"
	Version20241105 = "2024-11-05"
	Version20250326 = "2025-03-26"
)

Known MCP specification versions

Variables

SupportedVersions is a list of all supported MCP specification versions in order of preference (newest first)

Functions

func GetCompatibilityMatrix

func GetCompatibilityMatrix() map[string][]string

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

func NormalizeVersion(version string) string

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

type VersionAdapter struct {
	FromVersion string
	ToVersion   string
}

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

type VersionSupport struct {
	V20241105 bool
	V20250326 bool
	Draft     bool
}

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL