About Anthropic SDK Typescript
Anthropic SDK Typescript is an MCP server published by anthropics in the Developer Tools category: access to Anthropic's safety-first language model APIs in TypeScript.
The repository has 2.1K stars and 423 forks, with the last commit 2 days ago. Recent commit activity is the strongest signal that reported issues will get attention.
Install
git clone https://github.com/anthropics/anthropic-sdk-typescriptThis server has no ConduID identity, so agent calls to it are not receipted. Pin the version you install and review the source before granting it credentials.
Ask AI
Ask AI about Anthropic SDK Typescript
Powered by Claude · Grounded in docs
Security checks
Static checks derived from the repository 14 hours ago. Heuristics on the source, not an audit.
- ✓README presentThe repository ships documentation.
- ✓License declaredUsable under a stated license.
- ✓Tests presentA test suite exists in the repository.
- ✓Dependencies pinnedA lockfile pins dependency versions.
- !No dynamic code executionSource scan found eval or shell execution. Review how tool inputs reach it before granting credentials.
- !Scoped permissionsDoesn't declare a permission scope. Assume it can do anything its process can.
Releases
README
Claude SDK for TypeScript
The Claude SDK for TypeScript provides access to the Claude API from server-side TypeScript or JavaScript applications.
Documentation
SDK helpers (streaming, structured outputs, tool helpers and the tool runner) are documented in helpers.md. The browser and computer toolset classes have their own guides, browser-toolset.md and computer-toolset.md.
Full documentation is available at platform.claude.com/docs/en/api/sdks/typescript.
Installation
npm install @anthropic-ai/sdk
Getting started
import Anthropic from '@anthropic-ai/sdk';
const client = new Anthropic({
apiKey: process.env['ANTHROPIC_API_KEY'], // This is the default and can be omitted
});
const message = await client.messages.create({
max_tokens: 1024,
messages: [{ role: 'user', content: 'Hello, Claude' }],
model: 'claude-opus-5-5',
});
console.log(message.content);
Requirements
TypeScript >= 5.0 is supported.
The following runtimes are supported:
- Node.js 20 LTS or later (non-EOL) versions.
- Deno v1.28.0 or higher.
- Bun 1.0 or later.
- Cloudflare Workers.
- Vercel Edge Runtime.
- Jest 28 or greater with the
"node"environment ("jsdom"is not supported at this time). - Nitro v2.6 or greater.
- Web browsers: disabled by default to avoid exposing your secret API credentials (see API key best practices). Enable browser support by explicitly setting
dangerouslyAllowBrowsertotrue.
Note that React Native is not supported at this time.
If you are interested in other runtime environments, please open or upvote an issue.
OpenTelemetry
The SDK reports each API call as an OpenTelemetry span once your application has registered a tracer provider with @opentelemetry/api, which the SDK depends on.
Spans are on by default, so there is nothing to enable on the client.
The openTelemetry client option selects another tracer provider, turns the spans or the trace headers off, or, with traces.contentMode: 'content', adds the content of requests and responses to them.
const client = new Anthropic({ openTelemetry: { tracerProvider } }); // a provider other than the registered one
const quiet = new Anthropic({ openTelemetry: false }); // no spans
const detailed = new Anthropic({
openTelemetry: { traces: { contentMode: 'content', maxContentBytes: 65_536 } }, // content, up to about 64 KiB a span
});
const unpropagated = new Anthropic({ openTelemetry: { propagation: false } }); // spans, and no trace headers on the requests
await client.messages.create(params, { openTelemetry: { conversationId } }); // sets gen_ai.conversation.id
traces is a boolean, or an object with enabled, contentMode and maxContentBytes.
With each request the client sends the trace context of its span, as the headers that your registered propagator writes: traceparent, and tracestate and baggage when it writes them.
propagation: false sends none of them and leaves the spans as they are, for an application whose HTTP client instrumentation already propagates the trace context, so that a request does not carry it twice.
A field that the option leaves unset has its default.
A client without the option reads these environment variables once, when it is constructed: ANTHROPIC_OPEN_TELEMETRY=false turns its spans off, ANTHROPIC_OPEN_TELEMETRY_PROPAGATION=false turns propagation off, and ANTHROPIC_OPEN_TELEMETRY_TRACES_CONTENT_MODE and ANTHROPIC_OPEN_TELEMETRY_TRACES_MAX_CONTENT_BYTES give contentMode and maxContentBytes.
A client with the option does not read them.
client.openTelemetry is the option as the client settled it.
A withOptions() copy that passes openTelemetry uses that in place of the client's whole option, so spread the settled one to change a single setting:
const { openTelemetry } = client;
const withContent = client.withOptions({
openTelemetry: { ...openTelemetry, traces: { ...openTelemetry.traces, contentMode: 'content' } },
});
Contributing
See CONTRIBUTING.md.
License
This project is licensed under the MIT License. See the LICENSE file for details.
README fetched from the repository 14 hours ago. The original is authoritative.