Repository navigation
Add a client organizationId for MCP tool calls - #115
Open
sohaibahsan007 wants to merge 2 commits into
Open
sohaibahsan007 wants to merge 2 commits into
sohaibahsan007 wants to merge 2 commits into
Conversation
With a credential that works in several organizations, every knowledge and fixes call has to repeat the same organization_id, and a call that misses it gets ORGANIZATION_REQUIRED at run time. ProoflineClient now accepts organizationId. Knowledge and fixes calls without their own organization_id send it; a call's own target still wins. listOrganizations stays untargeted and REST paths keep their org_id. The value must be a UUID, is sent lowercase, and is never read from the environment, so the SDK still chooses no default itself.
The README code block closed with trailing text, so the next section rendered as code. organizationId is now typed string | undefined so the README example compiles under exactOptionalPropertyTypes. New tests prove the environment is never read and that a per-call null or empty organization_id is forwarded unchanged.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Who this helps
Anyone using the
knowledgeandfixeshelpers with a credential that works in more than one organization, such as an MCP OAuth credential approved for several organizations. Today every one of those 11 calls has to repeat the sameorganization_id. A call that misses it getsORGANIZATION_REQUIREDat run time, often deep in a script after earlier calls succeeded. The CLI solves this once with--org; the SDK had no equivalent.What it does
new ProoflineClient({ organizationId })sets the organization thatknowledge.*andfixes.*tool calls target when the call passes noorganization_idof its own.Decisions
organization_idalways wins. Existing per-call targeting, including concurrent calls on one client, works exactly as before.PROOFLINE_ORGANIZATION_IDlikePROOFLINE_BASE_URL. I dropped it: a wrong base URL fails loudly, but a stray organization variable could silently retarget writes such asrequestReverificationorstartPlanImplementationwhere today the same mistake returnsORGANIZATION_REQUIRED. The caller passes the value explicitly, so "the SDK chooses no default" in the README stays true.mcp.listOrganizations()stays untargeted so discovery works before a target is known, and REST methods keeporg_idin their path. The README says so, since the CLI's--orgalso covers REST.TypeErrorin the constructor, before any request.organizationId: undefinedis the same as leaving it out.isErrorwithNOT_AUTHORIZED, after one tool call.src/transport.ts,src/mcp.ts,src/index.ts, README and tests. Nothing generated changes.How I verified it
All CI steps locally on Node 22:
pnpm install --frozen-lockfile,pnpm generate && git diff --exit-code(no drift),pnpm lint,pnpm typecheck,node check-claims.mjs,pnpm build,pnpm test: 111 of 111 pass (106 before, 5 new tests).The new tests in
tests/http.test.mjsrun against the same local MCP stand-in as the existing organization tests:organizationIdset, all 11 targeted helpers send it when the call has no target and when the call passesorganization_id: undefined; a per-call target wins for every helper;listOrganizations()still sends{}; three concurrent calls on one client keep their own targets; every tool call is one initialize, one notification and one call.getReviewstill requests the path's ownorg_id.undefined), noorganization_idkey is sent andORGANIZATION_REQUIREDis kept.NOT_AUTHORIZEDandisErrorafter exactly one tool call.nullvalues throwTypeErrorwith no request; an uppercase UUID is sent lowercase.The public type check now also compiles
{ organizationId }as constructor options under--strict --exactOptionalPropertyTypes.To check the tests catch real breaks, I broke the code four ways and ran the suite each time: ignoring an own-key
undefined(2 tests fail), letting the client target override the call's (5 fail), targetinglistOrganizations(1 fails), and skipping the lowercase step (1 fails).