Skip to content

docs: improve discoverability and docs for the instructions parameter - #3311

Open
QiYuyyds wants to merge 1 commit into
modelcontextprotocol:mainfrom
QiYuyyds:docs/instructions-param
Open

docs: improve discoverability and docs for the instructions parameter#3311
QiYuyyds wants to merge 1 commit into
modelcontextprotocol:mainfrom
QiYuyyds:docs/instructions-param

Conversation

@QiYuyyds

Copy link
Copy Markdown

Summary

Improve discoverability and documentation of the instructions parameter on
MCPServer (which flows through to InitializeResult.instructions).

Closes #1464

Changes

  • Added a docstring to the instructions parameter in MCPServer.__init__,
    explaining its purpose and hinting at tool-grouping / workflow use cases.
  • Added a new "Server instructions" section to docs/get-started/first-steps.md
    with a concrete example showing how to use instructions to express tool
    grouping and ordering guidance.
  • Added docs_src/first_steps/tutorial002.py as the referenced example.

Checklist


🤖 AI-assisted: This PR was drafted with AI assistance. I (the contributor)
have reviewed the diff, understand the change, and confirm the example
accurately demonstrates the instructions parameter.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 issues found across 3 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="docs/get-started/first-steps.md">

<violation number="1" location="docs/get-started/first-steps.md:126">
P3: The new instructions example highlights `name="Demo"` instead of the `instructions` argument, which makes the key parameter harder to spot. Update `hl_lines` to point at the `instructions=` line.</violation>
</file>

<file name="docs_src/first_steps/tutorial002.py">

<violation number="1" location="docs_src/first_steps/tutorial002.py:8">
P2: The example instructions reference `batch_write`, but this tutorial only defines `read_status` and `write_record`. Replace that text with guidance that matches the tools shown, or add a `batch_write` tool.</violation>
</file>

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread src/mcp/server/mcpserver/server.py Outdated
instructions=(
"This server exposes two groups of tools: 'read_*' for fetching data "
"and 'write_*' for persisting it. Always call a read tool before a "
"write tool, and prefer batch_write over repeated single writes."

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: The example instructions reference batch_write, but this tutorial only defines read_status and write_record. Replace that text with guidance that matches the tools shown, or add a batch_write tool.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At docs_src/first_steps/tutorial002.py, line 8:

<comment>The example instructions reference `batch_write`, but this tutorial only defines `read_status` and `write_record`. Replace that text with guidance that matches the tools shown, or add a `batch_write` tool.</comment>

<file context>
@@ -0,0 +1,22 @@
+    instructions=(
+        "This server exposes two groups of tools: 'read_*' for fetching data "
+        "and 'write_*' for persisting it. Always call a read tool before a "
+        "write tool, and prefer batch_write over repeated single writes."
+    ),
+)
</file context>

to guide the model on how to use your server's tools — for example, grouping
related tools or describing a workflow:

```python title="server.py" hl_lines="4"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3: The new instructions example highlights name="Demo" instead of the instructions argument, which makes the key parameter harder to spot. Update hl_lines to point at the instructions= line.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At docs/get-started/first-steps.md, line 126:

<comment>The new instructions example highlights `name="Demo"` instead of the `instructions` argument, which makes the key parameter harder to spot. Update `hl_lines` to point at the `instructions=` line.</comment>

<file context>
@@ -116,6 +116,22 @@ Notice what isn't there. `completions` (argument autocomplete for resource templ
+to guide the model on how to use your server's tools — for example, grouping
+related tools or describing a workflow:
+
+```python title="server.py" hl_lines="4"
+--8<-- "docs_src/first_steps/tutorial002.py"
+```
</file context>
Suggested change
```python title="server.py" hl_lines="4"
```python title="server.py" hl_lines="5"

@QiYuyyds
QiYuyyds force-pushed the docs/instructions-param branch from db0f5b0 to 024bac8 Compare August 15, 2026 07:37
Add a class docstring to MCPServer documenting the instructions parameter,
and a new Server instructions section to the first-steps guide, with a
concrete example showing how to use instructions to express tool grouping
and workflow guidance.

Closes modelcontextprotocol#1464
@QiYuyyds
QiYuyyds force-pushed the docs/instructions-param branch from 024bac8 to 291811d Compare August 15, 2026 07:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve docs on how to use instructions on InitializeResult

1 participant