@calypsohq/elephant-mcp-server 1.6.0 → 1.7.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.
@@ -7,6 +7,15 @@ export type GrantFacts = {
7
7
  readonly team?: string;
8
8
  readonly cid?: string;
9
9
  readonly sub?: string;
10
+ /**
11
+ * The names behind the ids, when the authorization server sealed them
12
+ * into the token (`ed`). Absent on older tokens and when it could not
13
+ * resolve them.
14
+ */
15
+ readonly personName?: string;
16
+ readonly personEmail?: string;
17
+ readonly teamName?: string;
18
+ readonly clientName?: string;
10
19
  };
11
20
  /**
12
21
  * What an authenticated request carries into the tool layer: the Calypso API
@@ -27,4 +27,11 @@ export declare class JwtGrantStrategy implements AuthStrategy {
27
27
  constructor(options: JwtGrantStrategyOptions);
28
28
  accepts(token: string): boolean;
29
29
  authenticate(token: string, preset: ProtectedResource): Promise<Credential | AuthChallenge>;
30
+ /**
31
+ * The grant's names from the sealed `ed` claim: `{n, e, t, c}` for the
32
+ * person's name and email, the team and the client. They only make the
33
+ * operator notices readable, so a claim that is missing or does not open
34
+ * is no reason to refuse the request.
35
+ */
36
+ private names;
30
37
  }
@@ -54,9 +54,40 @@ export class JwtGrantStrategy {
54
54
  team: claims.team,
55
55
  cid: claims.cid,
56
56
  sub: claims.sub,
57
+ ...this.names(claims.ed),
57
58
  },
58
59
  };
59
60
  }
61
+ /**
62
+ * The grant's names from the sealed `ed` claim: `{n, e, t, c}` for the
63
+ * person's name and email, the team and the client. They only make the
64
+ * operator notices readable, so a claim that is missing or does not open
65
+ * is no reason to refuse the request.
66
+ */
67
+ names(sealed) {
68
+ if (typeof sealed !== "string" || !sealed)
69
+ return {};
70
+ try {
71
+ const parsed = JSON.parse(this.options.cipher.open(sealed));
72
+ if (!parsed || typeof parsed !== "object")
73
+ return {};
74
+ const text = (key) => {
75
+ const value = parsed[key];
76
+ return typeof value === "string" && value.trim()
77
+ ? value.trim()
78
+ : undefined;
79
+ };
80
+ return {
81
+ personName: text("n"),
82
+ personEmail: text("e"),
83
+ teamName: text("t"),
84
+ clientName: text("c"),
85
+ };
86
+ }
87
+ catch {
88
+ return {};
89
+ }
90
+ }
60
91
  }
61
92
  function describeJoseError(error) {
62
93
  if (error instanceof errors.JWTExpired)
@@ -22,10 +22,18 @@ export function buildUsageMessage(call, server, dropped = 0, summarize) {
22
22
  const headline = summary.headline
23
23
  ? ` · ${truncate(summary.headline, 120)}`
24
24
  : "";
25
+ const grant = call.grant;
26
+ const person = [grant?.personName, grant?.personEmail]
27
+ .filter(Boolean)
28
+ .join(" · ");
29
+ // Who first, by name when the token carried the names; the ids follow in
30
+ // the context line at the foot of the post.
25
31
  const fields = [
32
+ { label: "Person", value: person },
33
+ { label: "Team", value: grant?.teamName ?? "" },
34
+ { label: "Client", value: grant?.clientName ?? "" },
26
35
  ...summary.fields,
27
36
  { label: "Outcome", value: outcome },
28
- { label: "Caller", value: caller },
29
37
  {
30
38
  label: "Scopes",
31
39
  value: call.scopes.length ? call.scopes.join(" ") : "api key (all)",
@@ -43,7 +51,7 @@ export function buildUsageMessage(call, server, dropped = 0, summarize) {
43
51
  }
44
52
  return {
45
53
  // Escaped like the fields: the headline is the caller's own text.
46
- text: escapeMrkdwn(`${product.label} used · ${call.tool}${headline} · ${caller}`),
54
+ text: escapeMrkdwn(`${product.label} used · ${call.tool}${headline} · ${grant?.personEmail || grant?.personName || caller}`),
47
55
  blocks: [
48
56
  {
49
57
  type: "header",
@@ -54,6 +62,16 @@ export function buildUsageMessage(call, server, dropped = 0, summarize) {
54
62
  },
55
63
  },
56
64
  ...fieldSections(fields),
65
+ {
66
+ type: "context",
67
+ elements: [
68
+ {
69
+ type: "mrkdwn",
70
+ text: fitEscaped(caller, FIELD_TEXT_LIMIT),
71
+ verbatim: true,
72
+ },
73
+ ],
74
+ },
57
75
  ],
58
76
  };
59
77
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@calypsohq/elephant-mcp-server",
3
- "version": "1.6.0",
3
+ "version": "1.7.0",
4
4
  "mcpName": "io.github.calypso-so/elephant-mcp-server",
5
5
  "description": "Elephant: PDF AI and docs Q&A as an MCP server. Chat with your PDFs, documents and web pages from Claude, ChatGPT and Cursor, with every answer cited.",
6
6
  "type": "module",