pattern-mcp 0.14.1 → 0.15.0
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/README.md +68 -60
- package/dist/client-connect.js +56 -17
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -15,22 +15,22 @@ design reference.
|
|
|
15
15
|
|
|
16
16
|
[Website](https://usepattern.sh) · [npm](https://www.npmjs.com/package/pattern-mcp) · [Report an issue](https://github.com/donaldrichard19-LVD/pattern-mcp/issues/new/choose)
|
|
17
17
|
|
|
18
|
-
**Current release: v0.
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
18
|
+
**Current release: v0.15.0** — `npx pattern-mcp init` is now the first
|
|
19
|
+
and only command shown for getting started, everywhere (this README
|
|
20
|
+
and the website); bare `npx pattern-mcp` is documented as the server
|
|
21
|
+
command your client uses, not something to run yourself. The connect
|
|
22
|
+
wizard also no longer asks just once: if you run Pattern bare in your
|
|
23
|
+
own terminal and skip or miss it, it keeps offering on every later run
|
|
24
|
+
until it can actually confirm a client is connected, instead of going
|
|
25
|
+
silent forever after the first try. Previously: v0.14.1 made the
|
|
26
|
+
crash/exit telemetry added in v0.14.0 (`pattern_cli_exited`) register
|
|
27
|
+
before any of this file's own module-level code runs, and tagged both
|
|
28
|
+
it and `pattern_cli_started` with the running package version, so a
|
|
29
|
+
crash right around a release can be tied to the old or new binary. Before
|
|
30
|
+
that: v0.14.0 made a crash on startup diagnosable instead of silent,
|
|
31
|
+
warned at startup if `ANTHROPIC_API_KEY` is missing or clearly
|
|
32
|
+
malformed instead of only surfacing a raw 401 mid-call, and added one
|
|
33
|
+
respectful retry on a 429 (honoring `Retry-After`). See
|
|
34
34
|
[Connect Pattern to your MCP client](#connect-pattern-to-your-mcp-client)
|
|
35
35
|
for more details.
|
|
36
36
|
|
|
@@ -50,11 +50,22 @@ for more details.
|
|
|
50
50
|
## Install
|
|
51
51
|
|
|
52
52
|
```bash
|
|
53
|
-
npx pattern-mcp
|
|
53
|
+
npx pattern-mcp init
|
|
54
54
|
```
|
|
55
55
|
|
|
56
|
-
|
|
57
|
-
|
|
56
|
+
This is the only command you run yourself. It downloads Pattern,
|
|
57
|
+
detects which MCP client(s) you have (Claude Code, Claude Desktop,
|
|
58
|
+
Cursor, or Codex CLI), connects each one for you, and offers to add
|
|
59
|
+
your Anthropic API key. See [Quick Start](#quick-start) below for what it
|
|
60
|
+
does step by step, or
|
|
61
|
+
[Connect Pattern to your MCP client](#connect-pattern-to-your-mcp-client)
|
|
62
|
+
if you'd rather connect a client by hand.
|
|
63
|
+
|
|
64
|
+
`npx pattern-mcp` on its own (no `init`) is the server command your MCP
|
|
65
|
+
client will use once connected -- running it yourself in a bare
|
|
66
|
+
terminal starts a real process that just sits there waiting for a
|
|
67
|
+
client, since nothing has told it to connect to one yet. Prefer `init`
|
|
68
|
+
above for getting started.
|
|
58
69
|
|
|
59
70
|
## What Pattern Does
|
|
60
71
|
|
|
@@ -224,14 +235,40 @@ threshold.
|
|
|
224
235
|
|
|
225
236
|
## Quick Start
|
|
226
237
|
|
|
227
|
-
### 1. Install
|
|
238
|
+
### 1. Install and connect
|
|
228
239
|
|
|
229
240
|
```bash
|
|
230
|
-
npx pattern-mcp
|
|
241
|
+
npx pattern-mcp init
|
|
231
242
|
```
|
|
232
243
|
|
|
233
|
-
|
|
234
|
-
|
|
244
|
+
This is the only command you need to run yourself -- `npx` downloads
|
|
245
|
+
`pattern-mcp` on demand, then `init` detects which clients you have
|
|
246
|
+
installed and offers to connect each one:
|
|
247
|
+
|
|
248
|
+
- **Claude Code** -- runs `claude mcp add` for you (asks whether to make
|
|
249
|
+
Pattern available in every project or just this one); skips if already
|
|
250
|
+
connected (`claude mcp list` already shows it).
|
|
251
|
+
- **Claude Desktop** and **Cursor** -- merges a `pattern` entry into the
|
|
252
|
+
client's own config file, showing the exact change before writing it
|
|
253
|
+
and never touching any other server already configured there.
|
|
254
|
+
- **Codex CLI** -- prints the config snippet to add by hand (Codex's
|
|
255
|
+
config is TOML; this doesn't auto-edit it).
|
|
256
|
+
|
|
257
|
+
Optionally pastes your `ANTHROPIC_API_KEY` into whichever configs you set
|
|
258
|
+
up (visible in plain text as you type it, and in the files it writes) --
|
|
259
|
+
press Enter to skip and add it yourself later, see
|
|
260
|
+
[step 2](#2-add-your-anthropic-api-key) below. Run non-interactively with
|
|
261
|
+
`--yes` (skips the API key prompt entirely, accepts every detected
|
|
262
|
+
client).
|
|
263
|
+
|
|
264
|
+
If `init` doesn't detect your client, or you'd rather set it up by
|
|
265
|
+
hand, see [Connect Pattern to your MCP client](#connect-pattern-to-your-mcp-client)
|
|
266
|
+
below for the same configs, per client, done manually. The server
|
|
267
|
+
command either way is `npx pattern-mcp` -- this is what your client's
|
|
268
|
+
config launches; you shouldn't need to run it yourself. If you do run
|
|
269
|
+
it bare in your own terminal (e.g. to double check the install), it
|
|
270
|
+
will just sit there waiting for a client and periodically remind you
|
|
271
|
+
to run `init` -- that's expected, not a hang.
|
|
235
272
|
|
|
236
273
|
<details>
|
|
237
274
|
<summary>Build from source instead</summary>
|
|
@@ -243,14 +280,15 @@ npm install
|
|
|
243
280
|
npm run build
|
|
244
281
|
```
|
|
245
282
|
|
|
246
|
-
Use `node /absolute/path/to/pattern-mcp/dist/index.js`
|
|
247
|
-
|
|
283
|
+
Use `node /absolute/path/to/pattern-mcp/dist/index.js` in place of
|
|
284
|
+
`npx pattern-mcp` everywhere in this README, including inside `init`'s
|
|
285
|
+
own generated client configs.
|
|
248
286
|
|
|
249
287
|
</details>
|
|
250
288
|
|
|
251
289
|
### 2. Add your Anthropic API key
|
|
252
290
|
|
|
253
|
-
Pattern requires:
|
|
291
|
+
Skipped it above, or want to change it? Pattern requires:
|
|
254
292
|
|
|
255
293
|
```
|
|
256
294
|
ANTHROPIC_API_KEY
|
|
@@ -265,40 +303,10 @@ Claude Pro or Max subscription does not include API usage.
|
|
|
265
303
|
|
|
266
304
|
### Connect Pattern to your MCP client
|
|
267
305
|
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
```
|
|
274
|
-
npx pattern-mcp
|
|
275
|
-
```
|
|
276
|
-
|
|
277
|
-
#### Automatic setup
|
|
278
|
-
|
|
279
|
-
```bash
|
|
280
|
-
npx pattern-mcp init
|
|
281
|
-
```
|
|
282
|
-
|
|
283
|
-
Detects which clients are installed and offers to connect each one:
|
|
284
|
-
|
|
285
|
-
- **Claude Code** -- runs `claude mcp add` for you (asks whether to make
|
|
286
|
-
Pattern available in every project or just this one); skips if already
|
|
287
|
-
connected (`claude mcp list` already shows it).
|
|
288
|
-
- **Claude Desktop** and **Cursor** -- merges a `pattern` entry into the
|
|
289
|
-
client's own config file, showing the exact change before writing it
|
|
290
|
-
and never touching any other server already configured there.
|
|
291
|
-
- **Codex CLI** -- prints the config snippet to add by hand (Codex's
|
|
292
|
-
config is TOML; this doesn't auto-edit it).
|
|
293
|
-
|
|
294
|
-
Optionally pastes your `ANTHROPIC_API_KEY` into whichever configs you set
|
|
295
|
-
up (visible in plain text as you type it, and in the files it writes) --
|
|
296
|
-
press Enter to skip and add it yourself later instead. Run
|
|
297
|
-
non-interactively with `--yes` (skips the API key prompt entirely,
|
|
298
|
-
accepts every detected client).
|
|
299
|
-
|
|
300
|
-
If you'd rather do it by hand, or `init` didn't detect your client, the
|
|
301
|
-
per-client instructions below cover the same configs manually.
|
|
306
|
+
[Step 1](#1-install-and-connect) above (`npx pattern-mcp init`) does
|
|
307
|
+
this automatically for every client it detects -- the sections below
|
|
308
|
+
are the same configs done by hand, for a client `init` didn't detect,
|
|
309
|
+
or if you'd simply rather edit the config yourself.
|
|
302
310
|
|
|
303
311
|
#### Claude Code
|
|
304
312
|
|
package/dist/client-connect.js
CHANGED
|
@@ -127,6 +127,28 @@ async function mergeServerConfig(label, path, apiKey, options) {
|
|
|
127
127
|
writeFileSync(path, JSON.stringify(merged, null, 2) + "\n", "utf8");
|
|
128
128
|
console.log(`Written. Restart ${label} to pick it up.`);
|
|
129
129
|
}
|
|
130
|
+
function clientConfigHasPattern(path) {
|
|
131
|
+
if (!path)
|
|
132
|
+
return false;
|
|
133
|
+
const { config } = readJsonConfig(path);
|
|
134
|
+
return Boolean(config.mcpServers?.pattern);
|
|
135
|
+
}
|
|
136
|
+
// Best-effort, read-only check across every client Pattern knows how to
|
|
137
|
+
// detect a prior successful setup for -- used to decide whether to keep
|
|
138
|
+
// offering the connect wizard on a later bare run (see
|
|
139
|
+
// offerClientConnectSetupOnce below), instead of asking only once ever
|
|
140
|
+
// regardless of outcome. Codex is deliberately excluded: its config is
|
|
141
|
+
// TOML, which this project never parses or writes (see
|
|
142
|
+
// offerCodexInstructions), so there's no way to confirm a Codex-only
|
|
143
|
+
// setup from here. That means a Codex-only user keeps getting offered
|
|
144
|
+
// the wizard -- a false negative, which is the safe failure mode (asks
|
|
145
|
+
// again when already connected) rather than a false positive (goes quiet
|
|
146
|
+
// when it isn't).
|
|
147
|
+
export function isAnyClientConnected(root) {
|
|
148
|
+
return (claudeCodeAlreadyConnected() ||
|
|
149
|
+
clientConfigHasPattern(claudeDesktopConfigPath()) ||
|
|
150
|
+
clientConfigHasPattern(join(root, ".cursor", "mcp.json")));
|
|
151
|
+
}
|
|
130
152
|
// Claude Desktop isn't shipped on Linux -- there's no config path to
|
|
131
153
|
// even guess at there, so this target is simply not offered on that
|
|
132
154
|
// platform rather than writing a file no client will ever read.
|
|
@@ -225,36 +247,53 @@ export async function runConnect(root, options) {
|
|
|
225
247
|
// Option 1/#1 from the activation-funnel discussion: piggybacks on the
|
|
226
248
|
// same first-run moment as the telemetry and enforcement-boundary
|
|
227
249
|
// notices (see telemetry.ts's printTelemetryNoticeOnce, which states the
|
|
228
|
-
// stdin constraint first). Always prints
|
|
229
|
-
//
|
|
230
|
-
//
|
|
231
|
-
//
|
|
232
|
-
//
|
|
233
|
-
//
|
|
250
|
+
// stdin constraint first). Always prints the full notice once, ever --
|
|
251
|
+
// including when a real MCP client has spawned this as a subprocess,
|
|
252
|
+
// where it's genuinely irrelevant but harmless, since the notice is
|
|
253
|
+
// gated on a marker file the same as the others.
|
|
254
|
+
//
|
|
255
|
+
// The interactive "set it up now?" prompt is different: it used to be
|
|
256
|
+
// gated on that same one-time marker, so a human who ignored or missed
|
|
257
|
+
// it on the very first bare run never saw it again -- a permanent
|
|
258
|
+
// drop-off with no second chance, found while mapping the new-install
|
|
259
|
+
// journey (see project_pattern_activation_funnel memory). It now keeps
|
|
260
|
+
// reappearing on every bare TTY run -- a human running `npx pattern-mcp`
|
|
261
|
+
// in their own shell, never a real client's spawned subprocess -- for as
|
|
262
|
+
// long as isAnyClientConnected() can't confirm a real connection exists
|
|
263
|
+
// yet. This is the concrete fix for "don't rely on the user to figure
|
|
264
|
+
// out how to connect": Pattern keeps offering, not just once, until it
|
|
265
|
+
// can verify success, or until PATTERN_NO_CONNECT_NOTICE opts out.
|
|
234
266
|
const CONNECT_NOTICE_PATH = process.env.PATTERN_CONNECT_NOTICE_PATH ?? join(homedir(), ".pattern", "connect_notice_shown");
|
|
235
267
|
export async function offerClientConnectSetupOnce(root) {
|
|
236
268
|
if (process.env.PATTERN_NO_CONNECT_NOTICE)
|
|
237
269
|
return;
|
|
270
|
+
let noticeAlreadyShown = true;
|
|
238
271
|
try {
|
|
239
272
|
readFileSync(CONNECT_NOTICE_PATH, "utf8");
|
|
240
|
-
return;
|
|
241
273
|
}
|
|
242
274
|
catch {
|
|
243
|
-
|
|
275
|
+
noticeAlreadyShown = false;
|
|
244
276
|
}
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
277
|
+
if (!noticeAlreadyShown) {
|
|
278
|
+
console.error(["", "Pattern -- one-time setup notice (this will not print again)", connectInstructionsText(), ""].join("\n"));
|
|
279
|
+
try {
|
|
280
|
+
mkdirSync(dirname(CONNECT_NOTICE_PATH), { recursive: true });
|
|
281
|
+
writeFileSync(CONNECT_NOTICE_PATH, new Date().toISOString(), "utf8");
|
|
282
|
+
}
|
|
283
|
+
catch {
|
|
284
|
+
// Couldn't persist the marker -- worst case this prints again next
|
|
285
|
+
// run. Never blocks startup over it, same as the other notices.
|
|
286
|
+
}
|
|
253
287
|
}
|
|
254
288
|
if (!process.stdin.isTTY)
|
|
255
289
|
return;
|
|
290
|
+
if (isAnyClientConnected(root))
|
|
291
|
+
return;
|
|
256
292
|
try {
|
|
257
|
-
const
|
|
293
|
+
const question = noticeAlreadyShown
|
|
294
|
+
? "No MCP client is connected to Pattern yet -- run the connect wizard now?"
|
|
295
|
+
: "Run the connect wizard now?";
|
|
296
|
+
const setUpNow = await confirm(question, { yes: false }, true);
|
|
258
297
|
if (setUpNow) {
|
|
259
298
|
await runConnect(root, { yes: false }); // closes the shared readline itself
|
|
260
299
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pattern-mcp",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.15.0",
|
|
4
4
|
"description": "MCP server that turns your design guidance into a checkable process -- evaluates UI components from external libraries (shadcn/ui, 21st.dev, ReUI) or your own registered design system against a requirements checklist, then tells the agent whether to reuse an existing component or build one from a concrete design reference.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|