GNU TeXmacsUser manualReferenceAboutEnglish
Working with an AI agent: the MCP server

TeXmacs Upsilon can serve its documents to an AI agent, such as Claude Code, Claude Desktop or any other client of the Model Context Protocol (MCP). The command is

texmacs --mcp

It starts a TeXmacs without a window, which the agent talks to through its standard input and output. You do not type anything in a terminal: the agent starts the program itself, once you have told it, in its configuration, which command to run (see Installing and connecting an agent).

What the agent can do

The agent reads and edits your documents by their structure. It asks for the outline of a document (the title, the sections and the labels), reads the sections that it needs, finds text and tags, lists the labels, the references and the citations (with the broken ones), and changes the document by replacing, inserting or deleting a node, or by changing a word or a sentence in a paragraph. Every node it reads has a handle and a hash, and an edit says which node and which version of it it is meant for.

Why not simply edit the file?

An agent can also edit a .tm file as text. That works for small changes, but the file of TeXmacs is a serialized tree, with its own encoding of accents and symbols, and an editor of text does not know it. Through the server:

In this chapter

The server is part of TeXmacs Upsilon only (see TeXmacs Upsilon features). The developer notes are in the file docs/mcp-server.md of the sources, and the security model is described on the page MCP-security of the wiki of the repository.

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.1 or any later version published by the Free Software Foundation; with no Invariant Sections, with no Front-Cover Texts, and with no Back-Cover Texts. A copy of the license is included in the section entitled "GNU Free Documentation License".