Skip to content

feat(caller): forward account callers to dfo-apis - #201

Open
sefk wants to merge 2 commits into
devfrom
feat/keyed-caller
Open

sefk wants to merge 2 commits into
devfrom
feat/keyed-caller

Conversation

@sefk

@sefk sefk commented Nov 16, 2026 •

Copy link
Copy Markdown

What and why

Part of DevelopmentFinanceObservatory/website#142, API keys on the website's platform proxy. Limits are per account, so the website names a call made with an API key as x-dfo-caller: user:<32 hex>, beside today's ip:<32 hex>.

The data, presentation and analysis MCP clients forwarded the caller to dfo-apis only when it matched ip:, and dropped anything else. A keyed caller's allowances would then have counted against dfo-ai itself.

  • common.caller: ADDRESS_CALLER becomes WEBSITE_CALLER, (ip|user):[0-9a-f]{32}. Its docstring drops the key: form, since limits are per account.
  • data-mcp, presentation-mcp and analysis-mcp forward user: callers with the principal exactly as they forward ip:. conversation: callers and malformed values are still dropped.
  • No other code in dfo-ai inspects the caller's prefix. current_writer() records the caller string as is.

Verification

  • just lint and just typecheck pass.
  • The full workspace suite passes: 15,689 passed, 21 skipped, 5 xfailed.
  • New tests:
    • packages/common/tests/test_caller.py: the pattern accepts ip: and user: and refuses other prefixes, wrong lengths, non-hex, uppercase and whitespace.
    • Each client's tests: a user: caller is forwarded with the principal and dropped without it, and malformed ip: and user: callers are dropped.
  • Codex review: no findings.

Coordination

Merge and deploy after dfo-apis accepts user: callers (DevelopmentFinanceObservatory/apis#320). Until then dfo-apis answers 400 to them. The website starts sending them in website #143, which ships last.

Docs: docs/guide/connect.md now covers API keys, and its 429 row says a key raises the limit, linking the hub's new "Use an API key" page. Merge DevelopmentFinanceObservatory/docs#26 first, or the docs build's link check reports that link as broken.

🤖 Generated with Claude Code

https://claude.ai/code/session_015QQk2mKJZzXv2AYykDjvQf

The website proxy is gaining API keys (website#142). Limits are per
account, so a keyed call reaches dfo-ai with `x-dfo-caller:
user:<32 hex>` (an HMAC digest of the account id, the same shape as
`ip:<32 hex>`). The data, presentation and analysis clients forwarded the
caller to dfo-apis, beside the caller principal, only for `ip:`, and
dropped anything else, which would have counted a keyed caller's
allowances against dfo-ai itself.

Replace `ADDRESS_CALLER` with `WEBSITE_CALLER`, matching `ip:` or `user:`
plus 32 lowercase hex digits, and use it in all three clients. A malformed
caller is still dropped. Correct the docs: `key:` is not a form the
website sends.

Requires the matching dfo-apis change (accept `user:` beside the
principal) to be deployed first; until then dfo-apis would refuse a
`user:` caller.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015QQk2mKJZzXv2AYykDjvQf
connect.md said no token is needed. Anonymous use still needs none, but an
optional API key raises the call limit and developer clients and Claude
custom connectors can send it as a header. Update the 429 troubleshooting
row and link the API keys page.

Refs DevelopmentFinanceObservatory/website#142

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
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