Documentation
¶
Overview ¶
Package typegen prepares portable typed MCP clients without a Holon installation.
Index ¶
- Constants
- func AcquireLocks(m Manifest) (func(), error)
- func Check(ctx context.Context, m Manifest, o Options) error
- func Contract(ctx context.Context, manifest Manifest, name string, options Options) (*mcpcontract.Metadata, error)
- func Generate(ctx context.Context, m Manifest, options Options) error
- func InstalledRuntime(root, pkg string) (string, error)
- func LiveContract(ctx context.Context, location string, identity mcpcontract.Identity, ...) (*mcpcontract.Metadata, error)
- type App
- type Client
- type Descriptor
- type HTTPError
- type HolonMetadata
- type Manifest
- type Options
- type Package
- type Prepared
- func (p *Prepared) CheckConfig(app string) (map[string]any, bool)
- func (p *Prepared) CheckPublished(ctx context.Context) error
- func (p *Prepared) Close() error
- func (p *Prepared) Languages(app string) []string
- func (p *Prepared) Metadata() map[string]*mcpcontract.Metadata
- func (p *Prepared) Published(ctx context.Context) (map[string]*mcpcontract.Metadata, error)
- func (p *Prepared) TypeCheck(ctx context.Context) error
- func (p *Prepared) WriteBrowserSlot(app, pkgDir string) error
- func (p *Prepared) WriteGoSlot(app, root string) error
- func (p *Prepared) WriteNodeSlot(app, pkgDir string) error
- func (p *Prepared) WritePythonSlot(app, root string) error
- type Reference
- type RegistrySource
- type Remote
- type Transport
Constants ¶
const MaxDescriptorBytes = 1 << 20
const PublisherMetadata = "io.modelcontextprotocol.registry/publisher-provided"
const RegistryOrigin = "https://registry.modelcontextprotocol.io"
Variables ¶
This section is empty.
Functions ¶
func AcquireLocks ¶
AcquireLocks locks app source directories and installed runtime slots until the returned release function is called. A failure releases every acquired lock.
func Contract ¶
func Contract(ctx context.Context, manifest Manifest, name string, options Options) (*mcpcontract.Metadata, error)
Contract retrieves one provider's contract without resolving its callers or generating clients.
func InstalledRuntime ¶
InstalledRuntime resolves a Node runtime package from root and verifies its generated-slot contract.
func LiveContract ¶
func LiveContract(ctx context.Context, location string, identity mcpcontract.Identity, client *http.Client) (*mcpcontract.Metadata, error)
LiveContract initializes an MCP session and retrieves its advertised schemas. Identity must be supplied by the caller because MCP serverInfo is not a registry identity.
Types ¶
type App ¶
type App struct {
Name string `json:"name"`
Path string `json:"path,omitempty"`
Image string `json:"image,omitempty"`
Registry *RegistrySource `json:"registry,omitempty"`
Remote *Remote `json:"remote,omitempty"`
Mount string `json:"mount,omitempty"`
Port *int `json:"port,omitempty"`
Access json.RawMessage `json:"access,omitempty"`
OAuth json.RawMessage `json:"oauth,omitempty"`
Headers json.RawMessage `json:"headers,omitempty"`
Egress json.RawMessage `json:"egress,omitempty"`
Run json.RawMessage `json:"run,omitempty"`
Arguments json.RawMessage `json:"arguments,omitempty"`
// contains filtered or unexported fields
}
type Descriptor ¶
type Descriptor struct {
Name string `json:"name"`
Version string `json:"version"`
Description string `json:"description"`
Packages []Package `json:"packages"`
Remotes []Transport `json:"remotes"`
Meta map[string]json.RawMessage `json:"_meta"`
Requires map[string]Reference `json:"-"`
Types string `json:"-"`
Raw json.RawMessage `json:"-"`
}
func ParseDescriptor ¶
func ParseDescriptor(data []byte) (*Descriptor, error)
func (*Descriptor) Identity ¶
func (d *Descriptor) Identity() mcpcontract.Identity
type HolonMetadata ¶
type HolonMetadata struct {
Requires map[string]Reference `json:"requires"`
Types string `json:"types,omitempty"`
Egress json.RawMessage `json:"egress,omitempty"`
}
type Manifest ¶
type Manifest struct {
Apps []App `json:"apps"`
// contains filtered or unexported fields
}
func Directories ¶
Directories builds a standalone manifest from server.json files and returns its local app names for Options.Apps. Preparation infers dependencies and filters provider-only directories.
func LoadManifest ¶
LoadManifest resolves app paths relative to the manifest, never the process working directory.
type Options ¶
type Options struct {
Apps []string
Env []string
HTTPClient *http.Client
Stdout, Stderr io.Writer
NoInstall bool
NoPublished bool
// Credential authenticates OCI registry requests ahead of the Docker credential store. A registry
// that rejects a credential it returned (HTTP 401) fails resolution instead of leaving clients untyped.
Credential auth.CredentialFunc
// Extract runs one language's extractor: the runner under toolingDir/<language> reads configPath and
// writes outputPath. It defaults to the host's Node.js or Python interpreter.
Extract func(ctx context.Context, language, toolingDir, configPath, outputPath string) error
// GoModule is the runtime module that generated Go clients import. When set, apps with a server.go
// entrypoint receive a holon/ Go client package for their dependencies; their own contracts are not extracted.
GoModule string
}
type Prepared ¶
type Prepared struct {
Manifest Manifest
// contains filtered or unexported fields
}
Prepared owns temporary source snapshots. Close releases them; preparation never modifies apps.
func Prepare ¶
Prepare snapshots local sources, resolves required contracts and generates portable client files.
func (*Prepared) CheckConfig ¶
CheckConfig is the runner's check configuration ({entry, sources, check}) for app's own language, for a type check inside an image build against the dependencies installed there. Paths are relative to the app directory. It reports false for apps without a runner (Go, unanalysed or unselected apps).
func (*Prepared) CheckPublished ¶
CheckPublished reports selected apps whose extracted contracts break their published contracts or the expectations that other published apps hold of them.
func (*Prepared) Languages ¶
Languages reports the generated client languages for a selected app, in stable order. It returns no languages for an unknown or unprepared app.
func (*Prepared) Metadata ¶
func (p *Prepared) Metadata() map[string]*mcpcontract.Metadata
Metadata returns contracts by manifest app name: extracted ones for path apps, and the resolved image, registry or remote contracts of the dependencies that selected apps require.
func (*Prepared) Published ¶
Published returns the contracts that each selected path app's descriptor last published (sh.holon.types or its OCI package), using Options.Credential; an app without one maps to nil.
func (*Prepared) TypeCheck ¶
TypeCheck type-checks each selected app's snapshot against its freshly generated clients, linked beside the app's installed dependencies. Apps and installed slots are never modified. Go callers are not checked.
func (*Prepared) WriteBrowserSlot ¶
WriteBrowserSlot writes app's browser clients into pkgDir/generated, where pkgDir is an installed holon-ui package or a copy staged for an image. Same refusals as WriteNodeSlot.
func (*Prepared) WriteGoSlot ¶
WriteGoSlot writes app's holon/ Go client package under root. It requires Options.GoModule and replaces only an absent or Holon-marked holon/ directory.
func (*Prepared) WriteNodeSlot ¶
WriteNodeSlot writes app's TypeScript clients and their holon-generated.json marker into pkgDir/generated, where pkgDir is an installed holon-sh package or a copy staged for an image. It refuses slots that are unmarked, symlinked or owned by another app, and leaves an identical slot untouched.
func (*Prepared) WritePythonSlot ¶
WritePythonSlot writes app's holon/apps/__init__.py under root, an application directory or its staged copy. A legacy Holon-managed holon/ package is replaced; user files in the namespace are refused.
type Reference ¶
type Reference struct {
Name string `json:"name"`
Version string `json:"version"`
Registry string `json:"registry,omitempty"`
}
func (Reference) Identity ¶
func (r Reference) Identity() mcpcontract.Identity
func (Reference) RegistryURL ¶
type RegistrySource ¶
type RegistrySource struct {
Reference
Package json.RawMessage `json:"package,omitempty"`
Remote json.RawMessage `json:"remote,omitempty"`
}