mcptools

package module
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2025 License: MIT Imports: 17 Imported by: 1

README

MCP (Model Context Protocol) Tools

A list of tools to provide different capabilities to LLMs (Language Model Models). The tools adhere to the Model Context Protocol (MCP) specification to provide a common interface for LLMs to interact with.

{
  name: string;          // Unique identifier for the tool
  description?: string;  // Human-readable description
  inputSchema: {         // JSON Schema for the tool's parameters
    type: "object",
    properties: { ... }  // Tool-specific parameters
  }
}

Here is the definition speicification for the MCP Tools.

Available Tools

Tool Name Description Use-cases
cURL curl_all_in_one A versatile tool for making HTTP requests and interacting with APIs. Fetching data from APIs, web scraping, testing endpoints.
git git_all_in_one A tool for interacting with Git repositories. Managing code repositories, version control, collaboration.
docker docker_all_in_one A tool for managing Docker containers and images. Building, running, and deploying applications in containers.

Contributing

Contributions to this open-source package are welcome! If you'd like to contribute, please start by reviewing the MCP Tools documentation and ensure adherence to the MCP specification. You can contribute by suggesting new tools, reporting bugs, improving existing implementations, or enhancing documentation. To contribute, fork the repository, create a new branch for your changes, and submit a pull request with a detailed description of your contribution. Please follow the project's coding standards and ensure that all changes include appropriate tests and documentation updates. Thank you for supporting this project!

License

This project is licensed under the MIT License - see the LICENSE file for details.

Documentation

Index

Constants

View Source
const (
	GitHubIssuesToolName       = "github_issues"
	GitHubPullRequestsToolName = "github_pull_requests"
	GitHubRepositoryToolName   = "github_repository"
	GitHubSearchToolName       = "github_search"
)
View Source
const CurlToolName = "curl_all_in_one"
View Source
const DockerToolName = "docker_all_in_one"
View Source
const FileSystemToolName = "filesystem_all_in_one"
View Source
const GitToolName = "git_all_in_one"
View Source
const PostgreSQLToolName = "postgresql_all_in_one"

PostgreSQLToolName is the name of the PostgreSQL tool

Variables

View Source
var GetWeather = mcp.Tool{
	Name:        "get_weather",
	Description: "Get the current weather for a given location.",
	InputSchema: json.RawMessage(`{
				"type": "object",
				"properties": {
					"location": {
						"type": "string",
						"description": "The city and state, e.g. San Francisco, CA"
					}
				},
				"required": ["location"]
			}`),
	Handler: func(ctx context.Context, params mcp.CallToolParams) (mcp.CallToolResult, error) {
		_, span := observability.StartSpan(ctx, fmt.Sprintf("%s.Handler", params.Name))
		span.SetAttributes(
			attribute.String("tool_name", params.Name),
			attribute.String("tool_argument", string(params.Arguments)),
		)
		defer span.End()

		var err error
		defer func() {
			if err != nil {
				span.RecordError(err)
			}
		}()

		var input struct {
			Location string `json:"location"`
		}
		if err := json.Unmarshal(params.Arguments, &input); err != nil {
			return mcp.CallToolResult{}, err
		}

		return mcp.CallToolResult{
			Content: []mcp.ToolResultContent{
				{
					Type: "text",
					Text: fmt.Sprintf("Weather in %s: Sunny, 72°F", input.Location),
				},
			},
		}, nil
	},
}

GetWeather is a tool that provides the current weather for a specified location. The tool expects an input schema that includes a "location" field, which specifies the city and state (e.g., "San Francisco, CA"). It returns the weather information as text content.

Functions

This section is empty.

Types

type CommandExecutor

type CommandExecutor interface {
	ExecuteCommand(ctx context.Context, cmd *exec.Cmd) ([]byte, error)
}

CommandExecutor interface for executing commands

type Curl

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

Curl represents a wrapper around the system's curl command-line tool, providing a programmatic interface for making HTTP requests.

func NewCurl

func NewCurl(logger observability.Logger, config CurlConfig) *Curl

NewCurl creates and returns a new instance of the Curl wrapper with the provided configuration.

func (*Curl) CurlAllInOneTool

func (c *Curl) CurlAllInOneTool() mcp.Tool

CurlAllInOneTool returns a mcp.Tool that can perform various HTTP requests

type CurlConfig

type CurlConfig struct {
	BlockedMethods []string
}

CurlConfig holds the configuration for the Curl tool

type DBConnection

type DBConnection struct {
	Host     string
	Port     string
	User     string
	Password string
	DBName   string
	SSLMode  string
}

DBConnection represents a PostgreSQL database connection configuration

type Docker

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

Docker represents a wrapper around the system's docker command-line tool

func NewDocker

func NewDocker(logger observability.Logger) *Docker

NewDocker creates and returns a new instance of the Docker wrapper

func (*Docker) DockerAllInOneTool

func (d *Docker) DockerAllInOneTool() mcp.Tool

DockerAllInOneTool returns a mcp.Tool that can execute Docker commands

type DockerConfig

type DockerConfig struct {
}

DockerConfig holds the configuration for the Docker tool

type FileSystem

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

FileSystem represents a wrapper around filesystem operations

func NewFileSystem

func NewFileSystem(logger observability.Logger, config FileSystemConfig) *FileSystem

NewFileSystem creates a new instance of FileSystem

