new·The score now tells you which way it movedA brain's exam only ever grows: its own material writes questions, and so does every question a real caller asked and did not get answered. The score is a percentage over that growing set, so a brain that learned more could post a smaller number — and this week three did. One of them answered two MORE questions than the week before and showed eighteen points less. Printed as a single percentage, that reads as decline to a reader and as punishment to anyone who contributes material.all news →
mozg.beta
Sign in

MCP · Building servers and clients · all subjects

client: typescript

7 notes, read out of this brain and free to use. Each one was extracted from a source and is re-checked against its exam.

TypeScript MCP client: Client + StdioClientTransport

In TypeScript, import `Client` from `@modelcontextprotocol/client` and `StdioClientTransport` from `@modelcontextprotocol/client/stdio`. Construct with client identity, e.g. `new Client({ name: "mcp-client-cli", version: "1.0.0" })`, create `new StdioClientTransport({ command, args: [serverScriptPath] })`, then `await mcp.connect(transport)`. Close with `await mcp.close()`.

TypeScript tool fields use camelCase inputSchema

In the TypeScript MCP SDK, `await mcp.listTools()` returns `{ tools }` where each tool has `name`, `description` and `inputSchema` (camelCase), which must be mapped to the Anthropic SDK's `input_schema` (snake_case). Tool calls use an object argument: `await mcp.callTool({ name: toolName, arguments: toolArgs })`.

TypeScript client project setup for MCP

A TypeScript MCP client needs `npm install @anthropic-ai/sdk @modelcontextprotocol/client dotenv` plus dev deps `@types/node typescript`, `package.json` with `"type": "module"` and build script `"tsc && chmod 755 build/index.js"`, and a tsconfig with target ES2022, module Node16, moduleResolution Node16, outDir ./build, strict true. Node.js 20 or higher is required.

TypeScript sendLoggingMessage example

In the TypeScript SDK, a server sends a protocol log message with `await server.sendLoggingMessage({ level: "info", data: "Server started successfully" });`. Note that this `notifications/message` mechanism is deprecated as of protocol version 2026-07-28.

TypeScript PrivateKeyJwtProvider for JWT assertions

For JWT private-key auth in TypeScript, use `new PrivateKeyJwtProvider({ clientId: "my-service", privateKey: process.env.CLIENT_PRIVATE_KEY_PEM, algorithm: "RS256" })` from @modelcontextprotocol/client and pass it as `authProvider` to StreamableHTTPClientTransport, exactly as with ClientCredentialsProvider.

TypeScript client credentials with StreamableHTTPClientTransport

In TypeScript (`npm install @modelcontextprotocol/client`), create `new ClientCredentialsProvider({ clientId, clientSecret })`, build `new Client({name, version}, {capabilities: {}})`, then `new StreamableHTTPClientTransport(new URL("https://mcp.example.com/mcp"), { authProvider: provider })`, call `await client.connect(transport)`, use e.g. `await client.listTools()` (result has `.tools` with `.name`), and finish with `await transport.close()`.

TypeScript SDK needs additional maintainers

The TypeScript SDK is identified as needing additional maintainers for feature development and bug fixes.

Give your agent this brain