mcp

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package mcp implements a Model Context Protocol (MCP) server over stdio. It exposes cloop functionality as MCP tools so that Claude Desktop, Cursor, and other MCP clients can directly control and query cloop.

Protocol: JSON-RPC 2.0 over newline-delimited stdio. Spec: https://spec.modelcontextprotocol.io

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RunStdio

func RunStdio(ctx context.Context, workDir string, prov provider.Provider) error

RunStdio starts the MCP server reading from os.Stdin and writing to os.Stdout. It blocks until stdin is closed or ctx is cancelled.

Types

type RPCError

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

RPCError is a JSON-RPC 2.0 error object.

type Request

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

Request is an incoming JSON-RPC 2.0 request or notification.

type Response

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

Response is an outgoing JSON-RPC 2.0 response.

type Server

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

Server is an MCP server that reads JSON-RPC requests from r and writes responses to w, exposing cloop functionality as MCP tools.

func New

func New(workDir string, prov provider.Provider, r io.Reader, w io.Writer) *Server

New creates a new MCP Server. workDir is the cloop project directory (.cloop/state.json must exist). prov is the AI provider used for run_task; may be nil if only state tools are needed.

func (*Server) Serve

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

Serve reads requests from stdin until EOF or context cancellation.

type TextContent

type TextContent struct {
	Type string `json:"type"`
	Text string `json:"text"`
}

TextContent is a text content block in a tool result.

type Tool

type Tool struct {
	Name        string         `json:"name"`
	Description string         `json:"description"`
	InputSchema map[string]any `json:"inputSchema"`
}

Tool describes an MCP tool (returned by tools/list).

type ToolResult

type ToolResult struct {
	Content []TextContent `json:"content"`
	IsError bool          `json:"isError,omitempty"`
}

ToolResult is the result returned by tools/call.

Jump to

Keyboard shortcuts

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