You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/logfire.md
+16-35Lines changed: 16 additions & 35 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -106,49 +106,30 @@ We can also query data with SQL in Logfire to monitor the performance of an appl
106
106
107
107
### Monitoring HTTP Requests
108
108
109
-
!!! tip "\"F**k you, show me the prompt.\""
110
-
As per Hamel Husain's influential 2024 blog post ["Fuck You, Show Me The Prompt."](https://hamel.dev/blog/posts/prompt/)
111
-
(bear with the capitalization, the point is valid), it's often useful to be able to view the raw HTTP requests and responses made to model providers.
109
+
As per Hamel Husain's influential 2024 blog post ["Fuck You, Show Me The Prompt."](https://hamel.dev/blog/posts/prompt/)
110
+
(bear with the capitalization, the point is valid), it's often useful to be able to view the raw HTTP requests and responses made to model providers.
112
111
113
-
To observe raw HTTP requests made to model providers, you can use Logfire's [HTTPX instrumentation](https://logfire.pydantic.dev/docs/integrations/http-clients/httpx/) since all provider SDKs use the [HTTPX](https://www.python-httpx.org/) library internally.
112
+
To observe raw HTTP requests made to model providers, you can use Logfire's [HTTPX instrumentation](https://logfire.pydantic.dev/docs/integrations/http-clients/httpx/) since all provider SDKs (except for [Bedrock](models/bedrock.md)) use the [HTTPX](https://www.python-httpx.org/) library internally:
result = agent.run_sync('What is the capital of France?')
127
-
print(result.output)
128
-
#> The capital of France is Paris.
129
-
```
130
-
131
-
1. See the [`logfire.instrument_httpx` docs][logfire.Logfire.instrument_httpx] more details, `capture_all=True` means both headers and body are captured for both the request and response.
132
-
133
-

result = agent.run_sync('What is the capital of France?')
126
+
print(result.output)
127
+
#> The capital of France is Paris.
128
+
```
144
129
145
-
agent = Agent('openai:gpt-5')
146
-
result = agent.run_sync('What is the capital of France?')
147
-
print(result.output)
148
-
#> The capital of France is Paris.
149
-
```
130
+
1. See the [`logfire.instrument_httpx` docs][logfire.Logfire.instrument_httpx] more details, `capture_all=True` means both headers and body are captured for both the request and response.
150
131
151
-

132
+

MCP servers can provide instructions during initialization that give context about how to best interact with the server's tools. These instructions are accessible via the [`instructions`][pydantic_ai.mcp.MCPServer.instructions] property after the server connection is established.
344
+
345
+
```python {title="mcp_server_instructions.py"}
346
+
from pydantic_ai import Agent
347
+
from pydantic_ai.mcp import MCPServerStreamableHTTP
348
+
349
+
server = MCPServerStreamableHTTP('http://localhost:8000/mcp')
350
+
agent = Agent('openai:gpt-5', toolsets=[server])
351
+
352
+
@agent.instructions
353
+
asyncdefmcp_server_instructions():
354
+
return server.instructions # (1)!
355
+
356
+
asyncdefmain():
357
+
result =await agent.run('What is 7 plus 5?')
358
+
print(result.output)
359
+
#> The answer is 12.
360
+
```
361
+
362
+
1. The server connection is guaranteed to be established by this point, so `server.instructions` is available.
363
+
341
364
## Tool metadata
342
365
343
366
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.
0 commit comments