codegen

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: May 6, 2025 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Generate

func Generate(w io.Writer, def *ServerDefinition, pkgName string) error

Generate generates the server code from the server definition. See README.md or examples directory for more details.

Types

type CompletionsCapability

type CompletionsCapability struct{}

CompletionsCapability represents server capability for completions.

type Implementation

type Implementation struct {
	Name    string `json:"name"`
	Version string `json:"version"`
}

Implementation describes the name and version of an MCP implementation.

type LoggingCapability

type LoggingCapability struct{}

LoggingCapability represents server capability for logging.

type Prompt

type Prompt struct {
	// Name is the name of the prompt or prompt template.
	Name string `json:"name"`
	// Description is an optional description of what this prompt provides.
	Description string `json:"description,omitempty"`
	// Arguments is a list of arguments to use for templating the prompt.
	Arguments []PromptArgument `json:"arguments,omitempty"`
}

Prompt represents a prompt or prompt template that the server offers.

type PromptArgument

type PromptArgument struct {
	// Name is the name of the argument.
	Name string `json:"name"`
	// Description is a human-readable description of the argument.
	Description string `json:"description,omitempty"`
	// Required indicates whether this argument must be provided.
	Required bool `json:"required,omitempty"`
}

PromptArgument describes an argument that a prompt can accept.

type PromptCapability

type PromptCapability struct {
}

PromptCapability represents server capability for prompts.

type ResourceCapability

type ResourceCapability struct {
	// Subscribe indicates whether this server supports subscribing to resource updates.
	Subscribe bool `json:"subscribe,omitempty"`
	// ListChanged indicates whether this server supports notifications for changes to the resource list.
	ListChanged bool `json:"listChanged,omitempty"`
}

ResourceCapability represents server capability for resources.

type ResourceTemplate

type ResourceTemplate struct {
	// URITemplate is a URI template (according to RFC 6570) that can be used to construct resource URIs.
	URITemplate string `json:"uriTemplate"`
	// Name is a human-readable name for the type of resource this template refers to.
	// This can be used by clients to populate UI elements.
	Name string `json:"name"`
	// Description is a description of what this template is for.
	// This can be used by clients to improve the LLM's understanding of available resources.
	// It can be thought of like a "hint" to the model.
	Description string `json:"description,omitempty"`
	// MimeType is the MIME type for all resources that match this template. This should only be included
	// if all resources matching this template have the same type.
	MimeType string `json:"mimeType,omitempty"`
}

ResourceTemplate represents a template description for resources available on the server.

type ServerCapabilities

type ServerCapabilities struct {
	// Prompts is present if the server offers any prompt templates.
	Prompts *PromptCapability `json:"prompts,omitempty"`
	// Resources is present if the server offers any resources to read.
	Resources *ResourceCapability `json:"resources,omitempty"`
	// Tools is present if the server offers any tools to call.
	Tools *ToolCapability `json:"tools,omitempty"`
	// Completions is present if the server supports argument autocompletion suggestions.
	Completions *CompletionsCapability `json:"completions,omitempty"`
	// Logging is present if the server supports sending log messages to the client.
	Logging *LoggingCapability `json:"logging,omitempty"`
}

ServerCapabilities represents the capabilities that a server may support.

https://modelcontextprotocol.io/specification/2025-03-26/basic/lifecycle

type ServerDefinition

type ServerDefinition struct {
	// Capabilities defines the capabilities that this server supports.
	Capabilities ServerCapabilities
	// Implementation contains information about this server implementation.
	Implementation Implementation

	// Prompts is the list of prompts offered by this server.
	Prompts []Prompt
	// ResourceTemplates is the list of resource templates offered by this server.
	ResourceTemplates []ResourceTemplate
	// Tools is the list of tools offered by this server.
	Tools []Tool
}

ServerDefinition represents the definition of an MCP server.

type Tool

type Tool struct {
	// Name is the name of the tool.
	Name string `json:"name"`
	// Description is a human-readable description of the tool.
	// This can be used by clients to improve the LLM's understanding of available tools.
	// It can be thought of like a "hint" to the model.
	Description string `json:"description,omitempty"`
	// InputSchema is a Go struct that represents the input schema of the tool.
	// The struct fields can specify JSON tags supported by https://github.com/invopop/jsonschema.
	// See README.md or examples directory for more details.
	InputSchema any `json:"inputSchema"`
}

Tool represents a definition for a tool the client can call.

type ToolCapability

type ToolCapability struct {
}

ToolCapability represents server capability for tools.

Jump to

Keyboard shortcuts

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