Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions docs/server.md
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,26 @@ server.registerTool(
>
> For protocol details, see [Logging](https://modelcontextprotocol.io/specification/latest/server/utilities/logging) in the MCP specification.

## Instructions

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.

```ts source="../examples/server/src/serverGuide.examples.ts#instructions_basic"
const server = new McpServer(
{
name: 'multi-tool-server',
version: '1.0.0'
},
{
instructions: `This server provides data-pipeline tools. Always call "validate-schema"
before calling "transform-data" to avoid runtime errors.`
}
);
```

> [!TIP]
> Use instructions for cross-tool relationships, workflow ordering, and constraints that individual tool descriptions cannot express on their own.

## Server‑initiated requests

MCP is bidirectional — servers can also send requests *to* the client during tool execution, as long as the client declares matching capabilities.
Expand Down
22 changes: 22 additions & 0 deletions examples/server/src/serverGuide.examples.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,27 @@ import type { CallToolResult, ResourceLink } from '@modelcontextprotocol/server'
import { completable, McpServer, ResourceTemplate, StdioServerTransport } from '@modelcontextprotocol/server';
import * as z from 'zod/v4';

// ---------------------------------------------------------------------------
// Instructions
// ---------------------------------------------------------------------------

/** Example: Providing server instructions to guide LLM usage. */
function instructions_basic() {
//#region instructions_basic
const server = new McpServer(
{
name: 'multi-tool-server',
version: '1.0.0'
},
{
instructions: `This server provides data-pipeline tools. Always call "validate-schema"
before calling "transform-data" to avoid runtime errors.`
}
);
//#endregion instructions_basic
return server;
}

// ---------------------------------------------------------------------------
// Tools, resources, and prompts
// ---------------------------------------------------------------------------
Expand Down Expand Up @@ -373,6 +394,7 @@ function dnsRebinding_allowedHosts() {
}

// Suppress unused-function warnings (functions exist solely for type-checking)
void instructions_basic;
void registerTool_basic;
void registerTool_resourceLink;
void registerTool_logging;
Expand Down
Loading