mcptype

package
v0.0.1-dev.20 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2026 License: Apache-2.0 Imports: 17 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package mcptype compares MCP typed contracts and generates typed client packages.

Index

Constants

View Source
const TypeScriptModule = "index.mjs"

TypeScriptModule is the generated clients' module, beside its declarations in index.d.mts. Its .mjs keeps it an ES module in a CommonJS project.

Variables

This section is empty.

Functions

func Generate

func Generate(ctx context.Context, options GenerateRequest) (map[string][]byte, error)

Generate returns the generated sources by relative path.

func SameContract

func SameContract(ctx context.Context, a, b *mcpcontract.Contract) (bool, error)

SameContract reports whether two contracts are equal once annotations are removed and unordered keywords sorted.

func ValidateMetadata

func ValidateMetadata(ctx context.Context, data []byte) error

ValidateMetadata reports why data is not a contract document, or nil when it is one.

Types

type Change

type Change struct {
	Kind string
	Name string
	Text string
}

Change is one way a published contract breaks an expectation. Name is the tool name or resource URI, if any.

func Changes

func Changes(ctx context.Context, expected *mcpcontract.Metadata, published *mcpcontract.Metadata) ([]Change, error)

Changes lists what breaks expected if published is deployed. Empty means compatible.

type GenerateRequest

type GenerateRequest struct {
	Target    string                           `json:"target"`
	Identity  mcpcontract.Identity             `json:"identity"`
	Requires  map[string]mcpcontract.Identity  `json:"requires,omitempty"`
	Contracts map[string]*mcpcontract.Contract `json:"contracts,omitempty"`
	Own       string                           `json:"own,omitempty"`
	// Banner is the first-line comment on generated sources.
	Banner   string `json:"banner,omitempty"`
	GoModule string `json:"go_module,omitempty"`
}

GenerateRequest asks for one target's typed client package: node, browser, python or go. Empty optional strings use their defaults; GoModule is required for Go.

type Number

type Number struct {
	// contains filtered or unexported fields
}

Number keeps serde_json's three representations apart: 1 and 1.0 are different values.

func (Number) MarshalJSON

func (n Number) MarshalJSON() ([]byte, error)

MarshalJSON preserves the number representation used for schema comparison.

func (Number) String

func (n Number) String() string

String formats the number without losing integer precision or the integer/float distinction.

type Object

type Object map[string]Value

Object is a JSON object.

type Value

type Value = any

Value is a JSON value: nil, bool, Number, string, []Value or Object. Objects are unordered and serialize with sorted keys.

Jump to

Keyboard shortcuts

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