Skip to content

Commit 3916338

Browse files
author
Motta Kin
committed
Add instructions to the test server; tooltip to instructions example
1 parent 2238e39 commit 3916338

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

docs/mcp/client.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,14 +351,16 @@ agent = Agent('openai:gpt-5', toolsets=[server])
351351

352352
@agent.instructions
353353
async def mcp_server_instructions():
354-
return server.instructions
354+
return server.instructions # (1)!
355355

356356
async def main():
357357
result = await agent.run('What is 7 plus 5?')
358358
print(result.output)
359359
#> The answer is 12.
360360
```
361361

362+
1. The server connection is guaranteed to be established by this point, so `server.instructions` is available.
363+
362364
## Tool metadata
363365

364366
MCP tools can include metadata that provides additional information about the tool's characteristics, which can be useful when [filtering tools][pydantic_ai.toolsets.FilteredToolset]. The `meta`, `annotations`, and `output_schema` fields can be found on the `metadata` dict on the [`ToolDefinition`][pydantic_ai.tools.ToolDefinition] object that's passed to filter functions.

tests/mcp_server.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
)
1717
from pydantic import AnyUrl, BaseModel
1818

19-
mcp = FastMCP('Pydantic AI MCP Server')
19+
mcp = FastMCP('Pydantic AI MCP Server', instructions='Be a helpful assistant.')
2020
log_level = 'unset'
2121

2222

tests/test_mcp.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1764,7 +1764,7 @@ async def test_instructions(mcp_server: MCPServerStdio) -> None:
17641764
mcp_server.instructions
17651765
async with mcp_server:
17661766
# The test server doesn't provide instructions, so it should be None
1767-
assert mcp_server.instructions is None
1767+
assert mcp_server.instructions == 'Be a helpful assistant.'
17681768

17691769

17701770
async def test_agent_run_stream_with_mcp_server_http(allow_model_requests: None, model: Model):

0 commit comments

Comments
 (0)