codegen

package
v0.3.29-beta Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package codegen provides code generation for MCP tools. It generates TypeScript API files from MCP tool definitions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GeneratorStats

type GeneratorStats struct {
	ServerCount int
	ToolCount   int
}

GeneratorStats holds statistics about the code generation

type MCPCodeGenerator

type MCPCodeGenerator struct {
	// contains filtered or unexported fields
}

MCPCodeGenerator generates TypeScript code from MCP tool definitions

func NewMCPCodeGenerator

func NewMCPCodeGenerator(manager *tools.MCPManager, outputDir string) *MCPCodeGenerator

NewMCPCodeGenerator creates a new code generator

func (*MCPCodeGenerator) Generate

func (g *MCPCodeGenerator) Generate(ctx context.Context) error

Generate generates all TypeScript code for MCP tools

func (*MCPCodeGenerator) GetStats

func (g *MCPCodeGenerator) GetStats() GeneratorStats

GetStats returns generation statistics

func (*MCPCodeGenerator) SetServerFilter

func (g *MCPCodeGenerator) SetServerFilter(serverName string)

SetServerFilter sets a filter to only generate code for a specific server

type SchemaData

type SchemaData struct {
	Properties []SchemaProperty
}

SchemaData holds parsed schema information for templates

type SchemaProperty

type SchemaProperty struct {
	Name           string
	TypeScriptType string
	Required       bool
	Description    string
	Default        any
	Enum           []any
	Minimum        *float64
	Maximum        *float64
	MinLength      *int
	MaxLength      *int
	Pattern        string
	Format         string
	// For arrays with object items
	ArrayItemProperties []SchemaProperty
	IsArrayOfObjects    bool
}

SchemaProperty represents a property from a JSON schema with all metadata

type ToolData

type ToolData struct {
	ToolName        string
	MCPToolName     string
	ServerName      string
	Description     string
	InputSchema     *SchemaData
	HasOutputSchema bool
	OutputSchema    *SchemaData
}

ToolData holds template data for generating a tool file

type ToolInfo

type ToolInfo struct {
	FunctionName string
	Description  string
}

ToolInfo holds basic tool information for examples

Jump to

Keyboard shortcuts

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