You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 2ada652
Browse filesBrowse the repository at this point in the historyBrowse files
Add a `logger` option to `Client`, `McpServer`, `createMcpHandler` and the built-in OAuth providers such as `ClientCredentialsProvider`, and an optional `sdkLogger` property to `OAuthClientProvider`, so SDK diagnostics can be routed through user-provided logging. Omitting them keeps the current `console` output.
`expectedIssuer` is the `issuer` of the authorization server the credential was registered with. If discovery resolves a different issuer, the SDK throws `AuthorizationServerMismatchError` instead of sending the secret. `PrivateKeyJwtProvider` and `CrossAppAccessProvider` below take it too; omitting it is deprecated, and the credential then goes to whichever authorization server the MCP server advertises.
31
31
32
+
Every built-in provider also takes `logger`, a console-compatible `SdkLogger` for the warnings the SDK prints about it, such as that deprecation. It defaults to `console`.
33
+
32
34
## Bring your own bearer token
33
35
34
36
When something outside the SDK already owns the token — an API key, a gateway, a platform secret store — implement `AuthProvider` with only `token()`.
Copy file name to clipboardExpand all lines: docs/clients/oauth.md
+4Lines changed: 4 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -101,6 +101,10 @@ The SDK calls the `save*` methods as the flow produces values and reads them bac
101
101
When the requested scope includes `offline_access`, the SDK adds `prompt=consent` to the authorization URL. Set `skipOfflineAccessConsentPrompt = true` on the provider to omit it when consent is already granted out of band, such as a Microsoft Entra ID tenant with admin consent and user consent disabled.
102
102
:::
103
103
104
+
::: tip
105
+
`auth()` prints warnings while it runs, for example when a stored credential has no `issuer` stamp or a token refresh fails. Set `sdkLogger` on the provider to route them somewhere other than `console`. It takes the same console-compatible `SdkLogger` as `Client`'s `logger` option; a `logger` property your provider class already has is left alone.
106
+
:::
107
+
104
108
## Finish the flow from the callback
105
109
106
110
The authorization server redirects the end user to `redirectUrl` with `code` and `state` in the query. Compare `state`, hand the whole query to `finishAuth`, and reconnect.
Copy file name to clipboardExpand all lines: docs/servers/logging-progress-cancellation.md
+20Lines changed: 20 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -71,6 +71,25 @@ Only the result comes back:
71
71
72
72
`progress` must increase on every notification for the same token; `total` and `message` are optional.
73
73
74
+
## Route SDK diagnostics
75
+
76
+
Pass `logger` to `McpServer` to route the warnings and debug messages the SDK prints locally. On a stdio server, send every level to stderr: the server's stdout carries only MCP messages.
`Client` and `createMcpHandler` take the same option. The low-level `Server` has no diagnostics of its own, so it does not take one. The SDK logs at two levels, `debug` and `warn`. Both methods are optional, and an omitted one discards diagnostics at that level. The default is `console`, and a logger that throws is ignored.
88
+
89
+
The client's OAuth helpers run outside a `Client`, so they read the logger from the auth provider instead: set `sdkLogger` on your `OAuthClientProvider`, or pass `logger` to a built-in provider such as `ClientCredentialsProvider`.
90
+
91
+
This logger stays local to the process. It does not send MCP `notifications/message`; use `ctx.mcpReq.log` for that deprecated protocol feature.
92
+
74
93
## Log to the client
75
94
76
95
::: warning Deprecated — SEP-2577
@@ -221,6 +240,7 @@ Resolve an identifier against a fixed list, as `fetch-source` does. A tool that
221
240
222
241
- Every handler receives a context as its second argument; the request-scoped helpers live on `ctx.mcpReq`.
223
242
-`ctx.mcpReq.notify` sends `notifications/progress` when the request carried a `progressToken`; `progress` must increase on each one.
243
+
- The `logger` option routes local SDK diagnostics; it is separate from MCP protocol logging.
224
244
-`ctx.mcpReq.log(level, data)` sends `notifications/message` once the `logging` capability is declared; MCP logging is deprecated (SEP-2577).
225
245
- Declaring `logging` also installs `logging/setLevel`; after `client.setLoggingLevel(level)` the SDK drops messages below that level for the session.
226
246
-`ctx.mcpReq.signal` aborts on cancellation and disconnect — check it in long loops and forward it to your own I/O.
0 commit comments