@eigenpal/docx-editor-agents/mcp

Model Context Protocol (MCP) server for the docx editor agent bridge.

Two transports, same core: - stdio: classic MCP transport. Use runStdioServer(bridge) from a Node subprocess that Claude Desktop, Cursor, or any MCP-aware client will spawn. Newline-delimited JSON-RPC. - direct: call new McpServer(bridge).handle(message) if you have your own transport (WebSocket, postMessage, HTTP long-poll, etc.).

The server is transport-agnostic and zero-dep. The stdio module reaches for process.stdin / process.stdout only when you call runStdioServer without explicit streams.

Functions (7)

encodeFramefunctionSource ↗

Encode a JSON-RPC message as a single newline-terminated frame.

declare function encodeFrame(message: JsonRpcMessage): string;

isJsonRpcNotificationfunctionSource ↗

declare function isJsonRpcNotification(m: unknown): m is JsonRpcNotification;

isJsonRpcRequestfunctionSource ↗

declare function isJsonRpcRequest(m: unknown): m is JsonRpcRequest;

makeErrorfunctionSource ↗

declare function makeError(id: JsonRpcId, code: number, message: string, data?: unknown): JsonRpcError;

makeSuccessfunctionSource ↗

declare function makeSuccess(id: JsonRpcId, result: unknown): JsonRpcSuccess;

parseFramesfunctionSource ↗

Parse newline-delimited JSON-RPC frames out of a buffer. Returns parsed messages plus any leftover bytes. Tolerates blank lines.

declare function parseFrames(buffer: string): ParseResult;

runStdioServerfunctionSource ↗

Wire an EditorBridge to a JSON-RPC stdio loop. Returns immediately; reading happens via the stream listeners. Designed to be testable: pass in fake streams, call feed(...) directly, then assert on what was written.

declare function runStdioServer(bridge: EditorBridge, options?: StdioServerOptions): StdioServerHandle;

Classes (1)

McpServerclassSource ↗

declare class McpServer
MemberTypeSummary
(constructor)Constructs a new instance of the `McpServer` class
handleHandle one inbound message. Returns the response to send back, or `null` for notifications and other no-reply messages. Never throws.

Interfaces (13)

JsonRpcErrorinterfaceSource ↗

interface JsonRpcError
MemberTypeSummary
error{ code: number; message: string; data?: unknown; }
idJsonRpcId
jsonrpc'2.0'

JsonRpcNotificationinterfaceSource ↗

interface JsonRpcNotification
MemberTypeSummary
jsonrpc'2.0'
methodstring
params?unknown

JsonRpcRequestinterfaceSource ↗

interface JsonRpcRequest
MemberTypeSummary
idJsonRpcId
jsonrpc'2.0'
methodstring
params?unknown

JsonRpcSuccessinterfaceSource ↗

interface JsonRpcSuccess
MemberTypeSummary
idJsonRpcId
jsonrpc'2.0'
resultunknown

McpContentinterfaceSource ↗

interface McpContent
MemberTypeSummary
textstring
type'text'

McpInitializeResultinterfaceSource ↗

interface McpInitializeResult
MemberTypeSummary
capabilities{ tools?: Record<string, unknown>; }
protocolVersionstring
serverInfo{ name: string; version: string; }

McpServerOptionsinterfaceSource ↗

MCP server core. Transport-agnostic — accepts a JsonRpcRequest, returns either a JsonRpcResponse or null (for notifications, which never reply).

Wraps an EditorBridge: tools/list returns the bridge's tool schemas in MCP shape; tools/call dispatches via executeToolCall and converts the AgentToolResult into MCP CallToolResult content.

interface McpServerOptions
MemberTypeSummary
name?stringServer name reported in `initialize` response. Default: `@eigenpal/docx-editor-agents`.
protocolVersion?stringMCP protocol version we claim to speak. Default: `2025-06-18`.
version?stringServer version. Default: `0.0.0` (override at build time).

McpToolDescriptorinterfaceSource ↗

interface McpToolDescriptor
MemberTypeSummary
descriptionstring
inputSchemaRecord<string, unknown>
namestring

McpToolsCallParamsinterfaceSource ↗

interface McpToolsCallParams
MemberTypeSummary
arguments?Record<string, unknown>
namestring

McpToolsCallResultinterfaceSource ↗

interface McpToolsCallResult
MemberTypeSummary
contentMcpContent[]
isError?boolean

McpToolsListResultinterfaceSource ↗

interface McpToolsListResult
MemberTypeSummary
toolsMcpToolDescriptor[]

StdioServerHandleinterfaceSource ↗

interface StdioServerHandle
MemberTypeSummary
close() => voidStop accepting input and reject further writes. Idempotent.
feed(chunk: string | Buffer) => voidManually feed a raw chunk (used by tests; the live transport calls this internally).
serverMcpServerUnderlying server (for tests / introspection).

StdioServerOptionsinterfaceSource ↗

interface StdioServerOptions extends McpServerOptions
MemberTypeSummary
input?InputStream
log?(msg: string) => voidCalled with diagnostic strings (e.g. parse errors). Default: stderr.
output?OutputStream

Type aliases (3)

JsonRpcIdtypeSource ↗

MCP wire protocol (subset) — JSON-RPC 2.0 framing + the message types we actually implement. Zero dependencies. Pure functions; everything is unit- testable without a transport.

This is NOT a full MCP SDK. We implement only what the server needs: - initialize / initialized - tools/list - tools/call - notifications/cancelled (no-op, accepted)

Spec reference: https://spec.modelcontextprotocol.io

type JsonRpcId = string | number | null;

JsonRpcMessagetypeSource ↗

type JsonRpcMessage = JsonRpcRequest | JsonRpcNotification | JsonRpcResponse;

JsonRpcResponsetypeSource ↗

type JsonRpcResponse = JsonRpcSuccess | JsonRpcError;

Variables (1)

ErrorCodeconstSource ↗

Standard JSON-RPC error codes. We only ever emit JSON-RPC errors for protocol-level problems; tool execution failures use MCP's isError envelope inside a successful response, per spec.

ErrorCode: {
    readonly ParseError: -32700;
    readonly InvalidRequest: -32600;
    readonly MethodNotFound: -32601;
    readonly InvalidParams: -32602;
    readonly InternalError: -32603;
}

On this page