Skip to content

Commit 28fd4ad

Browse files
Merge branch 'main' into middleware-remove-console-warn
2 parents 9ee628f + cce3ac7 commit 28fd4ad

17 files changed

Lines changed: 287 additions & 44 deletions
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@modelcontextprotocol/core': patch
3+
---
4+
5+
Abort in-flight request handlers when the connection closes. Previously, request handlers would continue running after the transport disconnected, wasting resources and preventing proper cleanup. Also fixes `InMemoryTransport.close()` firing `onclose` twice on the initiating side.

.changeset/stdio-skip-non-json.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@modelcontextprotocol/core': patch
3+
---
4+
5+
`ReadBuffer.readMessage()` now silently skips non-JSON lines instead of throwing `SyntaxError`. This prevents noisy `onerror` callbacks when hot-reload tools (tsx, nodemon) write debug output like "Gracefully restarting..." to stdout. Lines that parse as JSON but fail JSONRPC schema validation still throw.

.github/workflows/conformance.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ jobs:
1818
runs-on: ubuntu-latest
1919
continue-on-error: true
2020
steps:
21-
- uses: actions/checkout@v4
21+
- uses: actions/checkout@v6
2222
- name: Install pnpm
23-
uses: pnpm/action-setup@v4
23+
uses: pnpm/action-setup@b906affcce14559ad1aafd4ab0e942779e9f58b1 # v4
2424
with:
2525
run_install: false
26-
- uses: actions/setup-node@v4
26+
- uses: actions/setup-node@v6
2727
with:
2828
node-version: 24
2929
cache: pnpm
@@ -36,12 +36,12 @@ jobs:
3636
runs-on: ubuntu-latest
3737
continue-on-error: true
3838
steps:
39-
- uses: actions/checkout@v4
39+
- uses: actions/checkout@v6
4040
- name: Install pnpm
41-
uses: pnpm/action-setup@v4
41+
uses: pnpm/action-setup@b906affcce14559ad1aafd4ab0e942779e9f58b1 # v4
4242
with:
4343
run_install: false
44-
- uses: actions/setup-node@v4
44+
- uses: actions/setup-node@v6
4545
with:
4646
node-version: 24
4747
cache: pnpm

.github/workflows/deploy-docs.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,13 @@ jobs:
2525
url: ${{ steps.deployment.outputs.page_url }}
2626

2727
steps:
28-
- uses: actions/checkout@v4
28+
- uses: actions/checkout@v6
2929

3030
- name: Install pnpm
31-
uses: pnpm/action-setup@v4
31+
uses: pnpm/action-setup@b906affcce14559ad1aafd4ab0e942779e9f58b1 # v4
3232
with:
3333
run_install: false
34-
- uses: actions/setup-node@v4
34+
- uses: actions/setup-node@v6
3535
with:
3636
node-version: 24
3737
cache: pnpm

.github/workflows/main.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
- uses: actions/checkout@v6
2020

2121
- name: Install pnpm
22-
uses: pnpm/action-setup@v4
22+
uses: pnpm/action-setup@b906affcce14559ad1aafd4ab0e942779e9f58b1 # v4
2323
id: pnpm-install
2424
with:
2525
run_install: false
@@ -44,7 +44,7 @@ jobs:
4444
- uses: actions/checkout@v6
4545

4646
- name: Install pnpm
47-
uses: pnpm/action-setup@v4
47+
uses: pnpm/action-setup@b906affcce14559ad1aafd4ab0e942779e9f58b1 # v4
4848
id: pnpm-install
4949
with:
5050
run_install: false
@@ -71,7 +71,7 @@ jobs:
7171
steps:
7272
- uses: actions/checkout@v6
7373
- name: Install pnpm
74-
uses: pnpm/action-setup@v4
74+
uses: pnpm/action-setup@b906affcce14559ad1aafd4ab0e942779e9f58b1 # v4
7575
with:
7676
run_install: false
7777
- uses: actions/setup-node@v6
@@ -81,12 +81,12 @@ jobs:
8181
cache-dependency-path: pnpm-lock.yaml
8282
- name: Set up Bun
8383
if: matrix.runtime == 'bun'
84-
uses: oven-sh/setup-bun@v2
84+
uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2
8585
with:
8686
bun-version: ${{ matrix.version }}
8787
- name: Set up Deno
8888
if: matrix.runtime == 'deno'
89-
uses: denoland/setup-deno@v2
89+
uses: denoland/setup-deno@667a34cdef165d8d2b2e98dde39547c9daac7282 # v2
9090
with:
9191
deno-version: ${{ matrix.version }}
9292
- run: pnpm install
@@ -105,14 +105,14 @@ jobs:
105105
id-token: write
106106

