@nextfreelatech/xpec-mcp 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/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for describing the origin of the Work and
141
+ reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may accept and charge a
167
+ fee for the acceptance of support, warranty, indemnity, or other
168
+ liability obligations and/or rights consistent with this License.
169
+ However, in accepting such obligations, You may act only on Your
170
+ own behalf and on Your sole responsibility, not on behalf of any
171
+ other Contributor, and only if You agree to indemnify, defend,
172
+ and hold each Contributor harmless for any liability incurred by,
173
+ or claims asserted against, such Contributor by reason of your
174
+ accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2026 Nextfreela Tech
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,450 @@
1
+ # Xpec MCP โ€” Specs as the Source of Truth for AI Coding Agents
2
+
3
+ Xpec is the home for product, feature, and architectural specs. The Xpec MCP server gives local AI coding agents (Claude Code, Cursor, VS Code, Zed, Windsurf, โ€ฆ) **read and write access to those specs**, so agents can plan, implement, and update features against the spec โ€” not against stale `docs/`, hallucinated APIs, or whatever the model remembers from training.
4
+
5
+ ## โŒ Without Xpec MCP
6
+
7
+ Coding agents drift from your product's actual contracts. You get:
8
+
9
+ - โŒ Code that ships ahead of the spec, then quietly diverges
10
+ - โŒ Implementations that contradict ADRs nobody re-read
11
+ - โŒ Duplicate "RFC-2025-โ€ฆ" markdown files in the repo, none authoritative
12
+ - โŒ Specs updated only after the code lands, when nobody can challenge them
13
+
14
+ ## โœ… With Xpec MCP
15
+
16
+ The agent reads the **current** spec before writing code, and proposes spec changes through the same workflow a human reviewer approves.
17
+
18
+ ```
19
+ Implement the password-reset flow per the "auth/password-reset" spec.
20
+ Use the contracts and error codes from ยง4. If the spec is incomplete,
21
+ open a draft, fill it in, and request review before writing code.
22
+ ```
23
+
24
+ ```
25
+ What ADRs apply to background jobs in this product? Read them, then
26
+ critique my proposed worker change against them.
27
+ ```
28
+
29
+ The agent calls `read_specification`, `list_open_questions`, `start_new_version`, `update_specification_section`, `request_review` โ€” and you stay in control: **a human still marks the draft Reviewed in the Xpec UI**.
30
+
31
+ ## ๐Ÿ“š Concepts
32
+
33
+ - **Workspace** โ€” top-level container. Contains member Products plus its own Workspace-scoped specs (e.g., cross-product ADRs).
34
+ - **Product** โ€” a single product or service. Holds the feature, UX, and architecture specs that govern its codebase.
35
+ - **Specification** โ€” Markdown document with status (`Draft` โ†’ `Needs Review` โ†’ `Reviewed`), open questions, and a version history.
36
+ - **Binding** โ€” a `.xpec.json` at the repo root binds the local checkout to a Workspace and/or Product, so agents don't have to pass ids on every call.
37
+
38
+ See `xpec.app` for the dashboard and to mint a token.
39
+
40
+ ## ๐Ÿ› ๏ธ Installation
41
+
42
+ ### Requirements
43
+
44
+ - **Node.js โ‰ฅ 20.11**
45
+ - An MCP-compatible client (Claude Code, Cursor, VS Code, Windsurf, Zed, Claude Desktop, โ€ฆ)
46
+ - An **Xpec Personal Access Token** โ€” generate one at `https://xpec.app/settings/developer`
47
+ - A repo with a `.xpec.json` file (or `XPEC_WORKSPACE_ID` / `XPEC_PRODUCT_ID` env vars). See [Binding the workspace](#binding-the-workspace) below.
48
+
49
+ ### **Install in Claude Code**
50
+
51
+ Run this command. See the [Claude Code MCP docs](https://docs.anthropic.com/en/docs/claude-code/mcp) for more info.
52
+
53
+ ```bash
54
+ claude mcp add --scope user \
55
+ -e XPEC_API_TOKEN=YOUR_TOKEN \
56
+ xpec -- npx -y @nextfreelatech/xpec-mcp
57
+ ```
58
+
59
+ Drop `--scope user` to install only for the current project.
60
+
61
+ To add a rule so the agent always reads the spec first, append the snippet from [Add a rule](#add-a-rule) below to your `CLAUDE.md`.
62
+
63
+ ### **Install in Cursor**
64
+
65
+ Add this to `~/.cursor/mcp.json` (global) or `.cursor/mcp.json` (project). See the [Cursor MCP docs](https://docs.cursor.com/context/model-context-protocol).
66
+
67
+ ```json
68
+ {
69
+ "mcpServers": {
70
+ "xpec": {
71
+ "command": "npx",
72
+ "args": ["-y", "@nextfreelatech/xpec-mcp"],
73
+ "env": {
74
+ "XPEC_API_TOKEN": "YOUR_TOKEN"
75
+ }
76
+ }
77
+ }
78
+ }
79
+ ```
80
+
81
+ ### **Install in VS Code**
82
+
83
+ See the [VS Code MCP docs](https://code.visualstudio.com/docs/copilot/chat/mcp-servers).
84
+
85
+ ```json
86
+ "mcp": {
87
+ "servers": {
88
+ "xpec": {
89
+ "type": "stdio",
90
+ "command": "npx",
91
+ "args": ["-y", "@nextfreelatech/xpec-mcp"],
92
+ "env": {
93
+ "XPEC_API_TOKEN": "YOUR_TOKEN"
94
+ }
95
+ }
96
+ }
97
+ }
98
+ ```
99
+
100
+ ### **Install in Windsurf**
101
+
102
+ Add this to your Windsurf MCP config. See the [Windsurf MCP docs](https://docs.windsurf.com/windsurf/cascade/mcp).
103
+
104
+ ```json
105
+ {
106
+ "mcpServers": {
107
+ "xpec": {
108
+ "command": "npx",
109
+ "args": ["-y", "@nextfreelatech/xpec-mcp"],
110
+ "env": {
111
+ "XPEC_API_TOKEN": "YOUR_TOKEN"
112
+ }
113
+ }
114
+ }
115
+ }
116
+ ```
117
+
118
+ ### **Install in Zed**
119
+
120
+ Add this to your Zed `settings.json`. See the [Zed Context Server docs](https://zed.dev/docs/assistant/context-servers).
121
+
122
+ ```json
123
+ {
124
+ "context_servers": {
125
+ "Xpec": {
126
+ "source": "custom",
127
+ "command": "npx",
128
+ "args": ["-y", "@nextfreelatech/xpec-mcp"],
129
+ "env": {
130
+ "XPEC_API_TOKEN": "YOUR_TOKEN"
131
+ }
132
+ }
133
+ }
134
+ }
135
+ ```
136
+
137
+ ### **Install in Claude Desktop**
138
+
139
+ Edit your `claude_desktop_config.json`. See the [Claude Desktop MCP docs](https://modelcontextprotocol.io/quickstart/user).
140
+
141
+ ```json
142
+ {
143
+ "mcpServers": {
144
+ "xpec": {
145
+ "command": "npx",
146
+ "args": ["-y", "@nextfreelatech/xpec-mcp"],
147
+ "env": {
148
+ "XPEC_API_TOKEN": "YOUR_TOKEN"
149
+ }
150
+ }
151
+ }
152
+ }
153
+ ```
154
+
155
+ ### **Install in OpenAI Codex**
156
+
157
+ See the [OpenAI Codex repo](https://github.com/openai/codex) for more on the MCP configuration format. Codex reads `~/.codex/config.toml`.
158
+
159
+ #### Codex Local Server Connection (stdio)
160
+
161
+ ```toml
162
+ [mcp_servers.xpec]
163
+ command = "npx"
164
+ args = ["-y", "@nextfreelatech/xpec-mcp"]
165
+ env = { XPEC_API_TOKEN = "YOUR_TOKEN" }
166
+ startup_timeout_ms = 20_000
167
+ ```
168
+
169
+ #### Codex Remote Server Connection (HTTP)
170
+
171
+ First, run the server (see [Running over HTTP](#running-over-http-hosted-agents)). Then point Codex at it:
172
+
173
+ ```toml
174
+ [mcp_servers.xpec]
175
+ url = "http://127.0.0.1:3030/mcp"
176
+ http_headers = { "Authorization" = "Bearer YOUR_TOKEN" }
177
+ ```
178
+
179
+ > Optional troubleshooting โ€” only if Codex reports startup "request timed out" or "program not found". Most users can ignore this.
180
+ >
181
+ > - First try: bump `startup_timeout_ms` to `40_000`.
182
+ > - **Windows** quick fix (absolute `npx` path + explicit env):
183
+ >
184
+ > ```toml
185
+ > [mcp_servers.xpec]
186
+ > command = "C:\\Users\\yourname\\AppData\\Roaming\\npm\\npx.cmd"
187
+ > args = ["-y", "@nextfreelatech/xpec-mcp"]
188
+ > env = {
189
+ > XPEC_API_TOKEN = "YOUR_TOKEN",
190
+ > SystemRoot = "C:\\Windows",
191
+ > APPDATA = "C:\\Users\\yourname\\AppData\\Roaming"
192
+ > }
193
+ > startup_timeout_ms = 40_000
194
+ > ```
195
+ >
196
+ > - **macOS** quick fix (call Node directly with the installed package's entry point):
197
+ >
198
+ > ```toml
199
+ > [mcp_servers.xpec]
200
+ > command = "/Users/yourname/.nvm/versions/node/v22.14.0/bin/node"
201
+ > args = [
202
+ > "/Users/yourname/.nvm/versions/node/v22.14.0/lib/node_modules/@nextfreelatech/xpec-mcp/dist/cli.js",
203
+ > "--stdio"
204
+ > ]
205
+ > env = { XPEC_API_TOKEN = "YOUR_TOKEN" }
206
+ > ```
207
+ >
208
+ > Replace `yourname` with your OS username. On Windows, setting `APPDATA` and `SystemRoot` is essential because `npx` requires them but some Codex builds don't pass them through.
209
+
210
+ ### **Using Bun or Deno**
211
+
212
+ Any client that launches an MCP server via `command + args` can swap `npx` for an alternative runtime.
213
+
214
+ #### Bun
215
+
216
+ ```json
217
+ {
218
+ "mcpServers": {
219
+ "xpec": {
220
+ "command": "bunx",
221
+ "args": ["-y", "@nextfreelatech/xpec-mcp"],
222
+ "env": { "XPEC_API_TOKEN": "YOUR_TOKEN" }
223
+ }
224
+ }
225
+ }
226
+ ```
227
+
228
+ #### Deno
229
+
230
+ ```json
231
+ {
232
+ "mcpServers": {
233
+ "xpec": {
234
+ "command": "deno",
235
+ "args": [
236
+ "run",
237
+ "--allow-env",
238
+ "--allow-net",
239
+ "--allow-read",
240
+ "npm:@nextfreelatech/xpec-mcp"
241
+ ],
242
+ "env": { "XPEC_API_TOKEN": "YOUR_TOKEN" }
243
+ }
244
+ }
245
+ }
246
+ ```
247
+
248
+ ### **Install in Windows**
249
+
250
+ `npx` on Windows usually needs to be invoked via `cmd /c`:
251
+
252
+ ```json
253
+ {
254
+ "mcpServers": {
255
+ "xpec": {
256
+ "command": "cmd",
257
+ "args": ["/c", "npx", "-y", "@nextfreelatech/xpec-mcp"],
258
+ "env": { "XPEC_API_TOKEN": "YOUR_TOKEN" }
259
+ }
260
+ }
261
+ }
262
+ ```
263
+
264
+ ### Running over HTTP (hosted agents)
265
+
266
+ For agents that consume MCP over HTTP/SSE rather than stdio, run the server explicitly:
267
+
268
+ ```bash
269
+ XPEC_API_TOKEN=YOUR_TOKEN \
270
+ npx -y @nextfreelatech/xpec-mcp --http --port 3030 --cors-origin https://your-agent.example.com
271
+ ```
272
+
273
+ Then point your hosted agent at `http://<host>:3030/mcp`.
274
+
275
+ ## ๐Ÿ”— Binding the workspace
276
+
277
+ The MCP server is **bound** to a Workspace and/or a Product so tools like `list_specifications` work without passing ids every call.
278
+
279
+ Drop a `.xpec.json` at your repo root:
280
+
281
+ ```json
282
+ {
283
+ "workspaceId": "ws_โ€ฆ",
284
+ "productId": "prd_โ€ฆ"
285
+ }
286
+ ```
287
+
288
+ Either field is optional:
289
+
290
+ | Configuration | Effective mode | What works |
291
+ | --------------------------- | ------------------- | ------------------------------------------------------------------------- |
292
+ | `workspaceId` + `productId` | `workspace+product` | Everything; defaults to the Product's specs |
293
+ | `workspaceId` only | `workspace` | Workspace-scoped specs + cross-Product search |
294
+ | `productId` only | `product` | Product-scoped specs (orphan / pre-aggregation Products work this way) |
295
+ | Neither | `discovery` | Only `list_workspaces` / `list_products` โ€” bind first to do anything else |
296
+
297
+ You can also use environment variables: `XPEC_WORKSPACE_ID`, `XPEC_PRODUCT_ID`. The file wins over env vars when both are present.
298
+
299
+ ## โœ… Verify the install
300
+
301
+ ```bash
302
+ XPEC_API_TOKEN=YOUR_TOKEN npx -y @nextfreelatech/xpec-mcp --check
303
+ ```
304
+
305
+ Prints `OK: https://xpec.app reachable, N product(s) visible.` on success, or a structured error code (`AUTH_REQUIRED`, `PRODUCT_NOT_BOUND`, โ€ฆ) and remediation when something is off. Add `--json` for machine-readable output.
306
+
307
+ ## ๐Ÿ”จ Available Tools
308
+
309
+ All tools take ids as strings. Bound Workspace/Product ids are inferred from `.xpec.json` unless overridden in the call.
310
+
311
+ ### Read tools
312
+
313
+ | Tool | Purpose |
314
+ | ----------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
315
+ | `list_workspaces` | List Workspaces visible to the token. Use when you don't yet know which Workspace to bind. |
316
+ | `list_products` | List Products. With a Workspace binding, returns its member Products; without, returns orphan Products. |
317
+ | `read_workspace` | Workspace metadata: name, description, type, archived state. |
318
+ | `read_product` | Product metadata: name, description, `specificationManagementType`, member-of Workspace. |
319
+ | `list_specifications` | List specs in scope. Filters: `type` (BUSINESS / UX / DESIGN_SYSTEM / DOCUMENT), `status` (DRAFT / GENERATING / NEEDS_REVIEW / REVIEWED), `folder`, `tags`, `query`. Cursor-paginated. |
320
+ | `search_specifications` | Lexical full-text search across spec titles and content. Workspace bindings search the Workspace plus every member Product; results carry a `scope` discriminator. |
321
+ | `read_specification` | Current Markdown body of a spec, plus status and OCC `version`. Use `format="rendered"` to strip open-question and assumption markers. |
322
+ | `list_specification_versions` | Reviewed snapshots of a spec, newest first. |
323
+ | `read_specification_version` | Full Markdown of a specific approved revision. Pair with `list_specification_versions` to diff history against current. |
324
+ | `list_open_questions` | Questions and assumptions attached to a spec. Resolved/dismissed items are excluded unless `includeResolved=true`. |
325
+
326
+ ### Write tools
327
+
328
+ | Tool | Purpose |
329
+ | ------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
330
+ | `start_new_version` | Open a new Draft of a Reviewed spec. Required before any write tool on a published spec. No-op when the spec is already a Draft (returns `hint="already_draft"`). |
331
+ | `update_specification_content` | Replace the full Markdown body of a Draft. OCC-guarded โ€” pass the `version` from your most recent `read_specification`. Returns `STALE_VERSION` (409) if another writer landed first; re-read and retry. |
332
+ | `update_specification_section` | Replace one heading-bound section (`sectionPath="## Pricing"`). OCC-guarded. Records a before-image revision. |
333
+ | `request_review` | Move a Draft to `Needs Review` for a human to approve. Rejected with `OPEN_QUESTIONS_PRESENT` if questions remain โ€” surface them to the user first. |
334
+ | `discard_draft` | Roll a Draft (or Needs Review) back to its last approved version. Rejected on specs that have never been approved. |
335
+ | `create_free_specification` | Create a new Markdown spec in the bound Free product. Path uniqueness is enforced. Rejected with `PRODUCT_TYPE_MISMATCH` on Web Application Products โ€” use `start_new_version` on a structured spec. |
336
+
337
+ > **Note** โ€” the agent never calls "mark reviewed". Approval stays a human action in the Xpec UI. The MCP can only nudge a draft to `Needs Review`.
338
+
339
+ ## ๐Ÿ›Ÿ Tips
340
+
341
+ ### Add a rule
342
+
343
+ Once installed, tell your agent to consult Xpec before writing code. Drop this into `CLAUDE.md`, `.cursorrules`, `.windsurfrules`, or your client's equivalent:
344
+
345
+ ```
346
+ Before writing or updating code, planning a feature, or making an architectural
347
+ choice, search and read the relevant Xpec specs via the xpec
348
+ MCP. Treat them as the source of truth. If a spec is wrong or incomplete, open
349
+ a draft (start_new_version), update it (update_specification_section), and
350
+ request review (request_review) before implementing. Never duplicate spec
351
+ content into the repo.
352
+ ```
353
+
354
+ The repo's `CLAUDE.md` is a good place for project-specific guidance.
355
+
356
+ ### Use ids when you have them
357
+
358
+ If you already know the spec id, pass it directly to skip the search:
359
+
360
+ ```
361
+ Read the "auth/password-reset" spec and reconcile ยง4 with the current
362
+ src/server/auth/reset.ts implementation. specId=spec_01Hโ€ฆ
363
+ ```
364
+
365
+ ### Self-hosted / dev API
366
+
367
+ Override the API base URL at the binding:
368
+
369
+ ```json
370
+ {
371
+ "apiUrl": "http://localhost:3000",
372
+ "workspaceId": "ws_local_dev",
373
+ "productId": "prd_local_dev"
374
+ }
375
+ ```
376
+
377
+ `http://localhost` is allowed without `--allow-insecure`. For any other non-HTTPS host, pass `--allow-insecure` (intended for self-hosted dev only).
378
+
379
+ ### HTTPS proxy
380
+
381
+ Standard `https_proxy` / `HTTPS_PROXY` env vars are honoured.
382
+
383
+ ## ๐Ÿ’ป Development
384
+
385
+ ```bash
386
+ # From the monorepo root
387
+ npm install
388
+ npm run build
389
+ ```
390
+
391
+ Run the built server:
392
+
393
+ ```bash
394
+ XPEC_API_TOKEN=YOUR_TOKEN node dist/cli.js
395
+ ```
396
+
397
+ ### CLI Arguments
398
+
399
+ `xpec-mcp` accepts:
400
+
401
+ - `serve` _(default)_ โ€” run the MCP server. Stdio unless `--http` is set.
402
+ - `--check` โ€” verify token + API URL and exit `0`/`1`. Pair with `--json` for scripting.
403
+ - `--help`, `-h` โ€” usage.
404
+ - `--stdio` โ€” run over stdio (default; for desktop agents).
405
+ - `--http` โ€” run as an HTTP/SSE server (for hosted agents).
406
+ - `--port <n>` โ€” port for `--http` (default `3030`).
407
+ - `--host <addr>` โ€” host for `--http` (default `127.0.0.1`).
408
+ - `--cors-origin <o>` โ€” origin to allow (repeatable). Without this, cross-origin browser requests are rejected.
409
+ - `--api-url <url>` โ€” override the Xpec API base URL.
410
+ - `--allow-insecure` โ€” permit a non-HTTPS `apiUrl` (self-hosted dev only).
411
+
412
+ ### Environment Variables
413
+
414
+ | Variable | Purpose |
415
+ | ------------------- | --------------------------------------------------------------- |
416
+ | `XPEC_API_TOKEN` | **Required.** Personal Access Token from `/settings/developer`. |
417
+ | `XPEC_API_URL` | Override the API base URL. Default `https://xpec.app`. |
418
+ | `XPEC_WORKSPACE_ID` | Default Workspace binding when no `.xpec.json` is present. |
419
+ | `XPEC_PRODUCT_ID` | Default Product binding when no `.xpec.json` is present. |
420
+ | `XPEC_TELEMETRY` | Set to `0` to disable anonymous telemetry. |
421
+ | `XPEC_LOG_LEVEL` | `debug` \| `info` \| `warn` \| `error` (default `info`). |
422
+
423
+ The `--api-url` CLI flag takes precedence over `XPEC_API_URL`. The `.xpec.json` `apiUrl` field falls between the two.
424
+
425
+ ### Testing with MCP Inspector
426
+
427
+ ```bash
428
+ XPEC_API_TOKEN=YOUR_TOKEN \
429
+ npx -y @modelcontextprotocol/inspector npx @nextfreelatech/xpec-mcp
430
+ ```
431
+
432
+ ## ๐Ÿšจ Troubleshooting
433
+
434
+ **`AUTH_REQUIRED` / 401 from every tool** โ€” token is missing, expired, or revoked. Mint a new one at `/settings/developer` and update your client's `env`.
435
+
436
+ **`PRODUCT_NOT_BOUND` / `WORKSPACE_NOT_BOUND`** โ€” the tool needs a binding the session doesn't have. Either pass `productId` / `workspaceId` explicitly, or add it to `.xpec.json` (see [Binding the workspace](#binding-the-workspace)).
437
+
438
+ **`STALE_VERSION` from `update_specification_*`** โ€” another writer landed between your read and your write. Re-call `read_specification` to get the current `version`, then retry.
439
+
440
+ **`OPEN_QUESTIONS_PRESENT` from `request_review`** โ€” call `list_open_questions` first, resolve them in the spec, then retry.
441
+
442
+ **Legacy `.xpec.json` shape rejected at startup** โ€” the binding format changed; the CLI prints a remediation pointing to the new shape. Update the file.
443
+
444
+ **`ERR_MODULE_NOT_FOUND` under `npx`** โ€” try `bunx` instead. It often resolves stale npm caches.
445
+
446
+ **Plain-HTTP `apiUrl`** โ€” only `localhost` / `127.0.0.1` / `::1` are allowed by default. For any other host, pass `--allow-insecure` (self-hosted dev only).
447
+
448
+ ## ๐Ÿ“„ License
449
+
450
+ [Apache License 2.0](./LICENSE) ยฉ Nextfreela Tech.