@nera-static/mcp 0.0.0-stage → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md ADDED
@@ -0,0 +1,25 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [1.0.1] - 2026-11-18
9
+
10
+ ### Added
11
+
12
+ - `mcpName` (`io.github.seebaermichi/nera-mcp`) in `package.json`, which the official MCP Registry uses to verify that a server listing belongs to this npm package.
13
+
14
+ ## [1.0.0] - 2026-11-18
15
+
16
+ ### Added
17
+
18
+ - A local MCP server for Nera over stdio: `npx -y @nera-static/mcp --root <folder>`. Only JSON-RPC goes to stdout; logs go to stderr. `--root` is required and must be an existing folder; a missing or invalid one exits with code 1 and a message on stderr. SIGINT, SIGTERM and the client closing stdin stop the running previews and publishes, then the server.
19
+ - The root guard: every path a tool or resource takes is resolved, followed through symlinks and must stay inside `--root`; `..`, an absolute path outside it and a symlink leading out are refused with an error that says what to pass instead.
20
+ - Tools `list_sites` and `get_site` (the site model from `@nera-static/core`), `read_page`, `write_page` (refuses frontmatter without `layout`; YAML written through `yaml`, comments kept) and `delete_page`, `read_file` and `write_file`.
21
+ - Tools `create_site` (`nera new`), `build` (`nera build --json`, optionally `--check`), `validate` (`validateSite()` from `@nera-static/validate`, its `{ file, line, severity, rule, message }` records unchanged) and `add_plugin` (`@nera-static/plugin-*` only: install, default config, templates). Commands run through the site's own `@nera-static/nera` when it has one, without a shell and with their output captured; a cancelled call or a closed server stops them with everything they started (their process group on POSIX, `taskkill /T /F` on Windows).
22
+ - Tools `preview` (`nera dev` on a free port, returns the local URL, `stop: true` stops it) and `publish` (`nera publish --yes --json` in the background: returns the GitHub sign-in code and page, the app installation or Netlify authorization step, then the live URL).
23
+ - Tools `list_starters`, `list_themes` and `list_plugins`, from the npm registry by keyword, official `@nera-static` packages first.
24
+ - Resources `nera://docs/llms-full.txt` (the nera.js.org documentation, bundled on `prepack`), `nera://catalog/{starters,themes,plugins}` and each site's `AGENTS.md` (`nera://site/{site}/AGENTS.md`).
25
+ - Prompts `new_business_website`, `new_blog`, `add_page` and `put_site_online`.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Michael Becker
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,119 @@
1
- # Temporary Holding Version
1
+ # @nera-static/mcp
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ [![Test](https://github.com/seebaermichi/nera-mcp/actions/workflows/test.yml/badge.svg)](https://github.com/seebaermichi/nera-mcp/actions/workflows/test.yml)
4
+ [![npm version](https://img.shields.io/npm/v/@nera-static/mcp)](https://www.npmjs.com/package/@nera-static/mcp)
5
+
6
+ A local [MCP](https://modelcontextprotocol.io) server for the [Nera](https://github.com/seebaermichi/nera) static site generator. It lets an AI assistant (Claude Code, Claude Desktop, Cursor, Codex or any other MCP client) create, edit, build, validate, preview and publish Nera sites in one folder on your computer, and nowhere else.
7
+
8
+ 📖 **Documentation:** [nera.js.org](https://nera.js.org)
9
+
10
+ ```bash
11
+ npx -y @nera-static/mcp --root ~/Sites
12
+ ```
13
+
14
+ The client starts this command itself; you only add it to the client's configuration (below). `--root` is the folder the server may work in: every site it creates lands there, and every path a tool takes is checked against it (no `..`, no absolute path outside it, no symlink leading out).
15
+
16
+ ## Requirements
17
+
18
+ - Node.js **22.12 or later** (`node --version`), with `npx`
19
+ - For `publish`: a GitHub account (and a Netlify account if you host there)
20
+
21
+ ## Install
22
+
23
+ Replace `/Users/you/Sites` with the folder your sites should live in. It must exist. Use an absolute path: clients do not expand `~` in their configuration files.
24
+
25
+ ### Claude Code
26
+
27
+ ```bash
28
+ claude mcp add --transport stdio nera -- npx -y @nera-static/mcp --root /Users/you/Sites
29
+ ```
30
+
31
+ Add `--scope user` to have it in every project, or `--scope project` to share it through the project's `.mcp.json`.
32
+
33
+ ### Claude Desktop
34
+
35
+ Settings → Developer → **Edit Config** opens `claude_desktop_config.json` (macOS: `~/Library/Application Support/Claude/`, Windows: `%APPDATA%\Claude\`). Add the server and restart Claude Desktop:
36
+
37
+ ```json
38
+ {
39
+ "mcpServers": {
40
+ "nera": {
41
+ "command": "npx",
42
+ "args": ["-y", "@nera-static/mcp", "--root", "/Users/you/Sites"]
43
+ }
44
+ }
45
+ }
46
+ ```
47
+
48
+ ### Cursor
49
+
50
+ Add the same `mcpServers` entry to `~/.cursor/mcp.json` (all projects) or `.cursor/mcp.json` (one project).
51
+
52
+ ### Codex
53
+
54
+ ```bash
55
+ codex mcp add nera -- npx -y @nera-static/mcp --root /Users/you/Sites
56
+ ```
57
+
58
+ or in `~/.codex/config.toml`:
59
+
60
+ ```toml
61
+ [mcp_servers.nera]
62
+ command = "npx"
63
+ args = ["-y", "@nera-static/mcp", "--root", "/Users/you/Sites"]
64
+ ```
65
+
66
+ ## What the assistant gets
67
+
68
+ A **site** is a folder under the root (or the root itself) whose `package.json` depends on `@nera-static/nera`. Tools that work on a site take `site`, its path relative to the root (`.` for the root itself); file tools take a path relative to the site.
69
+
70
+ ### Tools
71
+
72
+ | Tool | Does |
73
+ | --- | --- |
74
+ | `list_starters`, `list_themes`, `list_plugins` | The starter kits, themes and plugins on npm, official ones first |
75
+ | `create_site` | Creates a site with `nera new` (`name`, optional `starter`, `theme`, `title`, `lang`) |
76
+ | `list_sites` | The Nera sites under the root |
77
+ | `get_site` | A site's configuration, pages, plugins and theme |
78
+ | `read_page`, `write_page`, `delete_page` | A Markdown page with its frontmatter; `write_page` refuses frontmatter without `layout` |
79
+ | `read_file`, `write_file` | Configuration, templates and assets inside a site |
80
+ | `add_plugin` | Installs an `@nera-static/plugin-*`, copies its default config and publishes its templates |
81
+ | `build` | `nera build`, optionally with the output checks (`check: true`) |
82
+ | `validate` | `nera validate`: the site's layouts, includes and YAML, as `{ file, line, severity, rule, message }` records |
83
+ | `preview` | Starts `nera dev` and returns the local address; `stop: true` stops it |
84
+ | `publish` | `nera publish` to GitHub Pages or Netlify; returns the sign-in code for you, then the live address |
85
+
86
+ The commands run through the site's own `@nera-static/nera` when it has one installed, so the assistant gets the same results as you do in a terminal. A preview or a publish keeps running between calls and stops when the client closes the server.
87
+
88
+ ### Resources
89
+
90
+ | URI | Holds |
91
+ | --- | --- |
92
+ | `nera://docs/llms-full.txt` | The complete Nera documentation, bundled with this release |
93
+ | `nera://catalog/starters`, `nera://catalog/themes`, `nera://catalog/plugins` | The catalogs as JSON |
94
+ | `nera://site/{site}/AGENTS.md` | A site's `AGENTS.md` (`nera://site/AGENTS.md` for a site in the root itself) |
95
+
96
+ ### Prompts
97
+
98
+ | Prompt | Walks through |
99
+ | --- | --- |
100
+ | `new_business_website` | A new business website from the business starter |
101
+ | `new_blog` | A new blog from the blog starter |
102
+ | `add_page` | Adding a page or a post to a site |
103
+ | `put_site_online` | Building, checking and publishing a site |
104
+
105
+ ## Privacy and safety
106
+
107
+ - The server only touches files below `--root`. A path outside it is refused with an error, never quietly corrected.
108
+ - It never asks for input and never prompts in a terminal; long-running commands run in the background and are stopped when the server exits.
109
+ - `publish` signs in through GitHub's device flow: you enter the code in your browser. Tokens stay where `nera publish` keeps them (the system keychain, or a file only you can read) and are never returned to the assistant or written into a site.
110
+ - The catalogs are read from the public npm registry. Nothing else leaves your computer unless you publish.
111
+
112
+ ## Compatibility
113
+
114
+ - Node.js 22.12 or later
115
+ - Brings `@nera-static/nera` 1.23.0 for sites that have none installed. A site with its own CLI installed runs that one: `build` needs 1.9.0 or later (`--json`), `publish` 1.19.0 (1.20.0 for Netlify). `npm update` in the site brings it up to date.
116
+
117
+ ## License
118
+
119
+ MIT
@@ -0,0 +1,114 @@
1
+ #!/usr/bin/env node
2
+ // The stdio entry of @nera-static/mcp: `npx -y @nera-static/mcp --root <folder>`.
3
+ // stdout carries the MCP protocol (JSON-RPC) and nothing else, so every
4
+ // console method that would write there is routed to stderr before any other
5
+ // module loads, and the server is imported only after that.
6
+ import { parseArgs } from 'node:util'
7
+
8
+ for (const method of ['log', 'info', 'debug', 'dir', 'dirxml', 'table']) {
9
+ console[method] = console.error
10
+ }
11
+
12
+ const USAGE = `Usage: nera-mcp --root <folder>
13
+
14
+ Runs the Nera MCP server over stdio. An MCP client (Claude Code, Claude Desktop,
15
+ Cursor, Codex, …) starts it; it lets the assistant create, edit, build, validate,
16
+ preview and publish Nera sites inside <folder> and nowhere else.
17
+
18
+ Options:
19
+ --root <folder> the folder the server may work in (required, must exist)
20
+ --help show this help
21
+ --version show the version`
22
+
23
+ /**
24
+ * Prints `message` to stderr and exits with code 1.
25
+ *
26
+ * @param {string} message
27
+ * @returns {never}
28
+ */
29
+ function fail(message) {
30
+ console.error(`nera-mcp: ${message}`)
31
+ process.exit(1)
32
+ }
33
+
34
+ let options
35
+ try {
36
+ ({ values: options } = parseArgs({
37
+ options: {
38
+ root: { type: 'string' },
39
+ help: { type: 'boolean' },
40
+ version: { type: 'boolean' },
41
+ },
42
+ strict: true,
43
+ allowPositionals: false,
44
+ }))
45
+ } catch (error) {
46
+ fail(`${error.message}\n\n${USAGE}`)
47
+ }
48
+
49
+ // --help and --version start no server, so they may use stdout
50
+ if (options.help) {
51
+ process.stdout.write(`${USAGE}\n`)
52
+ process.exit(0)
53
+ }
54
+
55
+ const { default: pkg } = await import('../package.json', { with: { type: 'json' } })
56
+
57
+ if (options.version) {
58
+ process.stdout.write(`${pkg.version}\n`)
59
+ process.exit(0)
60
+ }
61
+
62
+ if (!options.root) {
63
+ fail(`--root <folder> is required: the folder the server may work in.\n\n${USAGE}`)
64
+ }
65
+
66
+ // the server and the Nera packages it loads come last: only the server needs them
67
+ const [{ StdioServerTransport }, { createServer }, { createProcesses }, { PathError }] = await Promise.all([
68
+ import('@modelcontextprotocol/sdk/server/stdio.js'),
69
+ import('../src/server.js'),
70
+ import('../src/processes.js'),
71
+ import('../src/paths.js'),
72
+ ])
73
+
74
+ const processes = createProcesses()
75
+ let server
76
+ try {
77
+ server = await createServer({ root: options.root, processes })
78
+ } catch (error) {
79
+ if (error instanceof PathError) fail(error.message)
80
+ throw error
81
+ }
82
+
83
+ let closing = false
84
+
85
+ /**
86
+ * Stops the preview and publish children (they run in their own process
87
+ * group, so they would outlive this process otherwise), closes the server
88
+ * and exits. A second signal while that runs exits at once.
89
+ *
90
+ * @param {number} code
91
+ */
92
+ async function shutdown(code) {
93
+ if (closing) process.exit(code)
94
+ closing = true
95
+ try {
96
+ // before server.close(): its onclose handler would start the same stop
97
+ // without anyone waiting for it
98
+ await processes.stopAll()
99
+ await server.close()
100
+ } catch (error) {
101
+ console.error(`nera-mcp: shutting down failed: ${error.message}`)
102
+ code = 1
103
+ }
104
+ process.exit(code)
105
+ }
106
+
107
+ process.on('SIGINT', () => shutdown(0))
108
+ process.on('SIGTERM', () => shutdown(0))
109
+ // the client hung up: stdin ends, or stdout can no longer be written
110
+ process.stdin.on('end', () => shutdown(0))
111
+ process.stdout.on('error', () => shutdown(0))
112
+
113
+ await server.connect(new StdioServerTransport())
114
+ console.error(`nera-mcp ${pkg.version}: serving Nera sites under ${options.root} over stdio`)