mcp

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2026 License: MIT Imports: 5 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package mcp implements a minimal MCP (Model Context Protocol) server using JSON-RPC 2.0 over stdio.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type RPCError

type RPCError struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
}

RPCError represents a JSON-RPC 2.0 error.

type Request

type Request struct {
	JSONRPC string          `json:"jsonrpc"`
	ID      json.RawMessage `json:"id,omitempty"`
	Method  string          `json:"method"`
	Params  json.RawMessage `json:"params,omitempty"`
}

Request represents a JSON-RPC 2.0 request.

type Response

type Response struct {
	JSONRPC string          `json:"jsonrpc"`
	ID      json.RawMessage `json:"id"`
	Result  json.RawMessage `json:"result,omitempty"`
	Error   *RPCError       `json:"error,omitempty"`
}

Response represents a JSON-RPC 2.0 response.

type Server

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

Server is a minimal MCP server that dispatches JSON-RPC 2.0 requests over stdio.

func NewServer

func NewServer(name, version string) *Server

NewServer creates a new Server with the given name and version.

func (*Server) CallTool

func (s *Server) CallTool(name string, args json.RawMessage) (any, error)

CallTool invokes a registered tool by name. Returns an error if the tool is unknown.

func (*Server) ListTools

func (s *Server) ListTools() []ToolDef

ListTools returns all registered tool definitions.

func (*Server) RegisterTool

func (s *Server) RegisterTool(def ToolDef, handler ToolHandler)

RegisterTool adds a tool to the server's registry.

func (*Server) Run

func (s *Server) Run(in io.Reader, out io.Writer) error

Run reads JSON-RPC messages line-by-line from in and writes responses to out. It returns when in reaches EOF. The scanner uses a 1 MB buffer to accommodate large requests.

type ToolDef

type ToolDef struct {
	Name        string          `json:"name"`
	Description string          `json:"description"`
	InputSchema json.RawMessage `json:"inputSchema"`
}

ToolDef describes a tool's metadata for the tools/list response.

type ToolHandler

type ToolHandler func(args json.RawMessage) (any, error)

ToolHandler is a function that handles a tool call and returns a result.

Directories

Path Synopsis
Package tools provides MCP tool definitions and HTTP helpers for the triage bot.
Package tools provides MCP tool definitions and HTTP helpers for the triage bot.

Jump to

Keyboard shortcuts

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