Skip to content

Record the tool of REST API requests - #6933

Draft
vinibrsl wants to merge 2 commits into
record-api-request-site-idfrom
record-api-request-tool
Draft

vinibrsl wants to merge 2 commits into
record-api-request-site-idfrom
record-api-request-tool

Conversation

@vinibrsl

@vinibrsl vinibrsl commented Nov 26, 2026 •

Copy link
Copy Markdown
Member

Changes

The API request log does not record which tool a request used. This PR records the tool of REST requests. A REST endpoint and an MCP tool that do the same thing share one name, so POST /api/v2/query is query_stats and GET /api/v1/sites is list_sites.

  • The router sets a :tool assign on these two routes. AuthorizePublicAPI adds it to the trace before the access checks, so a request that fails authorization still has plausible.tool. The controllers no longer set it. POST /api/docs/query no longer traces a tool.
  • The log stores :tool, or '' when the request did not use a tool.

MCP requests are not recorded yet. That comes in a later PR.

Depends on #6931.

Tests

  • Automated tests have been added

Changelog

  • This PR does not make a user-facing change

Documentation

  • This change does not need a documentation update

Dark mode

  • This PR does not change the UI

@vinibrsl
vinibrsl marked this pull request as draft November 26, 2026 17:14
Controllers set the plausible.tool trace attribute, so requests that
failed authorization had no tool. The router now sets a :tool assign on
POST /api/v2/query and GET /api/v1/sites. AuthorizePublicAPI adds it to
the trace before the access checks.

The request log will read the same assign.
The request log now stores the :tool assign that the router sets:
query_stats for POST /api/v2/query and list_sites for GET /api/v1/sites.
Other routes store an empty string.

Needs the tool column from #6932 deployed first.
@vinibrsl
vinibrsl force-pushed the record-api-request-site-id branch from 7e9adb5 to 3a66de3 Compare November 26, 2026 17:16
@vinibrsl
vinibrsl force-pushed the record-api-request-tool branch 5 times, most recently from abac820 to e687e86 Compare November 26, 2026 19:50
@vinibrsl vinibrsl changed the title Record the tool and MCP requests in the API request log Record the tool of REST API requests Nov 26, 2026
@vinibrsl
vinibrsl force-pushed the record-api-request-tool branch 3 times, most recently from c7ea372 to f9ed199 Compare November 26, 2026 20:07

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