api

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package api implements the MCP (Model Context Protocol) server functionality.

It provides a Service that registers and handles MCP tools for code generation rule management. The package uses stdio transport for MCP communication and supports concurrent operations through error groups. Each tool is registered with debug logging for request tracking.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CodeStyleArgs

type CodeStyleArgs struct {
	// Categories for filtering rules
	Categories string `` /* 163-byte string literal not displayed */
}

CategoryArgs holds the category parameter for rule filtering. Used to specify the category of code generation rules to retrieve.

type Config

type Config struct {
}

Config holds the service configuration parameters. Currently empty but maintained for future configuration options.

type MockToolHandler

type MockToolHandler struct {
	mock.Mock
}

MockToolHandler is an autogenerated mock type for the ToolHandler type

func NewMockToolHandler

func NewMockToolHandler(t interface {
	mock.TestingT
	Cleanup(func())
}) *MockToolHandler

NewMockToolHandler creates a new instance of MockToolHandler. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.

func (*MockToolHandler) EXPECT

func (*MockToolHandler) GetCodeStyle

func (_m *MockToolHandler) GetCodeStyle(ctx context.Context, categories []string) ([]core.Rule, error)

GetCodeStyle provides a mock function with given fields: ctx, categories

type MockToolHandler_Expecter

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

func (*MockToolHandler_Expecter) GetCodeStyle

func (_e *MockToolHandler_Expecter) GetCodeStyle(ctx interface{}, categories interface{}) *MockToolHandler_GetCodeStyle_Call

GetCodeStyle is a helper method to define mock.On call

  • ctx context.Context
  • categories []string

type MockToolHandler_GetCodeStyle_Call

type MockToolHandler_GetCodeStyle_Call struct {
	*mock.Call
}

MockToolHandler_GetCodeStyle_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetCodeStyle'

func (*MockToolHandler_GetCodeStyle_Call) Return

func (*MockToolHandler_GetCodeStyle_Call) Run

func (*MockToolHandler_GetCodeStyle_Call) RunAndReturn

type Service

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

Service implements the MCP server functionality for code generation rules. It registers tools for rule management and handles their execution through the provided ToolHandler. The service is safe for concurrent use.

func New

func New(cfg *Config, handler ToolHandler) *Service

New creates a new Service instance with the provided configuration and handler. The handler must be properly initialized and safe for concurrent use.

func (*Service) Run

func (s *Service) Run(ctx context.Context) error

Run starts the MCP server and begins handling tool requests. It sets up all available tools and starts the server with stdio transport. The server runs until the context is cancelled or an error occurs. Returns error if tool setup fails or server encounters an error.

type ToolHandler

type ToolHandler interface {
	GetCodeStyle(ctx context.Context, categories []string) ([]core.Rule, error)
}

ToolHandler defines the interface for handling code generation rule operations. Implementations must be safe for concurrent use as methods may be called simultaneously by different MCP tool handlers.

Jump to

Keyboard shortcuts

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