@tpsdev-ai/flair-mcp 0.48.0 → 0.49.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/dist/index.js CHANGED
@@ -44,6 +44,7 @@ import { FlairClient, FlairError } from "@tpsdev-ai/flair-client";
44
44
  import { z } from "zod";
45
45
  import { deriveActivity, postPresenceSafe, resolveHeartbeatIntervalMs, resolvePresenceTimeoutMs, shouldSendHeartbeat, } from "./presence.js";
46
46
  import { readEnvOrUnset, stripInterpolationLiteralsFromEnv } from "./env-guard.js";
47
+ import { serverInfo } from "./version.js";
47
48
  // ─── Error helpers ──────────────────────────────────────────────────────────
48
49
  function classifyError(err, flairUrl) {
49
50
  if (err instanceof FlairError) {
@@ -212,10 +213,7 @@ export async function runMcp() {
212
213
  postPresenceSafe(presenceFlair, activity, lastKnownTask, resolvePresenceTimeoutMs()).catch(() => { });
213
214
  }
214
215
  // ─── MCP Server ──────────────────────────────────────────────────────────────
215
- const server = new McpServer({
216
- name: "flair",
217
- version: "0.1.0",
218
- });
216
+ const server = new McpServer(serverInfo());
219
217
  // ─── Tools ───────────────────────────────────────────────────────────────────
220
218
  server.tool("memory_search", "Search memories by meaning. Understands temporal queries like 'what happened today'.", {
221
219
  query: z.string().describe("Search query — natural language, semantic matching"),
@@ -0,0 +1,28 @@
1
+ /**
2
+ * version.ts — the version advertised in MCP `initialize` `serverInfo`.
3
+ *
4
+ * `process.env.npm_package_version` is only populated inside `npm run`, so
5
+ * reading this package's own package.json relative to THIS running module is
6
+ * the only way to report the version of the code that's actually executing
7
+ * (same reason as resources/version.ts). Walk-by-name rather than a fixed
8
+ * number of `..` hops, matching src/lib/mcp-spec.ts: this file compiles to
9
+ * dist/version.js, tests import the .ts next to src/, and a hardcoded depth
10
+ * is one move away from silently advertising the wrong package — or "dev".
11
+ */
12
+ /** The published package whose version `initialize` must report. */
13
+ export declare const FLAIR_MCP_PACKAGE = "@tpsdev-ai/flair-mcp";
14
+ /** What we advertise when package.json cannot be read. */
15
+ export declare const UNKNOWN_VERSION = "dev";
16
+ /**
17
+ * Walk up from `startDir` looking for `@tpsdev-ai/flair-mcp`'s own package.json.
18
+ * Exported for tests, which need to exercise the not-found path without
19
+ * corrupting a real install.
20
+ */
21
+ export declare function resolvePackageVersionFrom(startDir: string): string;
22
+ /** This package's version — what `initialize` puts in `serverInfo.version`. */
23
+ export declare function resolvePackageVersion(): string;
24
+ /** The `serverInfo` object passed to `McpServer` (and thus returned on initialize). */
25
+ export declare function serverInfo(): {
26
+ name: "flair";
27
+ version: string;
28
+ };
@@ -0,0 +1,52 @@
1
+ /**
2
+ * version.ts — the version advertised in MCP `initialize` `serverInfo`.
3
+ *
4
+ * `process.env.npm_package_version` is only populated inside `npm run`, so
5
+ * reading this package's own package.json relative to THIS running module is
6
+ * the only way to report the version of the code that's actually executing
7
+ * (same reason as resources/version.ts). Walk-by-name rather than a fixed
8
+ * number of `..` hops, matching src/lib/mcp-spec.ts: this file compiles to
9
+ * dist/version.js, tests import the .ts next to src/, and a hardcoded depth
10
+ * is one move away from silently advertising the wrong package — or "dev".
11
+ */
12
+ import { readFileSync } from "node:fs";
13
+ import { dirname, join } from "node:path";
14
+ import { fileURLToPath } from "node:url";
15
+ /** The published package whose version `initialize` must report. */
16
+ export const FLAIR_MCP_PACKAGE = "@tpsdev-ai/flair-mcp";
17
+ /** What we advertise when package.json cannot be read. */
18
+ export const UNKNOWN_VERSION = "dev";
19
+ /**
20
+ * Walk up from `startDir` looking for `@tpsdev-ai/flair-mcp`'s own package.json.
21
+ * Exported for tests, which need to exercise the not-found path without
22
+ * corrupting a real install.
23
+ */
24
+ export function resolvePackageVersionFrom(startDir) {
25
+ let dir = startDir;
26
+ // 8 levels is far more than any real layout needs (dist/ → package root is 1)
27
+ // while still terminating on a pathological symlink loop.
28
+ for (let i = 0; i < 8; i++) {
29
+ try {
30
+ const pkg = JSON.parse(readFileSync(join(dir, "package.json"), "utf-8"));
31
+ if (pkg?.name === FLAIR_MCP_PACKAGE && typeof pkg.version === "string" && pkg.version) {
32
+ return pkg.version;
33
+ }
34
+ }
35
+ catch {
36
+ // No package.json here, or unreadable/malformed — keep walking.
37
+ }
38
+ const parent = dirname(dir);
39
+ if (parent === dir)
40
+ break;
41
+ dir = parent;
42
+ }
43
+ return process.env.npm_package_version ?? UNKNOWN_VERSION;
44
+ }
45
+ /** This package's version — what `initialize` puts in `serverInfo.version`. */
46
+ export function resolvePackageVersion() {
47
+ return resolvePackageVersionFrom(dirname(fileURLToPath(import.meta.url)));
48
+ }
49
+ /** The `serverInfo` object passed to `McpServer` (and thus returned on initialize). */
50
+ export function serverInfo() {
51
+ return { name: "flair", version: resolvePackageVersion() };
52
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tpsdev-ai/flair-mcp",
3
- "version": "0.48.0",
3
+ "version": "0.49.0",
4
4
  "description": "MCP server for Flair — persistent memory for Claude Code, Cursor, and any MCP client.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -28,7 +28,7 @@
28
28
  },
29
29
  "dependencies": {
30
30
  "@modelcontextprotocol/sdk": "1.27.1",
31
- "@tpsdev-ai/flair-client": "0.48.0",
31
+ "@tpsdev-ai/flair-client": "0.49.0",
32
32
  "zod": "4.3.6"
33
33
  },
34
34
  "license": "Apache-2.0",