# AI use cases for TypeScript SDK (modelcontextprotocol/typescript-sdk)

Repo: [modelcontextprotocol/typescript-sdk](https://github.com/modelcontextprotocol/typescript-sdk) | Use cases: 3 | Page: https://dedupedai.com/use-cases/modelcontextprotocol-typescript-sdk/

The official TypeScript SDK for Model Context Protocol servers and clients. It ships separate server and client packages, plus thin optional middleware adapters for Node.js HTTP, Express, Fastify and Hono, so you can expose tools to AI agents or connect to existing MCP servers from TypeScript.

This file holds every use case of this repo. Each one starts with a "## " heading and ends with its URL.

- Build your first MCP tool server in TypeScript: https://dedupedai.com/use-cases/modelcontextprotocol-typescript-sdk/build-a-stdio-mcp-tool-server-with-the-typescript-sdk/
- Serve MCP tools over HTTP from an Express app: https://dedupedai.com/use-cases/modelcontextprotocol-typescript-sdk/serve-mcp-over-http-with-express-and-the-typescript-sdk/
- Call existing MCP servers from your own app: https://dedupedai.com/use-cases/modelcontextprotocol-typescript-sdk/call-mcp-servers-from-your-app-with-the-typescript-sdk/

## How to build your first MCP tool server in TypeScript with TypeScript SDK

Repo: [modelcontextprotocol/typescript-sdk](https://github.com/modelcontextprotocol/typescript-sdk) | Difficulty: Intermediate | Time: 45 minutes | Basis: From the README

Expose a function as an MCP tool over stdio so Claude Code, Cursor or any MCP client can call it.

**Who it is for:** A developer who wants an AI agent to use one of their own functions.

**The problem:** Agents cannot call your internal logic until it is wrapped in a protocol they speak.

**The outcome:** A running stdio MCP server with one registered tool that any MCP client can list and call.

### Steps

1. Install the server package with `npm install @modelcontextprotocol/server`
2. Create an McpServer with a name and version, as in the README Getting Started example
3. Register a tool with server.registerTool, giving it a description and a zod inputSchema, like the greet example
4. Connect a StdioServerTransport with server.connect and add the server to your MCP client

### Prompt to paste into your agent

```text
Using modelcontextprotocol/typescript-sdk, install it with `npm install @modelcontextprotocol/server` and build a stdio MCP server that exposes <my function> as a tool with registerTool and a zod inputSchema, following the greet example.
```

### Caveat

The README points to the docs tutorials for a full weather alert server; the snippet is a minimal greet tool.

Risk, permissions: Any tool you register can be called by the connected agent, so do not expose functions that delete data or spend money without your own checks.

Disclaimer: Third-party repos we don't own or vouch for. AI-generated use cases can be wrong: review everything and run at your own risk. Full text: https://dedupedai.com/disclaimer/

URL: https://dedupedai.com/use-cases/modelcontextprotocol-typescript-sdk/build-a-stdio-mcp-tool-server-with-the-typescript-sdk/

## How to serve MCP tools over HTTP from an Express app with TypeScript SDK

Repo: [modelcontextprotocol/typescript-sdk](https://github.com/modelcontextprotocol/typescript-sdk) | Difficulty: Advanced | Time: 2 hours | Basis: From the README

Add the Express middleware package so an existing web service can offer MCP tools over the Streamable HTTP transport.

**Who it is for:** A backend developer who already runs an Express or Fastify service.

**The problem:** A stdio server only works locally; remote agents need an HTTP endpoint.

**The outcome:** Your existing web app answering MCP requests next to its normal routes.

### Steps

1. Install the server package with `npm install @modelcontextprotocol/server`
2. Add the adapter with `npm install @modelcontextprotocol/express express`, or `npm install @modelcontextprotocol/fastify fastify` for Fastify
3. For plain Node.js HTTP use `npm install @modelcontextprotocol/node` for the Streamable HTTP transport
4. Register your tools on an McpServer and mount it through the adapter, following the middleware README

### Prompt to paste into your agent

```text
With modelcontextprotocol/typescript-sdk, add MCP to my Express service <repo path>: run `npm install @modelcontextprotocol/express express`, register <my tools> on an McpServer and expose it over Streamable HTTP.
```

### Caveat

The README says the middleware packages are intentionally thin adapters and add no MCP features or business logic of their own.

Risk, security: An HTTP MCP endpoint is reachable by anyone who can reach the server, so put authentication in front of it before exposing it publicly.

Disclaimer: Third-party repos we don't own or vouch for. AI-generated use cases can be wrong: review everything and run at your own risk. Full text: https://dedupedai.com/disclaimer/

URL: https://dedupedai.com/use-cases/modelcontextprotocol-typescript-sdk/serve-mcp-over-http-with-express-and-the-typescript-sdk/

## How to call existing MCP servers from your own app with TypeScript SDK

Repo: [modelcontextprotocol/typescript-sdk](https://github.com/modelcontextprotocol/typescript-sdk) | Difficulty: Intermediate | Time: 1 hour | Basis: From the README

Use the client package to connect to an MCP server, list its tools and call them from TypeScript code.

**Who it is for:** A developer building an agent or app that should reuse community MCP servers.

**The problem:** Writing a custom integration for every service is slow when an MCP server already exists.

**The outcome:** A TypeScript client that discovers and calls the tools of any MCP server.

### Steps

1. Install the client package with `npm install @modelcontextprotocol/client`, or `bun add @modelcontextprotocol/client`
2. Follow the README's Build your first client tutorial to connect to a server
3. List the server's tools, then call the ones your app needs
4. Use the runnable client and server pairs in examples/README.md as references

### Prompt to paste into your agent

```text
Using modelcontextprotocol/typescript-sdk, install `npm install @modelcontextprotocol/client` and write a small script that connects to <my MCP server>, lists its tools and calls <tool name>.
```

### Caveat

This README covers the v2 packages; the v1 legacy docs and fixes live on a separate branch.

Disclaimer: Third-party repos we don't own or vouch for. AI-generated use cases can be wrong: review everything and run at your own risk. Full text: https://dedupedai.com/disclaimer/

URL: https://dedupedai.com/use-cases/modelcontextprotocol-typescript-sdk/call-mcp-servers-from-your-app-with-the-typescript-sdk/
