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