typescript changedcli-sdks-libraries/sdks/typescript
Nearest release: v2.1.238, published under an hour after this site recorded the change. Shown because the two are within 24 hours of each other. Nothing here says the release caused the edit.
Recorded here
Lines+9added
Lines−23removed
From line
270
where the diff opens
First seen
14 Aug 2026
this site's first read of the page
Recorded edits12to this page, all time
The whole hunk
from line 270, old and new numbered
/
from line 270
270270
271271// Upload MCP resources as files
272272const fileResource = await mcpClient.readResource({ uri: "file:///path/to/data.json" });
273await anthropic.beta.files.upload({ file: mcpResourceToFile(fileResource) });
273await anthropic.files.upload({ file: mcpResourceToFile(fileResource) });
274274```
275275
276276### MCP error handling
from line 339
339339const client = new Anthropic();
340340
341341// If you have access to Node `fs`, use `fs.createReadStream()`:
342await client.beta.files.upload({
342await client.files.upload({
343343 file: await toFile(fs.createReadStream("/path/to/file"), undefined, {
344344 type: "application/json"
345345 })
from line 346
346346});
347347
348348// Or if you have the web `File` API you can pass a `File` instance:
349await client.beta.files.upload({
349await client.files.upload({
350350 file: new File(["my bytes"], "file.txt", { type: "text/plain" })
351351});
352352// You can also pass a `fetch` `Response`:
353await client.beta.files.upload({
353await client.files.upload({
354354 file: await fetch("https://somesite/file")
355355});
356356
357357// Or a `Buffer` / `Uint8Array`
358await client.beta.files.upload({
358await client.files.upload({
359359 file: await toFile(Buffer.from("my bytes"), "file", { type: "text/plain" })
360360});
361await client.beta.files.upload({
361await client.files.upload({
362362 file: await toFile(new Uint8Array([0, 1, 2]), "file", { type: "text/plain" })
363363});
364364```
from line 730
730730
731731You can access most beta API features through the beta property of the client. To enable a particular beta feature, you need to add the appropriate [beta header](https://platform.claude.com/docs/en/api/beta-headers) to the `betas` field when creating a message.
732732
733For example, to use the [Files API](https://platform.claude.com/docs/en/build-with-claude/files):
733For example, to enable [context editing](https://platform.claude.com/docs/en/build-with-claude/context-editing):
734734
735735```typescript
736736const client = new Anthropic();
from line 737
737737const response = await client.beta.messages.create({
738738 model: "claude-opus-5",
739739 max_tokens: 1024,
740 messages: [
741 {
742 role: "user",
743 content: [
744 { type: "text", text: "Please summarize this document for me." },
745 {
746 type: "document",
747 source: {
748 type: "file",
749 file_id: "file_abc123"
750 }
751 }
752 ]
753 }
754 ],
755 betas: ["files-api-2025-04-14"]
740 messages: [{ role: "user", content: "Hello, Claude" }],
741 betas: ["context-management-2025-06-27"]
756742});
757743```
758744
No line in this hunk matches that.