pattern-mcp 0.9.0 → 0.9.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/dist/index.js CHANGED
@@ -36,8 +36,12 @@ import { createHash, randomUUID } from "node:crypto";
36
36
  import { appendFileSync, existsSync, mkdirSync, readdirSync, readFileSync, statSync, writeFileSync } from "node:fs";
37
37
  import { homedir } from "node:os";
38
38
  import { dirname, extname, isAbsolute, join, relative, resolve } from "node:path";
39
+ import { fileURLToPath } from "node:url";
39
40
  import { captureApiError, captureRecommendation, getClient as getPostHogClient, installId, printTelemetryNoticeOnce, shutdownTelemetry, TELEMETRY_ENABLED, } from "./telemetry.js";
40
41
  export const ANTHROPIC_API_KEY = process.env.ANTHROPIC_API_KEY;
42
+ // Only required for org-scoped keys (not tied to one workspace); unset for
43
+ // legacy workspace-scoped keys, which don't need it.
44
+ export const ANTHROPIC_WORKSPACE_ID = process.env.ANTHROPIC_WORKSPACE_ID;
41
45
  // Configurable so Sonnet vs. Haiku can be A/B tested without a code change.
42
46
  // Defaults to Sonnet 5. Try MODEL=claude-haiku-4-5-20251001 to test the
43
47
  // cheaper tier -- re-run the 5 validated test cases from the product brief
@@ -382,6 +386,7 @@ async function streamAnthropicMessage(body) {
382
386
  "content-type": "application/json",
383
387
  "x-api-key": ANTHROPIC_API_KEY,
384
388
  "anthropic-version": "2023-06-01",
389
+ ...(ANTHROPIC_WORKSPACE_ID ? { "anthropic-workspace-id": ANTHROPIC_WORKSPACE_ID } : {}),
385
390
  },
386
391
  body: JSON.stringify({ ...body, stream: true }),
387
392
  });
@@ -3338,7 +3343,12 @@ export function extractJson(text) {
3338
3343
  return text;
3339
3344
  return text.slice(start, end + 1);
3340
3345
  }
3341
- const server = new Server({ name: "pattern-mcp", version: "0.1.0" }, { capabilities: { tools: {} } });
3346
+ // Read from package.json rather than hardcoding, so $mcp_server_version in
3347
+ // PostHog's MCP tool-call analytics (and any client that reads the MCP
3348
+ // initialize response) reflects the version actually installed instead of
3349
+ // staying frozen at whatever it was when this line was first written.
3350
+ const PACKAGE_VERSION = JSON.parse(readFileSync(join(dirname(fileURLToPath(import.meta.url)), "..", "package.json"), "utf8")).version;
3351
+ const server = new Server({ name: "pattern-mcp", version: PACKAGE_VERSION }, { capabilities: { tools: {} } });
3342
3352
  // Standard MCP tool-call analytics (tool name, duration, success/failure,
3343
3353
  // unique installs/sessions) via PostHog's own MCP SDK -- separate from
3344
3354
  // this file's captureRecommendation()/captureApiError() calls, which carry
@@ -2,7 +2,7 @@
2
2
  // four independent calls. Deliberately separate from src/index.ts's own
3
3
  // fetch logic (which is tuned for the single bundled call) rather than
4
4
  // reused, since each stage here has a different tool/budget shape.
5
- import { ANTHROPIC_API_KEY, MODEL, extractJson, extractUrlsForDomain } from "../index.js";
5
+ import { ANTHROPIC_API_KEY, ANTHROPIC_WORKSPACE_ID, MODEL, extractJson, extractUrlsForDomain } from "../index.js";
6
6
  export async function callAnthropic({ systemPrompt, userMessage, tools, maxTokens = 4096 }) {
7
7
  if (!ANTHROPIC_API_KEY) {
8
8
  throw new Error("ANTHROPIC_API_KEY is not set. Export it in the environment running this pipeline.");
@@ -13,6 +13,7 @@ export async function callAnthropic({ systemPrompt, userMessage, tools, maxToken
13
13
  "content-type": "application/json",
14
14
  "x-api-key": ANTHROPIC_API_KEY,
15
15
  "anthropic-version": "2023-06-01",
16
+ ...(ANTHROPIC_WORKSPACE_ID ? { "anthropic-workspace-id": ANTHROPIC_WORKSPACE_ID } : {}),
16
17
  },
17
18
  body: JSON.stringify({
18
19
  model: MODEL,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pattern-mcp",
3
- "version": "0.9.0",
3
+ "version": "0.9.1",
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",