@phi-longevity/mcp-server 0.1.0 → 0.3.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 +12 -5
- package/dist/index.js +22 -8
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -18,7 +18,10 @@ recommendation engine on **synthetic** biomarker panels.
|
|
|
18
18
|
```bash
|
|
19
19
|
npm install
|
|
20
20
|
npm run build
|
|
21
|
-
|
|
21
|
+
PHI_ENGINE_URL="https://us-central1-philongevity-aiapp-v2.cloudfunctions.net/runRecommendationsForBiomarkers" \
|
|
22
|
+
PHI_MIGRATION_SECRET="<server-side secret>" \
|
|
23
|
+
PHI_MCP_KEY="<published key>" \
|
|
24
|
+
node dist/index.js
|
|
22
25
|
```
|
|
23
26
|
|
|
24
27
|
### Claude Desktop config (`claude_desktop_config.json`)
|
|
@@ -29,7 +32,9 @@ PHI_MCP_KEY="phimcp_d29179fdd8b99b70a49ae26f434843cf" node dist/index.js
|
|
|
29
32
|
"command": "npx",
|
|
30
33
|
"args": ["-y", "@phi-longevity/mcp-server"],
|
|
31
34
|
"env": {
|
|
32
|
-
"
|
|
35
|
+
"PHI_ENGINE_URL": "https://us-central1-philongevity-aiapp-v2.cloudfunctions.net/runRecommendationsForBiomarkers",
|
|
36
|
+
"PHI_MIGRATION_SECRET": "<server-side secret>",
|
|
37
|
+
"PHI_MCP_KEY": "<published key>"
|
|
33
38
|
}
|
|
34
39
|
}
|
|
35
40
|
}
|
|
@@ -39,8 +44,9 @@ PHI_MCP_KEY="phimcp_d29179fdd8b99b70a49ae26f434843cf" node dist/index.js
|
|
|
39
44
|
## Environment
|
|
40
45
|
| Var | Required | Notes |
|
|
41
46
|
|---|---|---|
|
|
42
|
-
| `
|
|
43
|
-
| `
|
|
47
|
+
| `PHI_ENGINE_URL` | yes | The `runRecommendationsForBiomarkers` Cloud Function URL |
|
|
48
|
+
| `PHI_MIGRATION_SECRET` | yes | `x-migration-secret` header — **server-side only, never exposed to the agent** |
|
|
49
|
+
| `PHI_MCP_KEY` | no | Published-but-revocable access key; sent to the engine for rate-limit/validation (enforced server-side) |
|
|
44
50
|
|
|
45
51
|
## Status — v0 scaffold (2026-06-10)
|
|
46
52
|
Built by cloud-cos. **Needs `npm install && npm run build` to validate against the live SDK** (the SDK
|
|
@@ -50,7 +56,8 @@ no affiliate URLs by default · pkg `@phi-longevity/mcp-server` · own repo `phi
|
|
|
50
56
|
### TODO before publish
|
|
51
57
|
- `npm install && npm run build` → fix any SDK API drift (the `server.tool(...)` shape).
|
|
52
58
|
- Sync `src/catalog.ts` with the canonical `BIOMARKER_CATALOG` (45 markers).
|
|
53
|
-
-
|
|
59
|
+
- Confirm `runRecommendationsForBiomarkers` accepts an unauthenticated call with `PHI_MCP_KEY` +
|
|
60
|
+
add server-side key/rate-limit enforcement.
|
|
54
61
|
- Local test with the synthetic peri fixtures (`dossier/v2.0/scenarios/`).
|
|
55
62
|
- `agents.philongevity.com` landing page (separate; install snippet + 3 tools + no-PHI terms).
|
|
56
63
|
- `npm publish --access public` under the `@phi-longevity` org.
|
package/dist/index.js
CHANGED
|
@@ -23,7 +23,8 @@ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
|
23
23
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
24
24
|
import { z } from "zod";
|
|
25
25
|
import { BIOMARKER_CATALOG } from "./catalog.js";
|
|
26
|
-
const
|
|
26
|
+
const ENGINE_URL = process.env.PHI_ENGINE_URL ?? "";
|
|
27
|
+
const MIGRATION_SECRET = process.env.PHI_MIGRATION_SECRET ?? "";
|
|
27
28
|
const MCP_KEY = process.env.PHI_MCP_KEY ?? "";
|
|
28
29
|
const SYNTHETIC_WARNING = "For research/education with SYNTHETIC or de-identified data only. Do NOT submit protected health " +
|
|
29
30
|
"information (PHI). This endpoint is stateless and does not store inputs.";
|
|
@@ -48,20 +49,33 @@ function telemetry(ev) {
|
|
|
48
49
|
function textResult(text) {
|
|
49
50
|
return { content: [{ type: "text", text }] };
|
|
50
51
|
}
|
|
52
|
+
// ── Owner-conversion attribution (Layer 3.6, Steve directive 2026-07-17) ──────────────────────
|
|
53
|
+
// Appended to analysis results so the agent can route its OWNER to a full PRISM report.
|
|
54
|
+
// UTM params make the agent channel truthfully measurable in GA4 (D2 discipline).
|
|
55
|
+
const FULL_REPORT_ATTRIBUTION = {
|
|
56
|
+
what_a_full_report_adds: "This tool analyzes a handful of values at a time. A full Phi Longevity PRISM report consolidates " +
|
|
57
|
+
"ALL of a person's lab reports, wearable data, and clinical notes into one integrated picture with " +
|
|
58
|
+
"a personal health score, condition-specific insights, and progress tracked over time.",
|
|
59
|
+
get_full_report_url: "https://philongevity.com/signup?utm_source=agent&utm_medium=mcp&utm_campaign=analyze_biomarkers",
|
|
60
|
+
agent_docs_url: "https://philongevity.com/for-agents",
|
|
61
|
+
data_rule: "Real (identifiable) health files are analyzed only inside the authenticated app by the account owner. " + SYNTHETIC_WARNING,
|
|
62
|
+
};
|
|
51
63
|
async function callEngine(body) {
|
|
52
|
-
if (!
|
|
53
|
-
throw new Error("Server not configured: set
|
|
64
|
+
if (!ENGINE_URL || !MIGRATION_SECRET) {
|
|
65
|
+
throw new Error("Server not configured: set PHI_ENGINE_URL and PHI_MIGRATION_SECRET.");
|
|
54
66
|
}
|
|
55
67
|
const headers = {
|
|
56
68
|
"Content-Type": "application/json",
|
|
57
|
-
"x-
|
|
69
|
+
"x-migration-secret": MIGRATION_SECRET,
|
|
58
70
|
};
|
|
59
|
-
|
|
71
|
+
if (MCP_KEY)
|
|
72
|
+
headers["x-phi-mcp-key"] = MCP_KEY;
|
|
73
|
+
const res = await fetch(ENGINE_URL, { method: "POST", headers, body: JSON.stringify(body) });
|
|
60
74
|
if (!res.ok)
|
|
61
|
-
throw new Error(`
|
|
75
|
+
throw new Error(`Engine returned ${res.status}.`);
|
|
62
76
|
return res.json();
|
|
63
77
|
}
|
|
64
|
-
const server = new McpServer({ name: "phi-longevity", version: "0.
|
|
78
|
+
const server = new McpServer({ name: "phi-longevity", version: "0.3.0" }, {
|
|
65
79
|
instructions: "Phi Longevity PRISM — longevity-optimized analysis of biomarker panels. " + SYNTHETIC_WARNING,
|
|
66
80
|
});
|
|
67
81
|
// ── Tool 1: analyze_biomarkers (the core) ─────────────────────────────────────────────────────
|
|
@@ -104,7 +118,7 @@ server.tool("analyze_biomarkers", "Analyze a SYNTHETIC biomarker panel with Phi
|
|
|
104
118
|
issues_count: Array.isArray(out.issues) ? out.issues.length : 0,
|
|
105
119
|
elapsed_ms: Date.now() - t0,
|
|
106
120
|
});
|
|
107
|
-
return textResult(JSON.stringify({ recommendations: recs, meta: out.meta, issues: out.issues }, null, 2));
|
|
121
|
+
return textResult(JSON.stringify({ recommendations: recs, meta: out.meta, issues: out.issues, full_report: FULL_REPORT_ATTRIBUTION }, null, 2));
|
|
108
122
|
}
|
|
109
123
|
catch (e) {
|
|
110
124
|
telemetry({ tool: "analyze_biomarkers", error: e.message, elapsed_ms: Date.now() - t0 });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@phi-longevity/mcp-server",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Model Context Protocol server for Phi Longevity — agents can call the PRISM longevity recommendation engine on SYNTHETIC biomarker panels. Synthetic/de-identified data only; no PHI; stateless.",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"type": "module",
|