func (*FileSystem) FileSystemAllInOneTool

func (fs *FileSystem) FileSystemAllInOneTool() mcp.Tool

FileSystemAllInOneTool returns a Tool that performs filesystem operations

type FileSystemConfig

type FileSystemConfig struct {
	AllowedDirectory string   // Base directory for all operations
	BlockedPatterns  []string // Patterns to block (e.g., "*.exe", "*.dll")
}

FileSystemConfig holds the configuration for the FileSystem tool

type Git

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

Git represents a wrapper around the system's git command-line tool, providing a programmatic interface for executing git commands.

func NewGit

func NewGit(logger observability.Logger, config GitConfig) *Git

NewGit creates and returns a new instance of the Git wrapper with the provided configuration.

func (*Git) GitAllInOneTool

func (g *Git) GitAllInOneTool() mcp.Tool

GitAllInOneTool returns a mcp.Tool that can perform various Git operations

type GitConfig

type GitConfig struct {
	// Add any configuration options here
	// For example, you might want to add:
	DefaultRepoPath string
	BlockedCommands []string
}

GitConfig holds the configuration for the Git tool

type GitHub

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

GitHub represents a wrapper around GitHub API client

func NewGitHubTool

func NewGitHubTool(logger observability.Logger, config GitHubConfig) *GitHub

NewGitHubTool to perform operations on GitHub

func (*GitHub) GetIssuesTool

func (g *GitHub) GetIssuesTool() mcp.Tool

GetIssuesTool returns a tool for managing GitHub issues

func (*GitHub) GetPullRequestsTool

func (g *GitHub) GetPullRequestsTool() mcp.Tool

GetPullRequestsTool returns a tool for managing GitHub pull requests

func (*GitHub) GetRepositoryTool

func (g *GitHub) GetRepositoryTool() mcp.Tool

GetRepositoryTool returns a tool for managing GitHub repositories

func (*GitHub) GetSearchTool

func (g *GitHub) GetSearchTool() mcp.Tool

GetSearchTool returns a tool for GitHub search operations

type GitHubConfig

type GitHubConfig struct {
	Token string
}

type MockLogger

type MockLogger struct {
	mock.Mock
}

MockLogger is a mock implementation of observability.Logger

func (*MockLogger) Debug

func (m *MockLogger) Debug(args ...interface{})

Debug logs a debug message.

func (*MockLogger) Debugf

func (m *MockLogger) Debugf(format string, args ...interface{})

Debugf logs a formatted debug message.

func (*MockLogger) Error

func (m *MockLogger) Error(args ...interface{})

Error logs an error message.

func (*MockLogger) Errorf

func (m *MockLogger) Errorf(format string, args ...interface{})

Errorf logs a formatted error message.

func (*MockLogger) Fatal

func (m *MockLogger) Fatal(args ...interface{})

Fatal logs a fatal message.

func (*MockLogger) Fatalf

func (m *MockLogger) Fatalf(format string, args ...interface{})

Fatalf logs a formatted fatal message.

func (*MockLogger) Info

func (m *MockLogger) Info(args ...interface{})

Info logs an info message.

func (*MockLogger) Infof

func (m *MockLogger) Infof(format string, args ...interface{})

Infof logs a formatted info message.

func (*MockLogger) Panic

func (m *MockLogger) Panic(args ...interface{})

Panic logs a panic message.

func (*MockLogger) Panicf

func (m *MockLogger) Panicf(format string, args ...interface{})

Panicf logs a formatted panic message.

func (*MockLogger) Warn

func (m *MockLogger) Warn(args ...interface{})

Warn logs a warning message.

func (*MockLogger) Warnf

func (m *MockLogger) Warnf(format string, args ...interface{})

Warnf logs a formatted warning message.

func (*MockLogger) WithContext

func (m *MockLogger) WithContext(ctx context.Context) observability.Logger

WithContext adds a context to the logger and returns a new logger instance.

func (*MockLogger) WithErr

func (m *MockLogger) WithErr(err error) observability.Logger

WithErr adds an error to the logger and returns a new logger instance.

func (*MockLogger) WithFields

func (m *MockLogger) WithFields(fields map[string]interface{}) observability.Logger

WithFields adds fields to the logger and returns a new logger instance.

type PostgreSQL

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

PostgreSQL represents a tool for performing PostgreSQL operations

func NewPostgreSQL

func NewPostgreSQL(logger observability.Logger, config PostgreSQLConfig) *PostgreSQL

NewPostgreSQL creates a new PostgreSQL tool with the given logger and configuration

func (*PostgreSQL) PostgreSQLAllInOneTool

func (p *PostgreSQL) PostgreSQLAllInOneTool() mcp.Tool

PostgreSQLAllInOneTool remains mostly the same, but uses getConnection instead

type PostgreSQLConfig

type PostgreSQLConfig struct {
	DefaultDatabase string
	BlockedCommands []string
}

PostgreSQLConfig represents the configuration for the PostgreSQL tool

type RealCommandExecutor

type RealCommandExecutor struct{}

RealCommandExecutor implements CommandExecutor for real command execution

func (*RealCommandExecutor) ExecuteCommand

func (e *RealCommandExecutor) ExecuteCommand(_ context.Context, cmd *exec.Cmd) ([]byte, error)

Jump to

Keyboard shortcuts

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