drafted 1.11.17 → 1.11.18

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.
Files changed (2) hide show
  1. package/mcp/server.mjs +17 -0
  2. package/package.json +1 -1
package/mcp/server.mjs CHANGED
@@ -766,6 +766,23 @@ async function api(method, path, body, extraHeaders = {}, _retried = false) {
766
766
  const scopedPath = pid ? `${path}${sep}projectId=${pid}` : path;
767
767
  const url = `${getServerUrl()}${scopedPath}`;
768
768
  const headers = { ...getAuthHeaders(), ...extraHeaders };
769
+ // Bind every data request to the org this MCP session is actually working in
770
+ // (the active project's org, or the org chosen via get_org switch). Without
771
+ // this, project-scoped routes that resolve org from the SHARED server-side
772
+ // session row (notably /api/fs ls + frame read, via effectiveOrgId) break when
773
+ // a concurrent agent session for the same user flips that row to another org:
774
+ // the active project then "isn't in the current org", the 404 handler below
775
+ // clears it, and the agent sees the "active project no longer in the current
776
+ // org" churn. X-Drafted-Org is validated against the caller's memberships
777
+ // server-side and never mutates the session, so it scopes resolution
778
+ // per-request — exactly like the org-less /project/:slug link that already
779
+ // works. An explicit override in extraHeaders (e.g. the wiki/skill `org` arg)
780
+ // always wins, and /auth/* is left untouched so it reports true session state.
781
+ const boundOrg = getSessionState().boundOrgId;
782
+ const hasExplicitOrg = Object.keys(headers).some((k) => k.toLowerCase() === 'x-drafted-org');
783
+ if (boundOrg && !hasExplicitOrg && !path.startsWith('/auth/')) {
784
+ headers['X-Drafted-Org'] = boundOrg;
785
+ }
769
786
  const opts = { method, headers };
770
787
 
771
788
  if (body !== undefined) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "drafted",
3
- "version": "1.11.17",
3
+ "version": "1.11.18",
4
4
  "description": "Drafted — visual thinking surface for humans and AI agents. Renders HTML, markdown, images, and code as frames on a zoomable canvas, with MCP tools for AI agents and real-time sync for humans.",
5
5
  "type": "module",
6
6
  "files": [