toolmetadata

package
v0.12.2 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2026 License: MIT Imports: 1 Imported by: 2

README

Tool Metadata

A standard format for defining MCP tool metadata that can be loaded from any source (TOML, JSON, YAML, database, API, etc.).

Format

The metadata format consists of two main structures:

ToolMetadata
type ToolMetadata struct {
    Description  string           // Tool description
    Keywords     []string         // Keywords for discovery mode
    Parameters   []ToolParameter  // Tool parameters
    Discoverable bool            // Enable discovery mode
}
ToolParameter
type ToolParameter struct {
    Name        string  // Parameter name
    Type        string  // Parameter type: "string", "int", "float", "bool"
    Description string  // Parameter description
    Required    bool    // Whether parameter is required
}

TOML Example

description = "Execute a shell command and return the output"
keywords = ["shell", "command", "execute", "run"]
discoverable = true

[[parameters]]
name = "command"
type = "string"
description = "The shell command to execute"
required = true

[[parameters]]
name = "args"
type = "array:string"
description = "Command arguments"
required = false

[[parameters]]
name = "timeout"
type = "int"
description = "Timeout in seconds (default: 30)"
required = false

Usage Example

package main

import (
    "github.com/paularlott/mcp"
    "github.com/paularlott/mcp/toolmetadata"
    "github.com/BurntSushi/toml"
)

func main() {
    // Parse TOML file
    var meta toolmetadata.ToolMetadata
    if _, err := toml.DecodeFile("execute_command.toml", &meta); err != nil {
        panic(err)
    }

    // Build MCP tool
    tool := toolmetadata.BuildMCPTool("execute_command", &meta)

    // Register with MCP server
    server := mcp.NewServer()
    server.RegisterTool(tool, func(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) {
        // Tool implementation
        return mcp.NewToolResultText("output"), nil
    })
}

JSON Example

{
  "description": "Execute a shell command and return the output",
  "keywords": ["shell", "command", "execute", "run"],
  "discoverable": true,
  "parameters": [
    {
      "name": "command",
      "type": "string",
      "description": "The shell command to execute",
      "required": true
    },
    {
      "name": "timeout",
      "type": "int",
      "description": "Timeout in seconds (default: 30)",
      "required": false
    }
  ]
}

Supported Parameter Types

  • string - String parameter
  • int, integer - Integer/number parameter
  • float, number - Float/number parameter
  • bool, boolean - Boolean parameter
  • array:string - Array of strings
  • array:int, array:integer, array:number, array:float - Array of numbers
  • array:bool, array:boolean - Array of booleans

Unknown types default to string parameters.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildMCPTool

func BuildMCPTool(toolName string, meta *ToolMetadata) *mcp.ToolBuilder

BuildMCPTool creates an mcp.ToolBuilder from ToolMetadata

Types

type ToolMetadata

type ToolMetadata struct {
	Description  string
	Keywords     []string
	Parameters   []ToolParameter
	Discoverable bool
}

ToolMetadata defines metadata for an MCP tool

type ToolParameter

type ToolParameter struct {
	Name        string
	Type        string
	Description string
	Required    bool
}

ToolParameter defines a single parameter for an MCP tool

Jump to

Keyboard shortcuts

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