mcp

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package mcp is a minimal Model Context Protocol server over the stdio transport (newline-delimited JSON-RPC 2.0) — enough to expose RunLore tools to MCP clients such as HolmesGPT, kagent, or Claude Desktop. It implements initialize, tools/list, tools/call, and ping; tool handlers return plain text. Deliberately dependency-free (no SDK) to keep the single static binary.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Server

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

Server is a minimal MCP server. Construct with NewServer, AddTool, then Serve.

func NewServer

func NewServer(name, version string, log *slog.Logger) *Server

NewServer creates a server advertising name/version. A nil logger discards logs (logs MUST NOT go to the stdout MCP channel — pass a stderr logger).

func (*Server) AddTool

func (s *Server) AddTool(t Tool)

AddTool registers (or replaces) a tool, preserving first-seen order for tools/list.

func (*Server) Serve

func (s *Server) Serve(ctx context.Context, in io.Reader, out io.Writer) error

Serve reads newline-delimited JSON-RPC requests from in and writes one response line per request to out, until in is exhausted or ctx is cancelled. Notifications (no id) get no response. json.Encoder writes compact, single-line JSON + a newline — exactly the stdio framing MCP expects.

type Tool

type Tool struct {
	Name        string
	Description string
	InputSchema json.RawMessage
	Handler     func(ctx context.Context, args json.RawMessage) (string, error)
}

Tool is an MCP tool: a name, a description, a JSON-Schema for its arguments, and a handler returning text (an error is surfaced to the client as an MCP tool error).

Jump to

Keyboard shortcuts

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