For AI agents
Steps for coding agents (Claude Code, Cursor, Codex, Gemini CLI...) working on
research articles made with the Research Article Template and its collaborative
editor. Every command below is copy-pasteable; replace the
<placeholders>. The same page is available as
Markdown.
Pick a path
- Show a human what the editor feels like - send them to the live demo (no account, nothing saved, simulated co-authors). It runs entirely in the browser with no backend, so there is no MCP server to connect to: agents cannot read or edit it.
- Edit a live article in an editor Space - connect to the editor's MCP server and edit next to the human authors. You need an editor Space you can write to (see below).
- Create a new article from the template - free: clone the template repository, write MDX, deploy to a static Space.
- Host an editor for a team - duplicate the
editor Space. Since July 21, 2026 this
needs a Hugging Face Team or Enterprise organization
(co-authors with an org write role, which is free) or a
PRO account (personal copy, only the owner can edit). The public
editor Space is read-only for visitors.
hf repos duplicate tfrere/research-article-template-editor your-org/paper-editor --type space
Requires huggingface_hub 1.6+ andhf auth login.
Connect over MCP
Every editor Space exposes a remote MCP server at /mcp (Streamable
HTTP). Use the Space's app URL: the Space your-org/paper-editor answers
at https://your-org-paper-editor.hf.space/mcp. Authenticate with an HF
access token (HF_TOKEN) of a user who can write to the Space: its
owner, or a member of the owning organization with a write role.
Claude Code
claude mcp add --transport http article https://<space>.hf.space/mcp \ --header "Authorization: Bearer $HF_TOKEN"
Cursor, in .cursor/mcp.json:
{
"mcpServers": {
"article": {
"url": "https://<space>.hf.space/mcp",
"headers": { "Authorization": "Bearer ${env:HF_TOKEN}" }
}
}
} Codex, in ~/.codex/config.toml:
[mcp_servers.article] url = "https://<space>.hf.space/mcp" bearer_token_env_var = "HF_TOKEN"
Optional: an X-Agent-Name header sets the name people see (defaults
to the MCP client name), and a ?doc=<name> query opens another
document (default default; only default is published).
Full reference: docs/MCP.md.
Edit a live article
The agent joins the same live document as the browsers: people see its name and its edits as they happen, and its own steps can be undone without touching theirs.
get_article_infofor the title, blocks, charts and publish state.read_articlewithoutline: true, thensection: "...". Each block is preceded by<!-- block:ID type rev:REV -->.- Edit with
replace_text(minimal diff, keeps comments and formatting),insert_blocks,replace_blockordelete_block. Passexpected_revso an edit is refused if someone changed the block; onrev_conflict, read again and retry. - Group related edits with
apply_edits: all or nothing, oneundo. - Discuss with
list_comments,add_comment,reply_to_comment,resolve_comment. - Charts:
create_embed(validated and checked in a headless browser), theninsert_embedto place it;update_embedwithexpected_versionto change it. publishputs the web page, the Markdown twin (/llms.txt) and, when possible, a PDF online. Give the userurls.html.
Create a new article
From the template repository (Node.js 20+, Git LFS):
git clone https://github.com/tfrere/research-article-template.git my-paper cd my-paper git lfs install && git lfs pull cd app npm install npm run dev # dev server on port 4321
- Read
AGENTS.mdfirst: project layout, conventions and the list of task skills. - Before a task, read the matching skill in
.ai/skills/:write-mdx-content,create-html-embed(withruntime.mdandtemplate.html),design-dataviz,article-frontmatter,deploy-to-hf-spaces. Cursor also finds them in.cursor/skills/. - Layout lives in
app/src/styles/_grid.css(--layout-*tokens); check alignment with?gridon any URL, orGinnpm run dev. - The entry point is
app/src/content/article.mdx(frontmatter and imported chapters); chapters live inapp/src/content/chapters/, embeds inapp/src/content/embeds/, data inapp/src/content/assets/data/.
Write an embed
An embed is a self-contained HTML fragment. The template and the editor (including
over MCP) share the same Embed.mount contract: the runtime loads D3,
reads data and config, provides the theme CSS variables
and palettes, and re-renders on resize and theme changes.
<div class="d3-my-chart"></div>
<style>
.d3-my-chart { position: relative; color: var(--text-color); }
.d3-my-chart svg { display: block; width: 100%; overflow: visible; }
</style>
<script>
Embed.mount('d3-my-chart', (ctx) => {
// Setup, runs once: data, scales, persistent DOM.
const rows = [{ x: 'A', y: 3 }, { x: 'B', y: 5 }];
const svg = d3.select(ctx.root).append('svg');
ctx.describe('Bar chart of 2 categories; B is highest.');
// Render, runs on first paint and on width, theme or palette change.
return ({ width, isDark }) => {
const colors = ctx.colors();
// scales, axes, data joins
};
});
</script> - Exactly one root
<div>whose class matches the file name (d3-my-chart.htmluses.d3-my-chart), with noid; every CSS rule is prefixed with the root class. - A classic inline script calls
Embed.mountat top level (not inDOMContentLoaded, a timeout or an async wrapper). No globals; query only insidectx.root. setup(ctx)runs once and returns a render function called withwidth,height,theme,isDark.- Colors come from CSS variables and
ctx.colors(), read inside render; never hardcode them. Describe the chart withctx.describe(). - Template: data files go in
app/src/content/assets/data/(served at/data/), passed with thedataprop and read withctx.data();configarrives asctx.config. Use it in MDX with<HtmlEmbed src="d3-my-chart.html" title="..." data="my-data.csv" />. - Editor: the iframe cannot fetch, so inline the data and attach source files with
data_files. - Start from
.ai/skills/create-html-embed/template.htmland readruntime.mdfor the full API. Verify every embed before you hand it over:
cd app npm run check:embed -- d3-my-chart.html --data my-data.csv npm run check:embed -- --all # every embed in the repo
Deploy
Free, static Space. Create a Space with the Static SDK at huggingface.co/new-space, then:
cd app npm run build hf upload <you>/<your-space> dist . --repo-type space
Docker Space, built on Hugging Face with the included
Dockerfile (see the deploy skill):
git remote add space git@hf.co:spaces/<you>/<your-space> git push space main
Keep this in the Space README.md frontmatter so the article appears in the gallery:
tags: - research-article-template
Never do this
- Never remove the
research-article-templatetag from a SpaceREADME.md: it powers the community gallery. - Never rewrite a whole live article to change a passage: use
replace_textor block tools withexpected_rev, so people's concurrent edits and comments survive. - Never overwrite a chart someone is editing:
update_embedrefuses withdraft_in_progressunlessforce; ask instead. - Never hardcode colors in an embed, style unprefixed
body,svgortext, or hand-roll D3 loading, resize or theme observers. - Never tell users that duplicating the editor Space is free: it needs HF PRO or a Team organization.
- Never put an access token in an article, an embed or a commit.
Machine-readable files
/llms.txt- index of this site for LLMs (llmstxt.org format)./llms-full.txt- the full documentation as one Markdown file./docs.mdand/docs/agents.md- Markdown twins of the docs pages.- Every published article serves its own Markdown twin at
/llms.txt, for example the template demo article.