morph 0.1.0
Asynchronous bridge between GUI thread and business models
Loading...
Searching...
No Matches
agent.hpp File Reference
#include <atomic>
#include <chrono>
#include <cstdint>
#include <exception>
#include <expected>
#include <functional>
#include <istream>
#include <map>
#include <memory>
#include <mutex>
#include <optional>
#include <ostream>
#include <set>
#include <stdexcept>
#include <string>
#include <string_view>
#include <utility>
#include <vector>
#include "../core/completion.hpp"
#include "../core/executor.hpp"
#include "../core/remote.hpp"
#include "../core/wire.hpp"
#include "../forms/forms.hpp"
#include "../session/session.hpp"
#include "bundle.hpp"
#include "value.hpp"

Go to the source code of this file.

Classes

struct  morph::ui::McpOptions
 What an McpAdapter is built with. More...
class  morph::ui::McpAdapter
 Serves MCP's tools over one server connection (spec 8 §11). More...

Functions

void morph::ui::serveStdio (McpAdapter &adapter, exec::MainThreadExecutor &owner, std::istream &input, std::ostream &output)
 Serves an adapter over MCP's stdio transport: one JSON-RPC message per line of input, each reply on a line of output, in order, until input ends. An empty line is skipped.

Variables

constexpr std::int64_t morph::ui::kMcpMethodNotFound = -32601
 The JSON-RPC error code of a method the adapter does not answer.
constexpr std::int64_t morph::ui::kMcpParseError = -32700
 The JSON-RPC error code of a message that is not JSON.
constexpr std::int64_t morph::ui::kMcpInvalidRequest = -32600
 The JSON-RPC error code of a message that is not a request.
constexpr std::int64_t morph::ui::kMcpInvalidParams = -32602
 The JSON-RPC error code of a call whose arguments the adapter cannot use.

Detailed Description

The MCP adapter (spec 8 §11): an agent's tool calls run through the server as ordinary envelopes on a connection of their own, so every check a GUI gets applies to them, and every GUI watching what they change is told. The adapter speaks MCP's JSON-RPC 2.0 and knows no transport; serveStdio drives it over MCP's stdio transport.

Definition in file agent.hpp.

Function Documentation

◆ serveStdio()

void morph::ui::serveStdio ( McpAdapter & adapter,
exec::MainThreadExecutor & owner,
std::istream & input,
std::ostream & output )
inline

Serves an adapter over MCP's stdio transport: one JSON-RPC message per line of input, each reply on a line of output, in order, until input ends. An empty line is skipped.

The calling thread is the adapter's owner: it pumps owner while it waits for each reply.

Parameters
adapterThe adapter; its McpOptions::callbacks is owner.
ownerThe adapter's owner, run on the calling thread.
inputWhere messages arrive.
outputWhere replies go; flushed after each.

Definition at line 524 of file agent.hpp.

Variable Documentation

◆ kMcpMethodNotFound

std::int64_t morph::ui::kMcpMethodNotFound = -32601
inlineconstexpr

The JSON-RPC error code of a method the adapter does not answer.

Definition at line 56 of file agent.hpp.

◆ kMcpParseError

std::int64_t morph::ui::kMcpParseError = -32700
inlineconstexpr

The JSON-RPC error code of a message that is not JSON.

Definition at line 58 of file agent.hpp.

◆ kMcpInvalidRequest

std::int64_t morph::ui::kMcpInvalidRequest = -32600
inlineconstexpr

The JSON-RPC error code of a message that is not a request.

Definition at line 60 of file agent.hpp.

◆ kMcpInvalidParams

std::int64_t morph::ui::kMcpInvalidParams = -32602
inlineconstexpr

The JSON-RPC error code of a call whose arguments the adapter cannot use.

Definition at line 62 of file agent.hpp.