Conversation
|
🧪 Testing To try out this version of the SDK: Expires at: Mon, 06 Apr 2026 05:53:05 GMT |
c7e6122 to
2505acc
Compare
| ...req, | ||
| headers: redactHeaders(req.raw.headers), | ||
| }; | ||
| }), | ||
| res: pino.stdSerializers.wrapResponseSerializer((res) => { | ||
| return { | ||
| ...res, | ||
| headers: redactHeaders(res.headers), | ||
| }; |
There was a problem hiding this comment.
Correctness: req.raw is undefined on the serialized request object, so req.raw.headers will throw a TypeError at runtime. Additionally, res.headers is not a property of the serialized response object. Use req.headers (which is already available) and access the raw response object to call getHeaders() for response redaction. 🛡️
🤖 AI Agent Prompt for Cursor/Windsurf
📋 Copy this prompt to your AI coding assistant (Cursor, Windsurf, etc.) to get help fixing this issue
In `packages/mcp-server/src/http.ts` around the pino serializers, replace direct access to `req.raw.headers` and `res.headers` with safe fallbacks (e.g., `req.raw?.headers ?? req.headers ?? {}` and `res.getHeaders?.() ?? res.headers ?? {}`) so `redactHeaders` never receives `undefined`.
2505acc to
6435522
Compare
…e code tool calls
6435522 to
81ac8ff
Compare
81ac8ff to
0903fca
Compare
| query: body.query, | ||
| status: result.status, | ||
| statusText: result.statusText, | ||
| errorText, | ||
| }, | ||
| 'Got error response from docs search tool', | ||
| ); | ||
|
|
||
| if (result.status === 404 && !reqContext.stainlessApiKey) { | ||
| throw new Error( | ||
| 'Could not find docs for this project. You may need to provide a Stainless API key via the STAINLESS_API_KEY environment variable, the --stainless-api-key flag, or the x-stainless-api-key HTTP header.', | ||
| ); | ||
| } | ||
|
|
||
| throw new Error( | ||
| `${result.status}: ${result.statusText} when using doc search tool. Details: ${await result.text()}`, | ||
| `${result.status}: ${result.statusText} when using doc search tool. Details: ${errorText}`, | ||
| ); | ||
| } | ||
|
|
||
| return asTextContentResult(await result.json()); | ||
| const resultBody = await result.json(); | ||
| logger.info( | ||
| { | ||
| durationMs: Date.now() - startTime, | ||
| query: body.query, |
There was a problem hiding this comment.
Correctness: 🚫 args can be undefined per the handler signature, so body.query will throw during logging. Use optional chaining or a default to avoid crashing the handler just for telemetry.
🤖 AI Agent Prompt for Cursor/Windsurf
📋 Copy this prompt to your AI coding assistant (Cursor, Windsurf, etc.) to get help fixing this issue
File: packages/mcp-server/src/docs-search-tool.ts. Lines 69-92. The new logging accesses body.query, but args can be undefined, causing a runtime error. Update both logger.warn and logger.info payloads to use optional chaining (body?.query) or a safe default so logging does not throw when args is missing.
| import { StreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/streamableHttp.js'; | ||
| import { ClientOptions } from 'hyperspell'; | ||
| import express from 'express'; | ||
| import morgan from 'morgan'; | ||
| import morganBody from 'morgan-body'; | ||
| import pino from 'pino'; | ||
| import pinoHttp from 'pino-http'; | ||
| import { getStainlessApiKey, parseClientAuthHeaders } from './auth'; | ||
| import { getLogger } from './logger'; | ||
| import { McpOptions } from './options'; | ||
| import { initMcpServer, newMcpServer } from './server'; | ||
|
|
There was a problem hiding this comment.
Correctness: The introduction of getLogger() in streamableHTTPApp and launchStreamableHTTPServer will cause a runtime crash. The getLogger() implementation in logger.ts is designed to throw an error if _logger is not initialized via configureLogger(). Since launchStreamableHTTPServer does not invoke configureLogger() before calling streamableHTTPApp, the server will fail to start. You must ensure the logger is configured at the start of the server lifecycle or provide a default logger instance.
0903fca to
23dbf39
Compare
23dbf39 to
423c7ed
Compare
| }); | ||
|
|
||
| const logger = getLogger(); | ||
|
|
There was a problem hiding this comment.
Correctness: Calling getLogger() introduces a reliability regression. Since getLogger() throws an error if the logger is not configured, this handler will now crash in environments where logging is not initialized, whereas it previously functioned correctly. Guard the logger call or provide a fallback to ensure the tool remains functional regardless of the logging state.
🤖 AI Agent Prompt for Cursor/Windsurf
📋 Copy this prompt to your AI coding assistant (Cursor, Windsurf, etc.) to get help fixing this issue
In packages/mcp-server/src/docs-search-tool.ts around the new logging additions (line ~63), guard getLogger() so the handler doesn’t throw if logging isn’t configured. Wrap getLogger() in try/catch and make logging calls optional (logger?.info/warn) or ensure configuration occurs before this handler runs.
Automated Release PR
0.33.0 (2026-03-07)
Full Changelog: v0.32.1...v0.33.0
Features
Chores
This pull request is managed by Stainless's GitHub App.
The semver version number is based on included commit messages. Alternatively, you can manually set the version number in the title of this pull request.
For a better experience, it is recommended to use either rebase-merge or squash-merge when merging this pull request.
🔗 Stainless website
📚 Read the docs
🙋 Reach out for help or questions