Documentation
¶
Overview ¶
Package om serves an API as an MCP server, one tool per operation. Compile turns an OpenAPI document into a Document: a model a host stores as JSON and serves with Document.Handler.
This package is the whole public surface for compiling and serving. A host never sees an operation's protocol.
Index ¶
- type Authorization
- type Compiled
- type Document
- func (d Document) Handler(lookup func(ctx context.Context, name string) (string, bool), ...) (http.Handler, error)
- func (d Document) Implementation() (*mcp.Implementation, *mcp.ServerOptions, error)
- func (d Document) MarshalJSON() ([]byte, error)
- func (d Document) Tool(name string) (*mcp.Tool, error)
- func (d Document) Tools(cursor string) (*mcp.ListToolsResult, error)
- func (d *Document) UnmarshalJSON(data []byte) error
- type Input
- type Omission
- type OpenAPI
- type Source
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Authorization ¶ added in v0.0.6
type Authorization = core.Authorization
Authorization is the RFC 8414 §2 issuer of the authorization server that issues an access token and the scopes the operations that send it require.
type Compiled ¶ added in v0.0.13
type Compiled struct {
// Document is the model a host stores and serves.
Document Document
// Omitted are the operations Document leaves out, each with its reason: first those the protocol cannot compile,
// then those the rules every protocol shares leave out, each in source order.
Omitted []Omission
}
Compiled is what one source compiles to.
func Compile ¶ added in v0.0.13
Compile turns source into a Document and the operations it left out. Every protocol ends in the same rules: an operation is left out when its name is not an MCP tool name or is taken, when its schemas do not compile, or when an input it needs takes the name of an input from elsewhere in the source; operations and inputs are sorted by name; and only the definitions kept tools reach are stored. It fails when no operation is left.
type Document ¶ added in v0.0.3
type Document struct {
Title string
Version string
Description string
// Server is the URL every operation is sent to. Its {name} variables are filled from the Inputs that have a
// Default. A host may replace it with another URL template of the same API; holon replaces it with the app's URL.
Server string
Inputs []Input
// contains filtered or unexported fields
}
Document is a compiled API: its identity, its server, the inputs a host supplies, and its tools, each with the way its protocol reaches the API. Its JSON encoding is the model a host stores between compiling and serving.
A Document is servable when Compile made it, or when it decoded from a model of a protocol and format this version of om serves. Any other Document, including the zero one, decodes without error and is refused by every method, so a host reports one refusal, from Document.Implementation, wherever it asks.
func (Document) Handler ¶ added in v0.0.3
func (d Document) Handler(lookup func(ctx context.Context, name string) (string, bool), transport http.RoundTripper) (http.Handler, error)
Handler serves the document's operations as MCP 2026-07-28 tools over Streamable HTTP, statelessly. lookup supplies an input's value by name; transport carries the upstream requests. It refuses a model it cannot serve with an error, never a panic.
func (Document) Implementation ¶ added in v0.0.7
func (d Document) Implementation() (*mcp.Implementation, *mcp.ServerOptions, error)
Implementation is the MCP server om serves the document as and the options it serves it with. It refuses a model of a protocol or format this version of om does not serve.
func (Document) MarshalJSON ¶ added in v0.0.13
MarshalJSON writes the model: the protocol's key with its format first, then the shared fields, then the operations in the protocol's own shape. The same Document always encodes to the same bytes, so a host may store it by digest.
func (Document) Tool ¶ added in v0.0.10
Tool is the tool named name, standalone, as tools/list shows it, with its schemas as json.RawMessage. It is nil when the document has no such tool.
func (Document) Tools ¶ added in v0.0.7
func (d Document) Tools(cursor string) (*mcp.ListToolsResult, error)
Tools is the page of tools a tools/list cursor names: as many standalone tools as fit in 256 KiB of names, descriptions and schemas, and at least one. Its cacheScope is public, since a model's tools do not depend on who asks. A cursor Tools did not issue is invalid params.
func (*Document) UnmarshalJSON ¶ added in v0.0.13
UnmarshalJSON reads a model. A model of a protocol or format this version of om does not serve decodes without its operations, whose shape it cannot know, and every method then refuses it. A model of a format it serves decodes strictly: an operation it cannot send, such as one with an unknown credential, fails the decode.
type Input ¶
Input is a value the host supplies by name: a server variable when it has a default, a credential when it has none. A credential with Authorization is an OAuth 2.0 access token, which operations send as an RFC 6750 §2.1 bearer token.
type Omission ¶
Omission is an operation a Document leaves out, and why. Its String is "<operation>: <reason>", where the operation is "GET /widgets" for OpenAPI.
type OpenAPI ¶ added in v0.0.13
type OpenAPI struct {
// Data is the document, as JSON or YAML.
Data []byte
// Location is where Data came from, which resolves a relative server URL. It is nil when unknown.
Location *url.URL
}
OpenAPI is an OpenAPI 3.0, 3.1 or 3.2 document. Its first server is the Document's server, and its security schemes are the credentials each operation sends.
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
om
command
|
|
|
Package discover finds the OpenAPI descriptions an API publishes, from an HTTPS URL.
|
Package discover finds the OpenAPI descriptions an API publishes, from an HTTPS URL. |
|
internal
|
|
|
core
Package core is what every protocol om serves shares: the MCP tool catalog, the JSON Schema definitions tools share, the inputs a host supplies, credentials, the limits on each upstream exchange, and the MCP server itself.
|
Package core is what every protocol om serves shares: the MCP tool catalog, the JSON Schema definitions tools share, the inputs a host supplies, credentials, the limits on each upstream exchange, and the MCP server itself. |
|
openapi
Package openapi is om's OpenAPI protocol: it compiles an OpenAPI 3.0–3.2 document into a core.Draft of operations, and each operation sends itself as an HTTP request with parameters serialized in the styles OpenAPI defines.
|
Package openapi is om's OpenAPI protocol: it compiles an OpenAPI 3.0–3.2 document into a core.Draft of operations, and each operation sends itself as an HTTP request with parameters serialized in the styles OpenAPI defines. |