@aws/nx-plugin-mcp 1.3.7 → 1.3.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -466,13 +466,19 @@ Let's take a look at some of the files in detail:
|
|
|
466
466
|
```python
|
|
467
467
|
# agent/agent.py
|
|
468
468
|
from contextlib import contextmanager
|
|
469
|
+
from datetime import UTC, datetime
|
|
469
470
|
|
|
470
471
|
from strands import Agent, tool
|
|
471
472
|
from strands.hooks import HookCallback, HookProvider
|
|
472
|
-
from strands_tools import current_time
|
|
473
473
|
from dungeon_adventure_agent_connection import log_model_errors, log_tool_errors
|
|
474
474
|
|
|
475
475
|
|
|
476
|
+
@tool
|
|
477
|
+
def current_time() -> str:
|
|
478
|
+
"""Get the current date and time in UTC (ISO 8601)."""
|
|
479
|
+
return datetime.now(UTC).isoformat()
|
|
480
|
+
|
|
481
|
+
|
|
476
482
|
@tool
|
|
477
483
|
def subtract(a: int, b: int) -> int:
|
|
478
484
|
return a - b
|
|
@@ -496,7 +502,7 @@ Refer to tools as your 'spellbook'.
|
|
|
496
502
|
)
|
|
497
503
|
```
|
|
498
504
|
|
|
499
|
-
This creates an example Strands agent and defines a subtraction tool. `log_model_errors` and `log_tool_errors` are hooks from the shared `dungeon_adventure_agent_connection` project that log model/tool failures instead of letting them fail silently.
|
|
505
|
+
This creates an example Strands agent and defines two tools: `current_time`, which returns the current UTC time, and a subtraction tool. `log_model_errors` and `log_tool_errors` are hooks from the shared `dungeon_adventure_agent_connection` project that log model/tool failures instead of letting them fail silently.
|
|
500
506
|
|
|
501
507
|
```python
|
|
502
508
|
# agent/middleware/session_id_middleware.py
|
|
@@ -408,6 +408,8 @@ function ItemList() {
|
|
|
408
408
|
|
|
409
409
|
The generated hooks automatically handle cursor-based pagination if your API supports it. The `nextCursor` value is extracted from the response and used to fetch the next page.
|
|
410
410
|
|
|
411
|
+
An infinite query is cached under its own query key, `[...api.listItems.queryKey(input), 'pages']`, so it never shares a cache entry with the plain query from `api.listItems.queryOptions(input)`. Invalidating `api.listItems.queryKey(input)` refreshes both, because TanStack Query matches query keys by prefix. To read or write the cached pages with `queryClient.getQueryData` or `setQueryData`, pass the infinite query's own key.
|
|
412
|
+
|
|
411
413
|
:::tip[Paginated APIs]
|
|
412
414
|
If you have a paginated API which has its pagination parameter named something other than `cursor`, you can [customise it using the `x-cursor` OpenAPI vendor extension](#custom-pagination-cursor).
|
|
413
415
|
:::
|
|
@@ -373,6 +373,8 @@ function ItemList() {
|
|
|
373
373
|
|
|
374
374
|
The generated hooks automatically handle cursor-based pagination if your API supports it. The `nextCursor` value is extracted from the response and used to fetch the next page.
|
|
375
375
|
|
|
376
|
+
An infinite query is cached under its own query key, `[...api.listItems.queryKey(input), 'pages']`, so it never shares a cache entry with the plain query from `api.listItems.queryOptions(input)`. Invalidating `api.listItems.queryKey(input)` refreshes both, because TanStack Query matches query keys by prefix. To read or write the cached pages with `queryClient.getQueryData` or `setQueryData`, pass the infinite query's own key.
|
|
377
|
+
|
|
376
378
|
:::tip[Paginated APIs]
|
|
377
379
|
If you have a paginated API which has its pagination parameter named something other than `cursor`, you can [customise it using the `x-cursor` OpenAPI vendor extension](#custom-pagination-cursor).
|
|
378
380
|
:::
|
package/docs/guides/py-agent.mdx
CHANGED
|
@@ -167,17 +167,23 @@ Define the tool, then add it to the `tools` list inside `get_agent()`:
|
|
|
167
167
|
|
|
168
168
|
<Tabs syncKey="agent-framework">
|
|
169
169
|
<TabItem label="Strands" _filter={{ framework: 'strands' }}>
|
|
170
|
-
```python title="packages/my-project/my_module/agent/agent.py" {
|
|
170
|
+
```python title="packages/my-project/my_module/agent/agent.py" {22-26,38}
|
|
171
171
|
from contextlib import contextmanager
|
|
172
|
+
from datetime import UTC, datetime
|
|
172
173
|
|
|
173
174
|
from strands import Agent, tool
|
|
174
175
|
from strands.hooks import HookCallback, HookProvider
|
|
175
|
-
from strands_tools import current_time
|
|
176
176
|
from my_scope_agent_connection import log_model_errors, log_tool_errors
|
|
177
177
|
|
|
178
178
|
from .session import get_session_manager
|
|
179
179
|
|
|
180
180
|
|
|
181
|
+
@tool
|
|
182
|
+
def current_time() -> str:
|
|
183
|
+
"""Get the current date and time in UTC (ISO 8601)."""
|
|
184
|
+
return datetime.now(UTC).isoformat()
|
|
185
|
+
|
|
186
|
+
|
|
181
187
|
@tool
|
|
182
188
|
def subtract(a: int, b: int) -> int:
|
|
183
189
|
return a - b
|
|
@@ -248,10 +254,10 @@ def get_agent():
|
|
|
248
254
|
|
|
249
255
|
<Tabs syncKey="agent-framework">
|
|
250
256
|
<TabItem label="Strands" _filter={{ framework: 'strands' }}>
|
|
251
|
-
Strands
|
|
257
|
+
The Strands SDK includes pre-built tools in `strands.vended_tools`, so they need no extra package. Import the tools you want and add them to `get_agent()`:
|
|
252
258
|
|
|
253
259
|
```python title="packages/my-project/my_module/agent/agent.py" {1,11}
|
|
254
|
-
from
|
|
260
|
+
from strands.vended_tools import http_request, read
|
|
255
261
|
|
|
256
262
|
# ...
|
|
257
263
|
|
|
@@ -261,11 +267,13 @@ def get_agent():
|
|
|
261
267
|
name="MyAgent",
|
|
262
268
|
description="MyAgent Strands Agent",
|
|
263
269
|
system_prompt="You are a helpful assistant.",
|
|
264
|
-
tools=[current_time,
|
|
270
|
+
tools=[current_time, read, http_request],
|
|
265
271
|
hooks=AGENT_HOOKS,
|
|
266
272
|
session_manager=get_session_manager(),
|
|
267
273
|
)
|
|
268
274
|
```
|
|
275
|
+
|
|
276
|
+
The `current_time` tool in this list is the one the generator defines in `agent.py`. The model calls it when it needs the date or time, and it returns the current UTC time. The generator does not add the deprecated `strands-agents-tools` package to `pyproject.toml`: from version 0.9.0, importing any of its tools raises an `ImportError`. If your project already lists it, keep it pinned below 0.9 or remove it if you do not use it. The [Strands migration guide](https://strandsagents.com/docs/user-guide/migrate/strands-agents-tools/) lists the replacement for each of its tools.
|
|
269
277
|
</TabItem>
|
|
270
278
|
<TabItem label="LangChain" _filter={{ framework: 'langchain' }}>
|
|
271
279
|
LangChain provides a large ecosystem of [tools and integrations](https://docs.langchain.com/oss/python/integrations/tools), each distributed in its own package. The generator does not add these, so install the one you need first — for example `langchain-community`, which the search tool below comes from:
|