Skip to content

Commit f1a7520

Browse files
committed
Document FastMCP server instructions
1 parent 3d7b311 commit f1a7520

1 file changed

Lines changed: 29 additions & 0 deletions

File tree

README.v2.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,35 @@ async def long_running_task(task_name: str, ctx: Context, steps: int = 5) -> str
370370
_Full example: [examples/snippets/servers/tool_progress.py](https://github.com/modelcontextprotocol/python-sdk/blob/main/examples/snippets/servers/tool_progress.py)_
371371
<!-- /snippet-source -->
372372

373+
#### Server Instructions
374+
375+
Use `instructions` to tell clients how the server's tools and resources fit
376+
together. These instructions are returned in the server's `InitializeResult`,
377+
which lets clients surface workflow guidance before the model calls any tools.
378+
379+
Instructions are useful when a server has related tools that should be used in a
380+
particular order, or when tools are grouped by domain and need extra context.
381+
382+
```python
383+
from mcp.server import MCPServer
384+
385+
mcp = MCPServer(
386+
name="Inventory",
387+
instructions=(
388+
"Use lookup_item before update_stock. "
389+
"Use create_purchase_order only after confirming supplier availability."
390+
),
391+
)
392+
```
393+
394+
Inside a tool you can read the same value via the request context:
395+
396+
```python
397+
@mcp.tool()
398+
async def describe_workflow(ctx: Context) -> str:
399+
return ctx.mcp_server.instructions or "(no instructions provided)"
400+
```
401+
373402
#### Structured Output
374403

375404
Tools will return structured results by default, if their return type

0 commit comments

Comments
 (0)