Skip to content

Errors in test client are not propagated to user, only show 'No response generated' #500

@dcramer

Description

@dcramer

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

  1. The AI SDK's streamText function doesn't throw synchronously for API errors
  2. The textStream iterator completes without yielding any chunks when there's an API error
  3. Error information might be available in result.fullStream, result.response, or result.errorPromise but these are not currently being checked

Reproduction Steps

  1. Set an invalid OpenAI API key: export OPENAI_API_KEY="sk-invalid-test-key"
  2. Run the test client: pnpm run start:client
  3. Enter any command (e.g., "test")
  4. 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

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions