Skip to content

Commit c49f054

Browse files
committed
chore: unify quickstart tsconfigs with shared base, fix doc drift
- Make examples/{client,server}-quickstart extend @modelcontextprotocol/tsconfig instead of carrying standalone compilerOptions. Drop the inline target/lib/ module/moduleResolution/strict/etc. duplicates; only outDir, rootDir, declaration overrides, and workspace paths remain. - Align docs/{client,server}-quickstart.md tsconfig snippets to ESNext/bundler to match what the example projects now compile under. - Adjust examples/client-quickstart/src/index.ts for the stricter noUncheckedIndexedAccess inherited from the shared base. - Strip leftover .js suffixes from vi.mock / vi.importActual string specifiers in packages/client/test/client/middleware.test.ts.
1 parent e886551 commit c49f054

9 files changed

Lines changed: 30 additions & 27 deletions

File tree

docs/client-quickstart.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,8 @@ Create a `tsconfig.json` in the root of your project:
9090
"compilerOptions": {
9191
"target": "ES2023",
9292
"lib": ["ES2023"],
93-
"module": "Node16",
94-
"moduleResolution": "Node16",
93+
"module": "ESNext",
94+
"moduleResolution": "bundler",
9595
"outDir": "./build",
9696
"rootDir": "./src",
9797
"strict": true,
@@ -236,7 +236,8 @@ Now let's add the core functionality for processing queries and handling tool ca
236236
messages,
237237
});
238238

239-
finalText.push(followUp.content[0].type === 'text' ? followUp.content[0].text : '');
239+
const firstBlock = followUp.content[0];
240+
finalText.push(firstBlock?.type === 'text' ? firstBlock.text : '');
240241
}
241242
}
242243

@@ -284,13 +285,14 @@ Finally, we'll add the main execution logic:
284285

285286
```ts source="../examples/client-quickstart/src/index.ts#main"
286287
async function main() {
287-
if (process.argv.length < 3) {
288+
const serverScriptPath = process.argv[2];
289+
if (!serverScriptPath) {
288290
console.log('Usage: node build/index.js <path_to_server_script>');
289291
return;
290292
}
291293
const mcpClient = new MCPClient();
292294
try {
293-
await mcpClient.connectToServer(process.argv[2]);
295+
await mcpClient.connectToServer(serverScriptPath);
294296

295297
// Check if we have a valid API key to continue
296298
const apiKey = process.env.ANTHROPIC_API_KEY;

docs/server-quickstart.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,8 @@ Create a `tsconfig.json` in the root of your project:
104104
{
105105
"compilerOptions": {
106106
"target": "ES2022",
107-
"module": "Node16",
108-
"moduleResolution": "Node16",
107+
"module": "ESNext",
108+
"moduleResolution": "bundler",
109109
"outDir": "./build",
110110
"rootDir": "./src",
111111
"strict": true,

examples/client-quickstart/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"@modelcontextprotocol/client": "workspace:^"
1616
},
1717
"devDependencies": {
18+
"@modelcontextprotocol/tsconfig": "workspace:^",
1819
"@types/node": "^24.10.1",
1920
"typescript": "catalog:devTools"
2021
}

examples/client-quickstart/src/index.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,8 @@ class MCPClient {
116116
messages,
117117
});
118118

119-
finalText.push(followUp.content[0].type === 'text' ? followUp.content[0].text : '');
119+
const firstBlock = followUp.content[0];
120+
finalText.push(firstBlock?.type === 'text' ? firstBlock.text : '');
120121
}
121122
}
122123

@@ -156,13 +157,14 @@ class MCPClient {
156157

157158
//#region main
158159
async function main() {
159-
if (process.argv.length < 3) {
160+
const serverScriptPath = process.argv[2];
161+
if (!serverScriptPath) {
160162
console.log('Usage: node build/index.js <path_to_server_script>');
161163
return;
162164
}
163165
const mcpClient = new MCPClient();
164166
try {
165-
await mcpClient.connectToServer(process.argv[2]);
167+
await mcpClient.connectToServer(serverScriptPath);
166168

167169
// Check if we have a valid API key to continue
168170
const apiKey = process.env.ANTHROPIC_API_KEY;

examples/client-quickstart/tsconfig.json

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,10 @@
11
{
2+
"extends": "@modelcontextprotocol/tsconfig",
23
"compilerOptions": {
3-
"target": "ES2023",
4-
"lib": ["ES2023"],
5-
"module": "ESNext",
6-
"moduleResolution": "bundler",
74
"outDir": "./build",
85
"rootDir": "./src",
9-
"strict": true,
10-
"esModuleInterop": true,
11-
"skipLibCheck": true,
12-
"forceConsistentCasingInFileNames": true,
6+
"declaration": false,
7+
"declarationMap": false,
138
"paths": {
149
"@modelcontextprotocol/client": ["./node_modules/@modelcontextprotocol/client/src/index.ts"],
1510
"@modelcontextprotocol/client/stdio": ["./node_modules/@modelcontextprotocol/client/src/stdio.ts"],

examples/server-quickstart/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"zod": "catalog:runtimeShared"
1616
},
1717
"devDependencies": {
18+
"@modelcontextprotocol/tsconfig": "workspace:^",
1819
"@types/node": "^24.10.1",
1920
"typescript": "catalog:devTools"
2021
}

examples/server-quickstart/tsconfig.json

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
11
{
2+
"extends": "@modelcontextprotocol/tsconfig",
23
"compilerOptions": {
3-
"target": "ES2022",
4-
"module": "ESNext",
5-
"moduleResolution": "bundler",
64
"outDir": "./build",
75
"rootDir": "./src",
8-
"strict": true,
9-
"esModuleInterop": true,
10-
"skipLibCheck": true,
11-
"forceConsistentCasingInFileNames": true,
6+
"declaration": false,
7+
"declarationMap": false,
128
"paths": {
139
"@modelcontextprotocol/server": ["./node_modules/@modelcontextprotocol/server/src/index.ts"],
1410
"@modelcontextprotocol/server/stdio": ["./node_modules/@modelcontextprotocol/server/src/stdio.ts"],

packages/client/test/client/middleware.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import type { Mocked, MockedFunction, MockInstance } from 'vitest';
44
import type { OAuthClientProvider } from '../../src/client/auth';
55
import { applyMiddlewares, createMiddleware, withLogging, withOAuth } from '../../src/client/middleware';
66

7-
vi.mock('../../src/client/auth.js', async () => {
8-
const actual = await vi.importActual<typeof import('../../src/client/auth')>('../../src/client/auth.js');
7+
vi.mock('../../src/client/auth', async () => {
8+
const actual = await vi.importActual<typeof import('../../src/client/auth')>('../../src/client/auth');
99
return {
1010
...actual,
1111
auth: vi.fn(),

pnpm-lock.yaml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)