mcp

package
v1.10.2 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package mcp implements a Model Context Protocol server over stdio.

This is a thin adapter over github.com/BackendStack21/go-mcp, which provides the core MCP protocol implementation. This package converts odek's tool interface to go-mcp's Tool type and manages transport.

Architecture:

MCP Client (Claude Code)       odek mcp (this package → go-mcp)
┌─────────────────────┐        ┌─────────────────────────────────┐
│  tools/list ─────────────►  │  go-mcp dispatches to handlers  │
│                     │        │                                 │
│  tools/call ─────────────►  │  go-mcp calls Tool.Handler      │
│                     │        │                                 │
│  ◄────── result ────│        │                                 │
└─────────────────────┘        └─────────────────────────────────┘
       stdin/stdout                   stdin/stdout

Security: uses the same DangerousConfig + Approver system as CLI mode. In MCP mode there's no TTY — the NonInteractiveAction fallback applies.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type NativeTool

type NativeTool struct {
	Name        string
	Description string
	Schema      any
	CallFn      func(args string) (string, error)
}

NativeTool wraps a odek Tool interface for MCP exposure.

func BuildNativeTools

func BuildNativeTools(callers []ToolCaller) []NativeTool

BuildNativeTools wraps a slice of odek.Tool-compatible values as MCP NativeTool entries for the server. Skips tools that don't make sense in MCP context (delegate_tasks, memory).

type Server

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

Server implements the MCP protocol over stdio transport. It reads JSON-RPC requests from stdin and writes responses to stdout. Internally delegates to gomcp.Server.

func NewServer

func NewServer(version string, tools []NativeTool, reader io.Reader, writer io.Writer) *Server

NewServer creates an MCP server that reads from the given reader and writes responses to the given writer. For stdio transport, pass os.Stdin and os.Stdout. Tests can pass pipes or buffers.

func (*Server) Run

func (s *Server) Run(ctx context.Context) error

Run reads requests from stdin and processes them until EOF.

type ToolCaller

type ToolCaller interface {
	Name() string
	Description() string
	Schema() any
	Call(args string) (string, error)
}

ToolCaller is the interface a tool must implement to be exposed via MCP.

Jump to

Keyboard shortcuts

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