-
Notifications
You must be signed in to change notification settings - Fork 53
Open
Description
Problem
When the MCP test client encounters errors (such as invalid API keys, rate limits, or API service errors), these errors are not properly propagated to the user. Instead, the client simply displays "(No response generated)" which doesn't help users understand what went wrong.
Current Behavior
- Invalid OpenAI API key → Shows "(No response generated)"
- Rate limit errors → Shows "(No response generated)"
- Invalid/unrecognized commands → Shows "(No response generated)"
- API service errors → Shows "(No response generated)"
Expected Behavior
The client should display meaningful error messages to help users understand what went wrong:
- Invalid API key → "OpenAI API authentication failed. Please check your OPENAI_API_KEY environment variable."
- Rate limits → "OpenAI API rate limit exceeded. Please wait and try again."
- Service errors → "OpenAI API service error. The service may be temporarily unavailable."
Technical Details
The issue appears to be related to how the Vercel AI SDK's streamText function handles errors. When an invalid API key is provided, the stream returns empty (no chunks) rather than throwing an error or including error events in the stream.
Code Location
- File:
packages/mcp-test-client/src/agent.ts - Function:
runAgent - Lines: ~53-140
Investigation Notes
- The AI SDK's
streamTextfunction doesn't throw synchronously for API errors - The
textStreamiterator completes without yielding any chunks when there's an API error - Error information might be available in
result.fullStream,result.response, orresult.errorPromisebut these are not currently being checked
Reproduction Steps
- Set an invalid OpenAI API key:
export OPENAI_API_KEY="sk-invalid-test-key" - Run the test client:
pnpm run start:client - Enter any command (e.g., "test")
- Observe that it shows "(No response generated)" instead of an authentication error
Impact
Users cannot distinguish between:
- Configuration issues (wrong API key)
- Service issues (rate limits, outages)
- Invalid commands
- Actual empty responses
This makes debugging and troubleshooting very difficult.
Metadata
Metadata
Assignees
Labels
No labels