|
14 | 14 | - [Overview](#overview) |
15 | 15 | - [Packages](#packages) |
16 | 16 | - [Installation](#installation) |
17 | | -- [Quick Start (runnable examples)](#quick-start-runnable-examples) |
| 17 | +- [Getting Started](#getting-started) |
18 | 18 | - [Documentation](#documentation) |
19 | 19 | - [Contributing](#contributing) |
20 | 20 | - [License](#license) |
@@ -90,59 +90,53 @@ npm install @modelcontextprotocol/express express |
90 | 90 | npm install @modelcontextprotocol/hono hono |
91 | 91 | ``` |
92 | 92 |
|
93 | | -## Quick Start (runnable examples) |
| 93 | +## Getting Started |
94 | 94 |
|
95 | | -The runnable examples live under `examples/` and are kept in sync with the docs. |
| 95 | +Here is what an MCP server looks like. This minimal example exposes a single `greet` tool over stdio: |
96 | 96 |
|
97 | | -1. **Install dependencies** (from repo root): |
| 97 | +```typescript |
| 98 | +import { McpServer, StdioServerTransport } from '@modelcontextprotocol/server'; |
| 99 | +import * as z from 'zod/v4'; |
98 | 100 |
|
99 | | -```bash |
100 | | -pnpm install |
101 | | -``` |
102 | | - |
103 | | -2. **Run a Streamable HTTP example server**: |
104 | | - |
105 | | -```bash |
106 | | -pnpm --filter @modelcontextprotocol/examples-server exec tsx src/simpleStreamableHttp.ts |
107 | | -``` |
| 101 | +const server = new McpServer({ name: 'greeting-server', version: '1.0.0' }); |
108 | 102 |
|
109 | | -Alternatively, from within the example package: |
| 103 | +server.registerTool( |
| 104 | + 'greet', |
| 105 | + { |
| 106 | + description: 'Greet someone by name', |
| 107 | + inputSchema: z.object({ name: z.string() }), |
| 108 | + }, |
| 109 | + async ({ name }) => ({ |
| 110 | + content: [{ type: 'text', text: `Hello, ${name}!` }], |
| 111 | + }), |
| 112 | +); |
110 | 113 |
|
111 | | -```bash |
112 | | -cd examples/server |
113 | | -pnpm tsx src/simpleStreamableHttp.ts |
114 | | -``` |
115 | | - |
116 | | -3. **Run the interactive client in another terminal**: |
| 114 | +async function main() { |
| 115 | + const transport = new StdioServerTransport(); |
| 116 | + await server.connect(transport); |
| 117 | +} |
117 | 118 |
|
118 | | -```bash |
119 | | -pnpm --filter @modelcontextprotocol/examples-client exec tsx src/simpleStreamableHttp.ts |
| 119 | +main(); |
120 | 120 | ``` |
121 | 121 |
|
122 | | -Alternatively, from within the example package: |
| 122 | +Ready to build something real? Follow the step-by-step quickstart tutorials: |
123 | 123 |
|
124 | | -```bash |
125 | | -cd examples/client |
126 | | -pnpm tsx src/simpleStreamableHttp.ts |
127 | | -``` |
| 124 | +- [Build a weather server](docs/server-quickstart.md) — server quickstart |
| 125 | +- [Build an LLM-powered chatbot](docs/client-quickstart.md) — client quickstart |
128 | 126 |
|
129 | | -Next steps: |
| 127 | +The complete code for each tutorial is in [`examples/server-quickstart/`](https://github.com/modelcontextprotocol/typescript-sdk/tree/main/examples/server-quickstart/) and [`examples/client-quickstart/`](https://github.com/modelcontextprotocol/typescript-sdk/tree/main/examples/client-quickstart/). For more advanced runnable examples, see: |
130 | 128 |
|
131 | | -- Server examples index: [`examples/server/README.md`](examples/server/README.md) |
132 | | -- Client examples index: [`examples/client/README.md`](examples/client/README.md) |
133 | | -- Guided walkthroughs: [`docs/server.md`](docs/server.md) and [`docs/client.md`](docs/client.md) |
| 129 | +- [`examples/server/README.md`](examples/server/README.md) — server examples index |
| 130 | +- [`examples/client/README.md`](examples/client/README.md) — client examples index |
134 | 131 |
|
135 | 132 | ## Documentation |
136 | 133 |
|
137 | | -- Local SDK docs: |
138 | | - - [docs/server.md](docs/server.md) – building MCP servers: transports, tools, resources, prompts, server-initiated requests, and deployment |
139 | | - - [docs/client.md](docs/client.md) – building MCP clients: connecting, tools, resources, prompts, server-initiated requests, and error handling |
140 | | - - [docs/faq.md](docs/faq.md) – frequently asked questions and troubleshooting |
141 | | -- External references: |
142 | | - - [SDK API documentation](https://ts.sdk.modelcontextprotocol.io/) |
143 | | - - [Model Context Protocol documentation](https://modelcontextprotocol.io) |
144 | | - - [MCP Specification](https://spec.modelcontextprotocol.io) |
145 | | - - [Example Servers](https://github.com/modelcontextprotocol/servers) |
| 134 | +- [Server Guide](docs/server.md) — building MCP servers: transports, tools, resources, prompts, server-initiated requests, and deployment |
| 135 | +- [Client Guide](docs/client.md) — building MCP clients: connecting, tools, resources, prompts, server-initiated requests, and error handling |
| 136 | +- [FAQ](docs/faq.md) — frequently asked questions and troubleshooting |
| 137 | +- [API docs](https://modelcontextprotocol.github.io/typescript-sdk/) |
| 138 | +- [MCP documentation](https://modelcontextprotocol.io/docs) |
| 139 | +- [MCP specification](https://modelcontextprotocol.io/specification/latest) |
146 | 140 |
|
147 | 141 | ### Building docs locally |
148 | 142 |
|
|
0 commit comments