mcpserver

package
v1.0.4 Latest Latest
Warning

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

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

Documentation

Overview

Package mcpserver exposes OK's tool registry as an MCP server over stdio. Any MCP client (Claude Code, Cursor, VS Code extensions) can connect and call OK's built-in tools (bash, read_file, write_file, edit_file, grep, glob, web_fetch, task, ask, todo_write, complete_step) plus all configured plugin tools — turning OK into a drop-in code-agent backend.

Protocol: JSON-RPC 2.0, one message per line (NDJSON), matching the MCP spec (https://spec.modelcontextprotocol.io). stdin/stdout are the JSON-RPC channel; all diagnostics go to stderr.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type RegistryAdapter

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

RegistryAdapter adapts a *tool.Registry to ToolProvider.

func NewRegistryAdapter

func NewRegistryAdapter(reg *tool.Registry) *RegistryAdapter

func (*RegistryAdapter) CallTool

func (a *RegistryAdapter) CallTool(ctx context.Context, name string, args json.RawMessage) (string, bool, error)

func (*RegistryAdapter) ListTools

func (a *RegistryAdapter) ListTools() []ToolInfo

type Server

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

Server runs the MCP stdio server. It reads JSON-RPC requests from r, writes responses to w, and dispatches tool calls through the ToolProvider.

func New

func New(r io.Reader, w io.Writer, tools ToolProvider) *Server

New creates an MCP server over the given reader/writer pair.

func (*Server) Run

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

Run reads requests until EOF and dispatches them. Returns on clean EOF or a read error.

type ToolInfo

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

ToolInfo describes one tool for the MCP tools/list response.

type ToolProvider

type ToolProvider interface {
	// ListTools returns every available tool's name + description + schema.
	ListTools() []ToolInfo
	// CallTool executes a tool by name with the given JSON args.
	CallTool(ctx context.Context, name string, args json.RawMessage) (string, bool, error)
}

ToolProvider is the minimal interface the MCP server needs from the caller. The caller (cli/mcp_serve.go) builds the full registry from config.

Jump to

Keyboard shortcuts

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