Skip to content

Commit 5516c1b

Browse files
chore: add instructions docs (#1778)
1 parent 01954e6 commit 5516c1b

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed

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)