Urgent.News

What's breaking now, across thousands of outlets.

Tech

Connect to Any MCP Server in TypeScript Over stdio and HTTP, Then List Its Tools

Most people meet the Model Context Protocol (MCP) through a client like Claude Desktop, where a config file quietly wires up servers and you never see the handshake. But the protocol is just a client and a server talking over a transport, and the official TypeScript SDK gives you every piece you need to do that yourself. In this tutorial I want to show you how to connect to an MCP server…

Connecting to an MCP server in TypeScript is achievable using either stdio or HTTP transports, with the official TypeScript SDK providing all necessary components to perform these tasks. This tutorial demonstrates how to establish connections over both interfaces and enumerate the server's tools, resources, and prompts. By leveraging the SDK, developers can easily write their own clients, create server indexes, or scan servers for trustworthiness.

The tutorial grounds the code in mcp-audit, a security scanner built for this purpose, although the technique is reusable for various use cases. The protocol comprises three core elements: a transport that carries bytes over stdin/stdout (stdio) or HTTP, a Client that communicates the MCP protocol over the chosen transport, and capability calls like listTools() asking the server for its offerings.

The SDK design allows the Client to be transport-agnostic, so developers only need to build the transport and integrate it into their code. To get started, install the SDK package and ensure Node 18 or newer is installed, setting `type: "module"` in package.json as the SDK ships as ESM. The first transport, StdioClientTransport, enables connections to local servers by spawning a child process with the provided command and options.

It handles MCP messages sent to stdout, while stderr captures server logs to prevent them from corrupting the stream. For remote servers, StreamableHTTPClientTransport or SSEClientTransport can be used, both of which inherit from the Transport interface, allowing the same probe function to operate on either transport. The probe function accepts any Transport object, connects to the server, retrieves the server version, and enumerates tools offered by the server, demonstrating the power and flexibility of the MCP protocol.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

Understanding Hoisting in JavaScript: var, let, const, and Functions

JavaScript hoisting is one of those concepts that looks simple at first but can cause confusing bugs when declarations appear to work before they are written.

  • JavaScript hoisting prepares declarations before code execution
  • Function declarations initialized during creation phase
  • Var variables contain undefined before assignment

Keeping an archived 800-star Roblox tool alive: MultiAlt, in Rust and Tauri

The original Roblox Account Manager by ic3w0lf22 helped millions of players run several Roblox accounts on one PC: its last release has over 2 million downloads.

  • MultiAlt project maintains Roblox tool legacy with Rust, TypeScript, Tauri
  • Supports multiple open clients, account groups, AFK mode, auto-rejoin
  • Encrypted storage, per-user MSI installer, multi-language support

Segurança e governança em infraestrutura - secrets management na prática

1. Uma nova série: segurança e governança em infraestrutura Provisionar infraestrutura com código, versionar tudo em Git e automatizar o deploy resolve boa parte dos problemas operacionais de um time…

  • Secrets management protects sensitive data in infrastructure automation
  • HashiCorp Vault is widely used for secure secret storage with access controls
  • Terraform integration fetches secrets in real-time without committing to version control

More from Monday 5 October →