Commit graph quickstart-resources/mcp-client-typescript/index.ts
Author SHA1 Message Date
olaservo
1a0ad1cc80 Fix tool use in TypeScript client, mirroring #141
Apply the same Messages API tool-use fixes that #141 made to the Python
client (mcp-client-python/client.py) to mcp-client-typescript/index.ts:

- Reply to each tool_use with a proper tool_result block carrying
  tool_use_id, and append the assistant's full content (preserving the
  tool_use block) instead of sending the result as a plain user string.
- Restructure processQuery into a turn-level loop so parallel tool calls
  in one response and chained tool calls across turns both work; pass
  tools on every follow-up request.
- Add MAX_TOOL_TURNS = 10 cap with a "[Stopped after N tool-use turns]"
  notice to prevent unbounded tool-use loops.
- Fix chatLoop to exit cleanly on EOF (Ctrl-D) and SIGINT (Ctrl-C) via
  an AbortController wired to readline close, instead of hanging or
  throwing on stdin EOF.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-05-30 11:47:53 -07:00
Jonathan Hefner
bd27d306c0
Implement smoke test for clients and servers (#76)
This commit adds `tests/smoke-test.sh`, which performs a smoke test of
all clients and servers. The smoke test tests that the clients and
servers run and that list tools is called.

This commit also adds a GitHub Actions workflow to run the smoke test on
all pull requests and pushes to main.

For practicality, this commit modifies the TypeScript and Python clients
to lazily initialize the Anthropic client, thus allowing tests to skip
setting an API key. This change also provides a friendly error when
users forget to set an API key.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Alex Akimov <alexeyakimov@gmail.com>
2026-02-01 10:57:45 +01:00
Jonathan Hefner
811d46212a
Merge pull request #27 from tmokmss/patch-1
await mcp.connect
2025-12-12 09:44:02 -06:00
Jonathan Hefner
c2cc47f5cd
Merge pull request #33 from thisistonydang/thisistonydang/catch-error
Add catch block to prevent silent failure in example TypeScript MCP client (mcp-client-typescript)
2025-12-12 09:39:00 -06:00
Alex Akimov
dd19be8d20 Revert unnecessary change 2025-11-09 18:25:47 +01:00
Alex Akimov
30655fc09c Refactor the Python client to define the model only once 2025-11-09 18:16:45 +01:00
Yichi Zhang
9929168cb8 Update sonnet version in typescript folder 2025-10-06 13:31:27 -07:00
David Soria Parra
6d5cb10fd3
Merge pull request #30 from jrgtt/main
Remove unused variable `toolResults`
2025-09-26 22:04:44 +01:00
Ido Cohen
dede2bce69 change model to claude-sonnet-4-0 2025-09-25 12:33:34 +03:00
Ido Cohen
7886d3c1be replace claude-3-5-sonnet-20241022 with claude-3-7-sonnet-latest 2025-08-24 00:29:22 +03:00
Tony Dang
083ce1d18b
add catch block 2025-05-09 09:03:58 -07:00
Jean Rigotti
266c3b3baf Remove unused variable toolResults 2025-04-02 11:40:53 -03:00
Masashi Tomooka
b5f0935306
await mcp.connect 2025-03-26 22:22:06 +09:00
Allen Zhou
7b68e28f05 Prettier formatting 2025-02-19 10:30:17 -08:00
Allen Zhou
7404384908 Update index.ts 2025-02-17 17:01:51 -08:00
Allen Zhou
0aef1e60e9 Only list tools on initialization 2025-02-17 17:01:28 -08:00
Allen Zhou
e065b112f2 Cleaner rl handling 2025-02-17 16:30:39 -08:00
Allen Zhou
f5637a04a2 Add explanatory comments 2025-02-17 16:28:06 -08:00
Allen Zhou
0411bf6975 Add mcp-client-typescript 2025-02-17 11:16:18 -08:00