Repository navigation
feat: log each call under the agent whose token it carries - #10
Merged
Merged
Conversation
App:AgentTokens maps agent names to bearer tokens and replaces
App:AuthToken. The middleware sets the matched agent as the request's
user, and every query_database, list_tables, describe_table and
/api/query call is logged with its name ("unauthenticated" over stdio
or without tokens). Blank or shared tokens stop the server at startup.
Calls refused before they reach the database (unknown database, a
statement SqlGuard rejects, invalid parameters, a missing password) are
now logged as warnings with their SQL, and requests with a missing or
unknown token are logged with their path and remote address.
appsettings.Production.json starts each log entry with the UTC time.
…a failure describe_table logged a missing or ambiguous table as having run, with 0 rows. The work passed to RunAsync now returns a result, so describe reports that outcome as an error and it is logged as a failure. list_databases, which logged nothing, now logs the agent and how many databases it listed.
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.
Until now the log said what ran and when, but not who ran it: every client shared one
App:AuthToken.App:AgentTokensmaps agent names to bearer tokens (App__AgentTokens__<name>as env vars) and replacesApp:AuthToken. A blank token, or one shared by two agents, stops the server at startup. Revoking one agent no longer means rotating everyone's token./api/queryfromHttpContext.User, and every log line names it. Over stdio, or over HTTP without tokens, it isunauthenticated.list_databasesis logged with the agent and the number of databases, and adescribe_tablethat finds no table (or more than one) is logged as a failure instead of a run with 0 rows.SqlMcp.Http.HttpSecuritywith method, path and remote address (never the token).appsettings.Production.jsonstarts each entry with the UTC time (journald keeps its own under systemd).Tested locally: all unit and HTTP tests, plus the Postgres integration tests. The other three databases are left to CI.