calculator

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Handlers = map[string]server.ToolHandlerFunc{
	"add":      HandleAdd,
	"subtract": HandleSubtract,
	"multiply": HandleMultiply,
	"divide":   HandleDivide,
}
View Source
var Tools = []mcp.Tool{
	{
		Name:        "add",
		Description: "Add two numbers",
		InputSchema: mcp.ToolInputSchema{
			Type: "object",
			Properties: map[string]interface{}{
				"a": map[string]interface{}{
					"type":        "number",
					"description": "First number",
				},
				"b": map[string]interface{}{
					"type":        "number",
					"description": "Second number",
				},
			},
		},
	},
	{
		Name:        "subtract",
		Description: "Subtract two numbers",
		InputSchema: mcp.ToolInputSchema{
			Type: "object",
			Properties: map[string]interface{}{
				"a": map[string]interface{}{
					"type":        "number",
					"description": "First number",
				},
				"b": map[string]interface{}{
					"type":        "number",
					"description": "Second number",
				},
			},
		},
	},
	{
		Name:        "multiply",
		Description: "Multiply two numbers",
		InputSchema: mcp.ToolInputSchema{
			Type: "object",
			Properties: map[string]interface{}{
				"a": map[string]interface{}{
					"type":        "number",
					"description": "First number",
				},
				"b": map[string]interface{}{
					"type":        "number",
					"description": "Second number",
				},
			},
		},
	},
	{
		Name:        "divide",
		Description: "Divide two numbers",
		InputSchema: mcp.ToolInputSchema{
			Type: "object",
			Properties: map[string]interface{}{
				"a": map[string]interface{}{
					"type":        "number",
					"description": "First number (dividend)",
				},
				"b": map[string]interface{}{
					"type":        "number",
					"description": "Second number (divisor)",
				},
			},
		},
	},
}

Functions

func HandleAdd added in v0.5.0

func HandleAdd(
	args map[string]interface{},
) (*mcp.CallToolResult, error)

func HandleDivide added in v0.5.0

func HandleDivide(
	args map[string]interface{},
) (*mcp.CallToolResult, error)

func HandleMultiply added in v0.5.0

func HandleMultiply(
	args map[string]interface{},
) (*mcp.CallToolResult, error)

func HandleSubtract added in v0.5.0

func HandleSubtract(
	args map[string]interface{},
) (*mcp.CallToolResult, error)

Types

type CalculationError

type CalculationError struct {
	Message string
}

CalculationError represents an error during calculation

func (CalculationError) Error

func (e CalculationError) Error() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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