Documentation
¶
Overview ¶
Package mcpopenapi exposes an OpenAPI 3 document as MCP tools over Streamable HTTP, forwarding tools/call to an in-process Upstream handler.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Config ¶
type Config struct {
// Name and Version are advertised in the MCP initialize result.
Name string
Version string
// Instructions is server-wide guidance for clients (keep the first ~512
// characters self-contained for Codex/ChatGPT).
Instructions string
// OpenAPIYAML is an OpenAPI 3.x document (YAML or JSON).
OpenAPIYAML []byte
// Upstream receives reconstructed HTTP requests for each tools/call.
// Paths match the OpenAPI paths (e.g. /api/agent/trips). Auth is the
// caller's responsibility (typically edge Bearer around this handler).
Upstream http.Handler
// PathPrefix, when non-empty, keeps only operations under that path
// prefix (e.g. "/api/agent"). Empty means all operations with an
// operationId except those with explicit empty security.
PathPrefix string
// Audience, when non-empty, filters tools by the operation's audience
// extension (see AudienceKey / IncludeUnannotated).
Audience string
// AudienceKey is the OpenAPI extension key for audiences. Empty means
// "x-audiences".
AudienceKey string
// IncludeUnannotated controls operations that omit the audience
// extension when Audience is set. nil means true (include them).
IncludeUnannotated *bool
}
Config configures the OpenAPI→MCP bridge.
type ParseOptions ¶ added in v0.3.0
type ParseOptions struct {
// PathPrefix, when non-empty, keeps only that path subtree.
PathPrefix string
// Audience, when non-empty, filters by the audience extension on each
// operation (see AudienceKey).
Audience string
// AudienceKey is the OpenAPI extension key listing audiences for an
// operation. Empty means "x-audiences".
AudienceKey string
// IncludeUnannotated controls operations that omit the audience
// extension when Audience is set. nil means true (include them).
// Set to false to keep only operations that explicitly list Audience.
IncludeUnannotated *bool
}
ParseOptions configures OpenAPI→tool schema extraction.
type ToolSchema ¶ added in v0.2.0
ToolSchema is an OpenAPI-derived tool definition usable by MCP or other tool runtimes (e.g. OpenAI function calling).
func ParseToolSchemas ¶ added in v0.2.0
func ParseToolSchemas(openAPIYAML []byte, pathPrefix string) ([]ToolSchema, error)
ParseToolSchemas turns an OpenAPI 3 document into tool schemas (one per operationId). PathPrefix, when non-empty, keeps only that path subtree. Operations with explicit empty security (public) are skipped, matching NewHandler.
func ParseToolSchemasOpts ¶ added in v0.3.0
func ParseToolSchemasOpts(openAPIYAML []byte, opts ParseOptions) ([]ToolSchema, error)
ParseToolSchemasOpts is like ParseToolSchemas with audience filtering.