simplepractice-mcp 0.2.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.
@@ -6,14 +6,14 @@
6
6
  },
7
7
  "metadata": {
8
8
  "description": "SimplePractice Client Portal tools for Claude",
9
- "version": "0.2.0"
9
+ "version": "0.3.0"
10
10
  },
11
11
  "plugins": [
12
12
  {
13
13
  "name": "simplepractice",
14
14
  "source": "./",
15
15
  "description": "Read a SimplePractice Client Portal — appointments, invoices and superbills, documents to sign, and practice announcements. Signs in with the portal's own passwordless emailed link; requests go straight to the portal's JSON:API over your own session.",
16
- "version": "0.2.0",
16
+ "version": "0.3.0",
17
17
  "author": {
18
18
  "name": "Chris Chall",
19
19
  "url": "https://github.com/chrischall"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "simplepractice",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "SimplePractice Client Portal — appointments, billing, documents, and announcements",
5
5
  "author": {
6
6
  "name": "Chris Chall",
package/README.md CHANGED
@@ -20,6 +20,7 @@ and announcements, read over the portal's own JSON:API.
20
20
  | `simplepractice_list_documents` | files the practice has shared |
21
21
  | `simplepractice_list_announcements` | practice announcements, with unread counts |
22
22
  | `simplepractice_session_status` · `_request_sign_in_link` · `_verify_sign_in_token` · `_verify_sign_in_pin` · `_sign_out` | sign-in |
23
+ | `simplepractice_healthcheck` | Verify credentials and upstream reachability; reports failures as data, not exceptions |
23
24
 
24
25
  Everything is read-only. Cancelling, signing, and paying happen in the portal.
25
26
 
@@ -27,15 +28,13 @@ Everything is read-only. Cancelling, signing, and paying happen in the portal.
27
28
 
28
29
  ```sh
29
30
  npm install -g simplepractice-mcp
30
- export SIMPLEPRACTICE_PRACTICE=achievebalancetherapy # or the full host
31
31
  ```
32
32
 
33
- `SIMPLEPRACTICE_PRACTICE` is the practice's portal address — the slug or the
34
- whole `<practice>.clientsecure.me` host from the link your provider emailed.
33
+ There is nothing to configure. The practice comes from your sign-in link.
35
34
 
36
35
  | Variable | |
37
36
  |---|---|
38
- | `SIMPLEPRACTICE_PRACTICE` | **required** — portal slug or host |
37
+ | `SIMPLEPRACTICE_PRACTICE` | optional — pins the server to one practice (slug or host) |
39
38
  | `SIMPLEPRACTICE_SESSION_FILE` | optional — session path (default `~/.simplepractice-mcp/session.json`, written `0600`) |
40
39
 
41
40
  ## Signing in
@@ -43,10 +42,31 @@ whole `<practice>.clientsecure.me` host from the link your provider emailed.
43
42
  The Client Portal has **no password**. SimplePractice emails a one-time link
44
43
  (or a 6-digit PIN); you trade it for a session cookie:
45
44
 
46
- 1. `simplepractice_request_sign_in_link { email, confirm: true }`
47
- 2. Open the email, copy the link.
48
- 3. `simplepractice_verify_sign_in_token { link }` — pass the whole link; the
49
- token is its `#` fragment and the tool extracts it.
45
+ 1. Open the email your provider sent, copy the link.
46
+ 2. `simplepractice_verify_sign_in_token { link }` — pass the **whole** link.
47
+
48
+ The link is `https://<practice>.clientsecure.me/sign-in/token#<TOKEN>`, so one
49
+ paste carries both halves of what the server needs: the token is the `#`
50
+ fragment, and the host names the practice. Nothing is hardcoded, and the
51
+ stored session remembers the practice for every later run —
52
+ `simplepractice_session_status` reports which practice is in play and whether
53
+ it came from a link, the environment variable, or the saved session.
54
+
55
+ To have a fresh link sent rather than using one you already have, name the
56
+ practice once:
57
+
58
+ ```
59
+ simplepractice_request_sign_in_link { email, practice: "achievebalancetherapy", confirm: true }
60
+ ```
61
+
62
+ `practice` can be omitted whenever the server already knows the practice —
63
+ from an earlier sign-in, or from `SIMPLEPRACTICE_PRACTICE`.
64
+
65
+ Two sign-in links name no practice, and fall back to whichever one is already
66
+ known: the mobile-app variant SimplePractice sends
67
+ (`https://clientsecure.me/client-portal-api/sign-in/token#<TOKEN>`, pointed at
68
+ the bare apex), and a bare token pasted without its link. A link on any host
69
+ outside `*.clientsecure.me` is never adopted — the token is not sent there.
50
70
 
51
71
  Links are single-use — replaying one answers
52
72
  `401 "Authorization has already been used or expired"` — and last 24 hours. The
@@ -87,7 +107,7 @@ records the endpoints and the traps, all confirmed against a live portal:
87
107
  ```sh
88
108
  npm install
89
109
  npm run build
90
- npm test # 151 tests
110
+ npm test # 214 tests
91
111
  npm run test:coverage # 100% enforced
92
112
  npm run typecheck # vitest does not run tsc — this does
93
113
  ```
package/dist/auth.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import { CookieJar, McpToolError } from '@chrischall/mcp-utils';
2
+ import { practiceHostFromLink } from './config.js';
2
3
  /** The Rails/Devise session cookie the portal authenticates with. */
3
4
  export const SESSION_COOKIE = 'simplepractice-session';
4
5
  /**
@@ -67,11 +68,37 @@ async function establishSession(client, attributes) {
67
68
  hint: `Expected a ${SESSION_COOKIE} cookie on the response. If SimplePractice has renamed it, simplepractice-mcp needs updating.`,
68
69
  });
69
70
  }
70
- client.saveSession(`${SESSION_COOKIE}=${cookie}`);
71
- return { status, signedIn: true };
71
+ const session = client.saveSession(`${SESSION_COOKIE}=${cookie}`);
72
+ return { status, signedIn: true, practiceHost: session.host };
72
73
  }
73
- export function verifySignInToken(client, linkOrToken) {
74
- return establishSession(client, { type: 'token', token: extractToken(linkOrToken) });
74
+ /**
75
+ * Trade an emailed sign-in link for a session — and take the practice from the
76
+ * link while we are at it.
77
+ *
78
+ * The link is `https://<practice>.clientsecure.me/sign-in/token#<TOKEN>`, so
79
+ * the same paste that carries the token also says which portal to send it to.
80
+ * That is the only ordering that can work when the link and the configuration
81
+ * disagree: the token was minted for the practice in the link, and posting it
82
+ * anywhere else is a 401.
83
+ *
84
+ * A link that names no practice — the mobile variant at the bare apex, or a
85
+ * bare token — falls back to whatever practice is already known.
86
+ */
87
+ // `async` so that the pre-flight rejections below reach a caller the same way
88
+ // the network ones do, rather than throwing synchronously out of a function
89
+ // that otherwise returns a promise.
90
+ export async function verifySignInToken(client, linkOrToken) {
91
+ const attributes = { type: 'token', token: extractToken(linkOrToken) };
92
+ const fromLink = practiceHostFromLink(linkOrToken);
93
+ // Scoped, so a link that fails to verify does not leave the process pointed
94
+ // at its practice — links are single-use, so failing is the ordinary case.
95
+ if (fromLink) {
96
+ return client.withPracticeHost(fromLink, () => establishSession(client, attributes));
97
+ }
98
+ // No practice in the link, so it has to be known already: resolve before
99
+ // posting, or a single-use token is spent against a guess.
100
+ client.portalHost();
101
+ return establishSession(client, attributes);
75
102
  }
76
103
  export function verifySignInPin(client, email, pin) {
77
104
  return establishSession(client, { type: 'pin', email, pin });