Skip to content

Commit 2951c23

Browse files
Merge pull request modelcontextprotocol#499 from thisistonydang/thisistonydang/catch-error
Docs: Add catch block to prevent silent failure in example TypeScript MCP client (mcp-client-typescript)
2 parents 7b429d4 + 8ccee39 commit 2951c23

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

docs/docs/develop/build-client.mdx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -738,6 +738,10 @@ async function main() {
738738
try {
739739
await mcpClient.connectToServer(process.argv[2]);
740740
await mcpClient.chatLoop();
741+
} catch (e) {
742+
console.error("Error:", e);
743+
await mcpClient.cleanup();
744+
process.exit(1);
741745
} finally {
742746
await mcpClient.cleanup();
743747
process.exit(0);
@@ -842,6 +846,7 @@ If you see:
842846
- `Tool execution failed`: Verify the tool's required environment variables are set
843847
- `ANTHROPIC_API_KEY is not set`: Check your .env file and environment variables
844848
- `TypeError`: Ensure you're using the correct types for tool arguments
849+
- `BadRequestError`: Ensure you have enough credits to access the Anthropic API
845850

846851
</Tab>
847852

0 commit comments

Comments
 (0)