Documentation
¶
Overview ¶
Package mcptype compares MCP typed contracts and generates typed client packages. It is a Go port of the mcptype compiler (hughhan1/mcptype 0.0.6) and produces the same bytes: canonical forms, digests, change texts and package files.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type CanonicalForm ¶
type CanonicalForm struct {
Canonical json.RawMessage `json:"canonical"`
Digest string `json:"digest"`
}
CanonicalForm is a document with annotations removed and unordered keywords sorted. Both fields are empty for metadata without a contract.
type Change ¶
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.Expectation, published *mcpcontract.Metadata) ([]Change, error)
Changes lists what breaks expected if published is deployed. Empty means compatible.
type Contract ¶
Contract holds tools keyed by name and resources keyed by URI. The wire format is v1's arrays, written in key order.
type Expectation ¶
Expectation is the contract a caller was built against.
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"`
Runtime map[string][]byte `json:"runtime,omitempty"`
Protocol string `json:"protocol,omitempty"`
PackageFields map[string]any `json:"package_fields,omitempty"`
RuntimeSpecifier string `json:"runtime_specifier,omitempty"`
BrowserRuntimeSpecifier string `json:"browser_runtime_specifier,omitempty"`
ProtocolSpecifier string `json:"protocol_specifier,omitempty"`
PythonModule string `json:"python_module,omitempty"`
PythonRuntimeModule string `json:"python_runtime_module,omitempty"`
Banner string `json:"banner,omitempty"`
GoModule string `json:"go_module,omitempty"`
// Entry names the TypeScript entry point files: "index" gives index.js, index.d.ts and resources.d.ts.
// Empty means index for node and browser for browser.
Entry string `json:"entry,omitempty"`
// Own, for browser targets, is the contracts key of the app's own server. The module then exports
// App: the ext-apps App with that server's tools and resources typed, called through the host.
Own string `json:"own,omitempty"`
}
GenerateRequest asks for one target's typed client package: node, browser, python or go. Runtime files are copied into the package verbatim.
type Metadata ¶
type Metadata struct {
Version uint32
Identity Identity
Contract *Contract
Requires map[string]Expectation
}
Metadata is the document an image publishes.
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.