107107
steps:
108-
- uses: actions/checkout@v4
108+
- uses: actions/checkout@v6
109109

110110
- name: Install pnpm
111-
uses: pnpm/action-setup@v4
111+
uses: pnpm/action-setup@b906affcce14559ad1aafd4ab0e942779e9f58b1 # v4
112112
id: pnpm-install
113113
with:
114114
run_install: false
115-
- uses: actions/setup-node@v4
115+
- uses: actions/setup-node@v6
116116
with:
117117
node-version: 24
118118
cache: pnpm

.github/workflows/publish.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
- uses: actions/checkout@v6
2020

2121
- name: Install pnpm
22-
uses: pnpm/action-setup@v4
22+
uses: pnpm/action-setup@b906affcce14559ad1aafd4ab0e942779e9f58b1 # v4
2323
with:
2424
run_install: false
2525

.github/workflows/release.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
- uses: actions/checkout@v6
2020

2121
- name: Install pnpm
22-
uses: pnpm/action-setup@v4
22+
uses: pnpm/action-setup@b906affcce14559ad1aafd4ab0e942779e9f58b1 # v4
2323
with:
2424
run_install: false
2525

@@ -36,7 +36,7 @@ jobs:
3636

3737
- name: Create Release Pull Request or Publish to npm
3838
id: changesets
39-
uses: changesets/action@v1
39+
uses: changesets/action@6a0a831ff30acef54f2c6aa1cbbc1096b066edaf # v1
4040
with:
4141
publish: pnpm run build:all && pnpm changeset publish
4242
env:

.github/workflows/update-spec-types.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
uses: actions/checkout@v6
1919

2020
- name: Install pnpm
21-
uses: pnpm/action-setup@v4
21+
uses: pnpm/action-setup@b906affcce14559ad1aafd4ab0e942779e9f58b1 # v4
2222
id: pnpm-install
2323
with:
2424
run_install: false

docs/server.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,26 @@ server.registerTool(
330330
>
331331
> For protocol details, see [Logging](https://modelcontextprotocol.io/specification/latest/server/utilities/logging) in the MCP specification.
332332
333+
## Instructions
334+
335+
Pass an `instructions` string in the server options to describe how to use the server and its features. This can be used by clients to improve the LLM's understanding of available tools, resources, and prompts. It can be thought of like a "hint" to the model — for example, a client MAY add it to the system prompt. See [Instructions](https://modelcontextprotocol.io/specification/latest/basic/lifecycle#instructions) in the MCP specification.
336+
337+
```ts source="../examples/server/src/serverGuide.examples.ts#instructions_basic"
338+
const server = new McpServer(
339+
{
340+
name: 'multi-tool-server',
341+
version: '1.0.0'
342+
},
343+
{
344+
instructions: `This server provides data-pipeline tools. Always call "validate-schema"
345+
before calling "transform-data" to avoid runtime errors.`
346+
}
347+
);
348+
```
349+
350+
> [!TIP]
351+
> Use instructions for cross-tool relationships, workflow ordering, and constraints that individual tool descriptions cannot express on their own.
352+
333353
## Server‑initiated requests
334354

335355
MCP is bidirectional — servers can also send requests *to* the client during tool execution, as long as the client declares matching capabilities.

examples/server/src/serverGuide.examples.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,27 @@ import type { CallToolResult, ResourceLink } from '@modelcontextprotocol/server'
1515
import { completable, McpServer, ResourceTemplate, StdioServerTransport } from '@modelcontextprotocol/server';
1616
import * as z from 'zod/v4';
1717

18+
// ---------------------------------------------------------------------------
19+
// Instructions
20+
// ---------------------------------------------------------------------------
21+
22+
/** Example: Providing server instructions to guide LLM usage. */
23+
function instructions_basic() {
24+
//#region instructions_basic
25+
const server = new McpServer(
26+
{
27+
name: 'multi-tool-server',
28+
version: '1.0.0'
29+
},
30+
{
31+
instructions: `This server provides data-pipeline tools. Always call "validate-schema"
32+
before calling "transform-data" to avoid runtime errors.`
33+
}
34+
);
35+
//#endregion instructions_basic
36+
return server;
37+
}
38+
1839
// ---------------------------------------------------------------------------
1940
// Tools, resources, and prompts
2041
// ---------------------------------------------------------------------------
@@ -373,6 +394,7 @@ function dnsRebinding_allowedHosts() {
373394
}
374395

375396
// Suppress unused-function warnings (functions exist solely for type-checking)
397+
void instructions_basic;
376398
void registerTool_basic;
377399
void registerTool_resourceLink;
378400
void registerTool_logging;

0 commit comments

Comments
 (0)