mcptools

package module
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2025 License: MIT Imports: 20 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.

Note: If you want to see the tools in action, you can use the MCP Kit project.

{
  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 A versatile tool for making HTTP requests and interacting with APIs. Fetching data from APIs, web scraping, testing endpoints.
git git A tool for interacting with Git repositories. Managing code repositories, version control, collaboration.
docker docker A tool for managing Docker containers and images. Building, running, and deploying applications in containers.
github github_issues Manages GitHub issues - create, list, update, comment on issues. Managing GitHub issues. Required GITHUB_TOKEN environment variable
github github_pull_requests Manages GitHub pull requests - create, review, merge. Managing GitHub pull requests. Required GITHUB_TOKEN environment variable
github github_repository Manages GitHub repositories - create, delete, update, fork. Repository management. Required GITHUB_TOKEN environment variable
github github_search Performs GitHub search operations across repositories, code, issues, and users. Advanced GitHub searches. Required GITHUB_TOKEN environment variable
gmail gmail Gmail operation to execute (list, send, read, delete). Managing Gmail operations

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 BashToolName = "bash"
View Source
const CatToolName = "cat"
View Source
const CurlToolName = "curl"
View Source
const DockerToolName = "docker"
View Source
const FileSystemToolName = "filesystem"
View Source
const GitToolName = "git"
View Source
const (
	GmailToolName = "gmail"
)
View Source
const GrepToolName = "grep"
View Source
const PostgreSQLToolName = "postgresql"

PostgreSQLToolName is the name of the PostgreSQL tool

View Source
const SedToolName = "sed"

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 Bash added in v0.0.5

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

Bash represents a wrapper around the system's bash command-line tool

func NewBash added in v0.0.5

func NewBash(logger observability.Logger) *Bash

NewBash creates a new instance of the Bash wrapper

func (*Bash) BashAllInOneTool added in v0.0.5

func (b *Bash) BashAllInOneTool() mcp.Tool

BashAllInOneTool returns a mcp.Tool that can execute bash commands

type Cat added in v0.0.5

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

Cat represents a wrapper around the system's cat command-line tool

func NewCat added in v0.0.5

func NewCat(logger observability.Logger) *Cat

NewCat creates a new instance of the Cat wrapper

func (*Cat) CatAllInOneTool added in v0.0.5

func (c *Cat) CatAllInOneTool() mcp.Tool

CatAllInOneTool returns a mcp.Tool that can execute cat commands

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 EmailMessage added in v0.0.3

type EmailMessage struct {
	ID      string `json:"id"`
	From    string `json:"from"`
	Subject string `json:"subject"`
	Snippet string `json:"snippet"`
	Date    string `json:"date"`
}

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 Gmail added in v0.0.3

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

Gmail represents a wrapper around the Gmail API service, providing a programmatic interface for executing Gmail operations.

func NewGmail added in v0.0.3

func NewGmail(logger observability.Logger, service *gmail.Service, config GmailConfig) *Gmail

NewGmail creates and returns a new instance of the Gmail wrapper with the provided configuration.

func (*Gmail) GmailAllInOneTool added in v0.0.3

func (g *Gmail) GmailAllInOneTool() mcp.Tool

GmailAllInOneTool returns a mcp.Tool that can perform various Gmail operations

type GmailConfig added in v0.0.3

type GmailConfig struct {
	UserID         string
	MaxResults     int64
	SinceLastNDays int
}

GmailConfig holds the configuration for the Gmail tool

type Grep added in v0.0.5

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

Grep represents a wrapper around the system's grep command-line tool

func NewGrep added in v0.0.5

func NewGrep(logger observability.Logger) *Grep

NewGrep creates and returns a new instance of the Grep wrapper

func (*Grep) GrepAllInOneTool added in v0.0.5

func (g *Grep) GrepAllInOneTool() mcp.Tool

GrepAllInOneTool returns a mcp.Tool that can execute grep commands

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)

type Sed added in v0.0.5

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

Sed represents a wrapper around the system's sed command-line tool

func NewSed added in v0.0.5

func NewSed(logger observability.Logger) *Sed

NewSed creates a new instance of the Sed wrapper

func (*Sed) SedAllInOneTool added in v0.0.5

func (s *Sed) SedAllInOneTool() mcp.Tool

SedAllInOneTool returns a mcp.Tool that can execute sed commands SedAllInOneTool returns a mcp.Tool that can execute sed commands

Jump to

Keyboard shortcuts

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