mcpserver

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2026 License: MIT Imports: 21 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 mcpserver is the app's tool mode: the app's own binary, run again by Claude Code as a stdio MCP server, which serves Describe it's tools to the in-app conversation and, through the plugin, to the user's own Claude Code. It reads the snapshot the app wrote (kit.Snapshot), answers with kit's words and checks, and writes nothing but a proposal, into a folder the app made. It starts nothing, opens no database, reads no environment, makes no network call, and writes no log.

The protocol is JSON-RPC 2.0 over stdin and stdout, one message a line, each line at most 4 MB, answered as it comes: the agent's client never closes stdin, and ends the tool mode with a signal, so nothing waits for stdin to end and every proposal is written whole the moment it is made. It speaks MCP's dated versions up to 2025-11-25: it answers initialize, ping, tools/list, and tools/call; refuses every other request, the newer protocol's server/discover probe among them, as a method it doesn't have, which makes the client fall back to initialize; and answers no notification. A tool's answer is text, with isError for a refusal the agent reads and can act on, and never structuredContent, which the client would show the agent in place of the text.

The flag names the describe folder and, for the in-app conversation, the conversation (Arg, ConversationArg). The conversation's agent (kit.InApp) reads the user's whole setup and the names in their inbox; a session in the user's own Claude Code (kit.Outside) reads the part of the setup Snapshot.Outside keeps, and never the inbox's names. Either way a proposal is checked against the whole snapshot, as the app checks it again on its card, and one with a problem is refused. One that passes is written into the conversation's proposals folder, or, from outside, into the outside folder, which holds at most kit.MaxOutsidePending proposals waiting for the user; the tool mode makes neither folder, and writes into one only when the app made it.

Index

Constants

View Source
const (
	// Flag asks for the tool mode, protocol version 1, with the data folder's describe
	// folder as its value: --mcp-server-v1=<describe folder>.
	Flag = "--mcp-server-v1"

	// ConversationFlag names the in-app conversation the tool mode serves, by its UUID:
	// --conversation=<uuid>. Without it, the tool mode serves the user's own Claude Code
	// (kit.Outside).
	ConversationFlag = "--conversation"
)

The tool mode's flags. The protocol is versioned in the flag's name, so a session that outlives an update calls the new build in the protocol it started with, and a build that doesn't know a version refuses it rather than start as the app.

Variables

This section is empty.

Functions

func Arg

func Arg(dir string) string

Arg returns the tool mode's argument for the describe folder dir.

func ConversationArg

func ConversationArg(id string) string

ConversationArg returns the argument naming the in-app conversation id.

func IsCall

func IsCall(args []string) bool

IsCall reports arguments that ask for the tool mode, in any protocol version.

func Serve

func Serve(args []string, stdin io.Reader, stdout, stderr io.Writer) (int, bool)

Serve runs the tool mode when args ask for it (IsCall), and returns the status the process exits with and true; for any other arguments it returns 0 and false and reads nothing. It answers the MCP messages on stdin, one JSON-RPC message a line, on stdout, each as it comes, and returns 0 once stdin ends. A call it can't serve (a protocol this build doesn't know, no describe folder, a conversation that isn't one) is refused with a line on stderr and a non-zero status before it reads anything, and an error that ends a session (stdin unreadable, stdout gone) is said on stderr too.

Types

This section is empty.

Jump to

Keyboard shortcuts

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