Skip to content

fix(mcp): get_page honors per-call source_id parameter#1394

Open
Valentin32 wants to merge 1 commit into
garrytan:masterfrom
Valentin32:fix/get-page-source-id-param
Open

fix(mcp): get_page honors per-call source_id parameter#1394
Valentin32 wants to merge 1 commit into
garrytan:masterfrom
Valentin32:fix/get-page-source-id-param

Conversation

@Valentin32
Copy link
Copy Markdown

Prior to this commit, get_page ignored the per-call source_id parameter entirely — only OperationContext.sourceId was respected. MCP clients with a default-source bearer (e.g. hermes-write with source_id=default) could not get_page pages in non-default sources, even when federated_read access was granted. Symptom: page_not_found errors despite the page existing in the DB and being visible via the query-tool.

The query-tool already supported per-call source_id via the --source-id flag (v0.34). This brings get_page into symmetry.

Change:

  • Add source_id to params schema (optional, string)
  • effectiveSourceId = p.source_id ?? ctx.sourceId
  • Threads through both the initial getPage lookup and the fuzzy-resolved follow-up.

Regression test: test/get-page-source-id-param.test.ts (5 cases).

Repro (pre-PR):

Bearer's ctx.sourceId = default; page lives in priv-karriere-entities

curl -X POST /mcp -H "Authorization: Bearer "
-d '{"method":"tools/call","params":{"name":"get_page", "arguments":{"slug":"X","source_id":"priv-karriere-entities"}}}' # Pre-PR: {"error":"page_not_found"} # Post-PR: returns the page

Backwards compatible: when source_id is unset, behavior matches v0.31.8 (D20).

Prior to this commit, get_page ignored the per-call source_id
parameter entirely — only OperationContext.sourceId was respected.
MCP clients with a default-source bearer (e.g. hermes-write with
source_id=default) could not get_page pages in non-default sources,
even when federated_read access was granted. Symptom: page_not_found
errors despite the page existing in the DB and being visible via
the query-tool.

The query-tool already supported per-call source_id via the
--source-id flag (v0.34). This brings get_page into symmetry.

Change:
  - Add `source_id` to params schema (optional, string)
  - effectiveSourceId = p.source_id ?? ctx.sourceId
  - Threads through both the initial getPage lookup and the
    fuzzy-resolved follow-up.

Regression test: test/get-page-source-id-param.test.ts (5 cases).

Repro (pre-PR):
  # Bearer's ctx.sourceId = default; page lives in priv-karriere-entities
  curl -X POST /mcp -H "Authorization: Bearer <default>" \
    -d '{"method":"tools/call","params":{"name":"get_page",
         "arguments":{"slug":"X","source_id":"priv-karriere-entities"}}}'
  # Pre-PR: {"error":"page_not_found"}
  # Post-PR: returns the page

Backwards compatible: when source_id is unset, behavior matches
v0.31.8 (D20).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant