Skip to content

Commit 8d7e24f

Browse files
committed
Update MCP docs for resources
1 parent 85e7c2b commit 8d7e24f

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

docs/mcp.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,32 @@ agent = Agent(
320320
)
321321
```
322322

323+
## Resources
324+
325+
MCP servers can expose resources that provide context data to agents. Resources are URI-addressable pieces of data (such as configuration files, documentation, or metrics) that agents can read and use. Servers that support resources expose two methods:
326+
327+
- `list_resources()` enumerates the available resources.
328+
- `read_resource(uri)` fetches the content of a specific resource by its URI.
329+
330+
```python
331+
from agents import Agent
332+
333+
resources_result = await server.list_resources()
334+
for resource in resources_result.resources:
335+
print(f"Resource: {resource.name} ({resource.uri})")
336+
337+
resource_result = await server.read_resource("config://app/settings")
338+
config_content = resource_result.contents[0].text
339+
340+
agent = Agent(
341+
name="Config Assistant",
342+
instructions=f"You are a helpful assistant. Current configuration:\n{config_content}",
343+
mcp_servers=[server],
344+
)
345+
```
346+
347+
Resources can use any URI scheme (e.g., `file://`, `http://`, `config://`, `docs://`) and can contain text or binary data. Unlike prompts which generate instructions, resources provide raw context data that agents can reference during execution.
348+
323349
## Caching
324350

325351
Every agent run calls `list_tools()` on each MCP server. Remote servers can introduce noticeable latency, so all of the MCP

0 commit comments

Comments
 (0)