* bots, nodejs: document chat, connection, member contact and network commands, typed commands in library * bots, nodejs: restore apiConnect, wrap domain once, test all connect responses * nodejs: JSDoc for new methods * docs: plan for bot API commands and typed Node library methods * tests: channel prepared with a domain has a verified SimpleX name * docs: apply review fixes to the plan for bot API commands * docs: apply second review pass to the plan for bot API commands * docs: refer the bot API plan to the rewritten test commit * docs: record decisions in the plan for bot API commands * docs: plan tests of the generated Python command strings * python: test the generated strings of the documented commands * docs: plan for files, /leave and library methods in the MCP server * docs: wait at stop in the MCP plan * docs: library methods and /leave mechanics in the MCP plan * mcp: typed library methods for chat commands * docs: plan the message information command for bots * mcp: /leave CHAT owner command to leave a chat at once * docs: file servers, GIF and video choices decided in the MCP plan * docs: file mechanics in the MCP plan * mcp: files of received messages * bots, nodejs: message information with the file servers for bots * docs: plan the relay approval option of receiving files in Node * mcp: download of received files with owner approval * docs: name the xftp-server test helper in the files plan * nodejs: receive files without approving unknown relays * docs: plan the user servers command for bots * bots, nodejs: user servers and relays by operator for bots * nodejs: document the message information method * docs: plan the file upload progress event for bots * mcp: send files with owner approval, refusing private keys * bots: file upload progress event for bots * mcp: /leave template in the agent control chat menu * docs: sent copies are deleted for contacts too, at sndFileCompleteXFTP * bots: drop the file upload progress event * docs: drop the upload progress event plan * nodejs: document user servers and relay approval of received files * mcp: download cards name unknown file servers after the upload * docs: record the wait for the file description in the files plan * mcp: fixed wait at stop for cancelled cards, without /sql * docs: record decision C4, a fixed wait at stop, in the files plan * ci: test the MCP server package on pull requests * ci: state when the MCP workflow can be dispatched * ci: run the MCP server tests when its libraries change * mcp: log the errors of image previews and resizing * mcp: keep files in transfer in the data folder * mcp: restrict sent files by the real paths of refused folders * mcp: validate the file at the send by its inode and change time * mcp: limit ffmpeg and ffprobe to local files and no input commands * mcp: ask the owner for unknown file servers; read approvals at creation * mcp: name downloaded files by their ID; return paths of downloads only * mcp: end each download with a result for the agent and the card * mcp: show files above their sender's size limit as failed * mcp: refuse empty files, as without file and captions too long to send * mcp: tell the owner about failed uploads and unposted received files * mcp: delete resized copies left by the last run at start * mcp: name downloads and leaving in the help and greeting, align docs * mcp: compute the download path for received files only * mcp: send a /receive file to the owner under its name * mcp: keep files received without a download in the chat's folder * mcp: keep a left chat's files and delete them with /delete CHAT files * mcp: test that sent images are resized by the core * mcp: wait 30 minutes for a download's progress before cancelling it * mcp: end a download as deleted only when its message is not found * mcp: delete the copy of a /receive file whose post fails * mcp: count the quoted content in a message's length, as the core sends it * mcp: name received bytes, unknown-server downloads and left chat files plainly * mcp: test refused folders, file changes and download approvals * docs: align MCP server docs with refused folders, leaves and download waits * mcp: move received files only in full, delete partials only of downloads * mcp: report a received file missing from its folder as failed * mcp: move received files of a group's member chats into its folder * mcp: read a video's preview and duration as an MP4 or QuickTime file * mcp: 0.2.0 on simplex-chat 7.1.0-beta.10.1 * mcp: file folders by chat type, /delete cancels downloads, files reply * docs: MCP server specs and plan for 0.2.0 * mcp: /receive gives the agent a file, /forward sends it to the owner * docs: MCP server specs for /receive and /forward of download cards * docs: MCP plan records the temp folder command as a library exception * mcp: /delete cancels resumed downloads; /forward quote fits the limit * docs: MCP specs and plans for /forward quotes and resumed downloads * docs: MCP specs name the source commit they are checked against * docs: MCP PLAN states the /forward quote and move rules * mcp: a download moves its completed file whatever its size * mcp: /receive N all covers its card and later files, not pending ones * docs: MCP files approval scope, reply text and README server wording * mcp: a download approves relays only for a card naming unknown servers * mcp: files in member chats of a group are tracked as in the main chat * docs: MCP relay approval of downloads and files in member chats * mcp: a rejected file gets a card again under the files approval * docs: MCP rejected files under the files approval, README scope * mcp: an offered file without a description gets no card or action * docs: MCP a file without a description is not downloaded * mcp: 0.2.0 on simplex-chat 7.1.0-beta.10.2 * ci: test the MCP server as a scope of build-linux
SimpleX MCP server: specification
Technical specification of
@simplex-chat/mcp0.2.0 inpackages/simplex-chat-mcp. Statements are checked against the source at commit937a975a6, and each section links to the code.Related: README (user manual) | PLAN (design record) | TESTING (local build and test)
Table of contents
Executive summary
@simplex-chat/mcp is a local server that gives an MCP host one SimpleX profile per process. The host reaches it with Streamable HTTP on 127.0.0.1 and a bearer token. The server exposes six tools: connect, send, receive, download, list and leave.
The SimpleX core (libsimplex, release core-7.1.0.20) runs inside the same Node.js process, loaded by the simplex-chat library 7.1.0-beta.10.2. The core keeps the profile, chats and connections in two SQLite databases of the data folder, and sends and receives files through XFTP servers. The MCP protocol is served by the MCP TypeScript SDK (@modelcontextprotocol/server 2.3.1 and @modelcontextprotocol/node 2.1.1).
connect, send, download and leave are actions. In mode requests the server posts each action as a card in the agent control chat, a SimpleX group created and owned by the agent's profile. An owner approves or rejects the card with a command in that chat, and the server performs the action after the approval. An owner can also approve all messages to one chat, or all downloads of files on known servers from one chat, in advance. On a download card, the owner lets the agent receive the file, or has it forwarded only to the owner. In mode host the server performs actions at once and marks the four tools for the host's own confirmation.
A tool call is held open by the server until the owner decides and, for connect and send, until the replies arrive, and for download, until the file is received or wait passes. A repeated call with the same arguments is attached to the same action, so a call that the host ends early is resumed.
The server keeps actions and downloads in memory, and they are lost when the process exits. The action counter and the standing approvals are stored as custom data in the chat database. The token, the headers file for the host, the server record and the lock are files in the data folder; downloaded files are in its files folder, one folder per chat.
Dependency graph
Solid edges are runtime imports. Dotted edges are type-only imports, removed by the compiler.
graph TD
cli["cli.ts"] --> serve["serve.ts"]
cli --> register["register.ts"]
cli --> messages["messages.ts"]
cli --> log["log.ts"]
cli -.-> actions["actions.ts"]
serve --> control["control.ts"]
serve --> tools["tools.ts"]
serve --> actions
serve --> http["http.ts"]
serve --> files["files.ts"]
serve --> messages
serve --> log
control --> tools
control --> actions
control --> messages
control --> log
control -.-> serve
tools --> actions
tools --> messages
tools --> log
actions --> messages
actions --> log
actions -.-> tools
register --> files
register --> log
files --> log
http --> log
messages --> log
serve --> sc["simplex-chat"]
tools --> sc
control --> sc
messages -.-> sc
log --> sc
serve --> types["@simplex-chat/types"]
tools --> types
control --> types
messages --> types
log --> types
serve --> mcps["@modelcontextprotocol/server"]
tools --> mcps
http --> mcps
http --> mcpn["@modelcontextprotocol/node"]
control --> qr["qrcode"]
| Module | Role |
|---|---|
cli.ts |
simplex-mcp entry point: commands, options, exit codes |
serve.ts |
start sequence, event dispatch, stop sequence |
http.ts |
HTTP listener, token check, /mcp route, SDK handler |
tools.ts |
tool schemas, descriptions, handlers, connect plans, perform steps, downloads, files to send |
actions.ts |
action records, state machine, expiry, stop |
control.ts |
agent control chat: link, owners, owner commands, cards, counter |
messages.ts |
message items and their files, item watch, waits, unread paging, display names |
files.ts |
data folder, lock, token, headers.json, server.json |
register.ts |
register command: Claude Code entry |
log.ts |
terminal lines, error texts, shell quoting |
Specification documents
| Document | Contents |
|---|---|
| Architecture | system diagram, modules and types, state, process lifecycle, approval model, security boundaries, limits |
| Flows | sequence diagrams of the main flows with source locations |
| API | the six tools, the control chat commands, replies and cards, the CLI |
Source entry points
| Component | File | Key symbol | Line |
|---|---|---|---|
Binary simplex-mcp |
src/cli.ts |
main |
198 |
| Argument parser | src/cli.ts |
parseCommand |
45 |
| Server start | src/serve.ts |
startServer |
65 |
| Agent wiring and event dispatch | src/serve.ts |
startAgent |
88 |
| HTTP listener | src/http.ts |
startHttp |
14 |
| Tool registration | src/tools.ts |
AgentTools.register |
488 |
| Downloads | src/tools.ts |
AgentTools.downloadFile |
522 |
| Action store | src/actions.ts |
Actions |
124 |
| Agent control chat | src/control.ts |
Control |
81 |
| Card text | src/control.ts |
cardText |
552 |
| Item watch | src/messages.ts |
ChatItemsWatch |
86 |
| Claude Code entry | src/register.ts |
register |
33 |
| Data folder files | src/files.ts |
createDataFolder, acquireLock |
12 |
| Package manifest | package.json |
bin.simplex-mcp |
6 |