domain

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2025 License: MIT Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APISchema

type APISchema struct {
	// Source indicates the origin of the schema (e.g., URL, file path, gRPC reflection endpoint).
	Source string
	// Type specifies the kind of schema (OpenAPI, gRPC, etc.).
	Type SchemaType
	// RawData holds the unprocessed schema content.
	// For OpenAPI, this could be []byte of JSON/YAML.
	// For gRPC, this might be less relevant if reflection data is processed directly,
	// but could hold service/method names or file descriptors.
	RawData []byte
	// ParsedData holds the schema parsed into a library-specific representation.
	// This avoids reparsing in later stages. The actual type depends on the SchemaType.
	// Example: *openapi3.T for OpenAPI. Use interface{} to keep domain clean,
	// but requires type assertions downstream.
	ParsedData interface{}
}

APISchema represents a fetched API schema before conversion. It holds the raw data and metadata about its origin and type.

type JSONSchemaProps

type JSONSchemaProps struct {
	Type       string                     `json:"type"`                 // e.g., "object", "string", "number", "integer", "boolean", "array"
	Properties map[string]JSONSchemaProps `json:"properties,omitempty"` // For type "object"
	Required   []string                   `json:"required,omitempty"`   // For type "object"
	Items      *JSONSchemaProps           `json:"items,omitempty"`      // For type "array"
	Format     string                     `json:"format,omitempty"`     // e.g., "date-time", "email"
	Enum       []interface{}              `json:"enum,omitempty"`       // Possible values

}

JSONSchemaProps represents the properties of a JSON schema, commonly used for input and output definitions in MCP tools. This is a simplified version; a more complete implementation might import a dedicated JSON schema library or use map[string]interface{}.

type SchemaType

type SchemaType string

SchemaType defines the type of the source API schema.

const (
	SchemaTypeOpenAPI      SchemaType = "openapi"
	SchemaTypeGRPC         SchemaType = "grpc"
	SchemaTypeGitHub       SchemaType = "github"       // GitHub-hosted OpenAPI schemas
	SchemaTypeProto        SchemaType = "proto"        // .proto files
	SchemaTypeConnect      SchemaType = "connect"      // Connect-RPC (HTTP mode)
	SchemaTypeConnectProto SchemaType = "connectproto" // Connect-RPC with .proto file

)

type Tool

type Tool struct {
	// Name follows the pattern "{namespace}-{verb}-{resource}" or "{namespace}-{action}".
	// It MUST be unique within the MCP server.
	Name string `json:"name"`

	// Description provides a natural language explanation of what the tool does.
	// This is crucial for the LLM to understand when to use the tool.
	Description string `json:"description"`

	// InputSchema defines the structure of the data the tool expects.
	// Uses JSON Schema format.
	InputSchema JSONSchemaProps `json:"input_schema"`

	// OutputSchema defines the structure of the data the tool returns upon successful invocation.
	// Optional. If omitted, the output is considered opaque or unstructured.
	// Uses JSON Schema format.
	OutputSchema *JSONSchemaProps `json:"output_schema,omitempty"`
}

Tool represents a callable function derived from an API schema, compliant with the Model Context Protocol (MCP). Based on MCP Spec 2025-03-26: https://modelcontextprotocol.io/specification/2025-03-26

Jump to

Keyboard shortcuts

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