agentcat 2.0.0b1__tar.gz → 2.0.0b2__tar.gz
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.
- {agentcat-2.0.0b1 → agentcat-2.0.0b2}/PKG-INFO +18 -3
- {agentcat-2.0.0b1 → agentcat-2.0.0b2}/README.md +17 -2
- {agentcat-2.0.0b1 → agentcat-2.0.0b2}/pyproject.toml +1 -1
- {agentcat-2.0.0b1 → agentcat-2.0.0b2}/src/agentcat/modules/adapters/lowlevel_v1.py +14 -4
- {agentcat-2.0.0b1 → agentcat-2.0.0b2}/src/agentcat/modules/adapters/lowlevel_v2.py +6 -3
- {agentcat-2.0.0b1 → agentcat-2.0.0b2}/tests/community/test_community_v3_handles.py +3 -2
- {agentcat-2.0.0b1 → agentcat-2.0.0b2}/tests/conftest.py +43 -6
- {agentcat-2.0.0b1 → agentcat-2.0.0b2}/tests/e2e/community_v4/test_session_http.py +16 -3
- {agentcat-2.0.0b1 → agentcat-2.0.0b2}/tests/test_concurrency_handles.py +5 -1
- {agentcat-2.0.0b1 → agentcat-2.0.0b2}/tests/test_inner_tap.py +74 -21
- {agentcat-2.0.0b1 → agentcat-2.0.0b2}/tests/test_lowlevel_v1_handles.py +38 -11
- {agentcat-2.0.0b1 → agentcat-2.0.0b2}/tests/test_response_shape.py +16 -3
- agentcat-2.0.0b2/tests/test_utils/__init__.py +207 -0
- {agentcat-2.0.0b1 → agentcat-2.0.0b2}/tests/test_utils/flavors.py +135 -14
- agentcat-2.0.0b1/tests/test_utils/__init__.py +0 -57
- {agentcat-2.0.0b1 → agentcat-2.0.0b2}/.gitignore +0 -0
- {agentcat-2.0.0b1 → agentcat-2.0.0b2}/CONTRIBUTING.md +0 -0
- {agentcat-2.0.0b1 → agentcat-2.0.0b2}/LICENSE +0 -0
- {agentcat-2.0.0b1 → agentcat-2.0.0b2}/docs/cats/bibi.png +0 -0
- {agentcat-2.0.0b1 → agentcat-2.0.0b2}/docs/cats/zelda.jpg +0 -0
- {agentcat-2.0.0b1 → agentcat-2.0.0b2}/docs/static/architecture.png +0 -0
- {agentcat-2.0.0b1 → agentcat-2.0.0b2}/docs/static/og-image.png +0 -0
- {agentcat-2.0.0b1 → agentcat-2.0.0b2}/src/agentcat/__init__.py +0 -0
- {agentcat-2.0.0b1 → agentcat-2.0.0b2}/src/agentcat/modules/__init__.py +0 -0
- {agentcat-2.0.0b1 → agentcat-2.0.0b2}/src/agentcat/modules/adapters/__init__.py +0 -0
- {agentcat-2.0.0b1 → agentcat-2.0.0b2}/src/agentcat/modules/adapters/_common.py +0 -0
- {agentcat-2.0.0b1 → agentcat-2.0.0b2}/src/agentcat/modules/adapters/_inner_tap.py +0 -0
- {agentcat-2.0.0b1 → agentcat-2.0.0b2}/src/agentcat/modules/adapters/community.py +0 -0
- {agentcat-2.0.0b1 → agentcat-2.0.0b2}/src/agentcat/modules/callpath.py +0 -0
- {agentcat-2.0.0b1 → agentcat-2.0.0b2}/src/agentcat/modules/client_identity.py +0 -0
- {agentcat-2.0.0b1 → agentcat-2.0.0b2}/src/agentcat/modules/constants.py +0 -0
- {agentcat-2.0.0b1 → agentcat-2.0.0b2}/src/agentcat/modules/detection.py +0 -0
- {agentcat-2.0.0b1 → agentcat-2.0.0b2}/src/agentcat/modules/diagnostics.py +0 -0
- {agentcat-2.0.0b1 → agentcat-2.0.0b2}/src/agentcat/modules/event_queue.py +0 -0
- {agentcat-2.0.0b1 → agentcat-2.0.0b2}/src/agentcat/modules/exceptions.py +0 -0
- {agentcat-2.0.0b1 → agentcat-2.0.0b2}/src/agentcat/modules/exporters/__init__.py +0 -0
- {agentcat-2.0.0b1 → agentcat-2.0.0b2}/src/agentcat/modules/exporters/datadog.py +0 -0
- {agentcat-2.0.0b1 → agentcat-2.0.0b2}/src/agentcat/modules/exporters/otlp.py +0 -0
- {agentcat-2.0.0b1 → agentcat-2.0.0b2}/src/agentcat/modules/exporters/sentry.py +0 -0
- {agentcat-2.0.0b1 → agentcat-2.0.0b2}/src/agentcat/modules/exporters/trace_context.py +0 -0
- {agentcat-2.0.0b1 → agentcat-2.0.0b2}/src/agentcat/modules/handles.py +0 -0
- {agentcat-2.0.0b1 → agentcat-2.0.0b2}/src/agentcat/modules/identify.py +0 -0
- {agentcat-2.0.0b1 → agentcat-2.0.0b2}/src/agentcat/modules/injection.py +0 -0
- {agentcat-2.0.0b1 → agentcat-2.0.0b2}/src/agentcat/modules/internal.py +0 -0
- {agentcat-2.0.0b1 → agentcat-2.0.0b2}/src/agentcat/modules/logging.py +0 -0
- {agentcat-2.0.0b1 → agentcat-2.0.0b2}/src/agentcat/modules/redaction.py +0 -0
- {agentcat-2.0.0b1 → agentcat-2.0.0b2}/src/agentcat/modules/request_extra.py +0 -0
- {agentcat-2.0.0b1 → agentcat-2.0.0b2}/src/agentcat/modules/sanitization.py +0 -0
- {agentcat-2.0.0b1 → agentcat-2.0.0b2}/src/agentcat/modules/telemetry.py +0 -0
- {agentcat-2.0.0b1 → agentcat-2.0.0b2}/src/agentcat/modules/tools.py +0 -0
- {agentcat-2.0.0b1 → agentcat-2.0.0b2}/src/agentcat/modules/truncation.py +0 -0
- {agentcat-2.0.0b1 → agentcat-2.0.0b2}/src/agentcat/modules/validation.py +0 -0
- {agentcat-2.0.0b1 → agentcat-2.0.0b2}/src/agentcat/thirdparty/__init__.py +0 -0
- {agentcat-2.0.0b1 → agentcat-2.0.0b2}/src/agentcat/thirdparty/ksuid/__init__.py +0 -0
- {agentcat-2.0.0b1 → agentcat-2.0.0b2}/src/agentcat/thirdparty/ksuid/baseconv.py +0 -0
- {agentcat-2.0.0b1 → agentcat-2.0.0b2}/src/agentcat/thirdparty/ksuid/ksuid.py +0 -0
- {agentcat-2.0.0b1 → agentcat-2.0.0b2}/src/agentcat/types.py +0 -0
- {agentcat-2.0.0b1 → agentcat-2.0.0b2}/src/agentcat/utils.py +0 -0
- {agentcat-2.0.0b1 → agentcat-2.0.0b2}/tests/__init__.py +0 -0
- {agentcat-2.0.0b1 → agentcat-2.0.0b2}/tests/community/__init__.py +0 -0
- {agentcat-2.0.0b1 → agentcat-2.0.0b2}/tests/community/test_community_v3_event_serialization.py +0 -0
- {agentcat-2.0.0b1 → agentcat-2.0.0b2}/tests/community/test_community_v3_inject_context.py +0 -0
- {agentcat-2.0.0b1 → agentcat-2.0.0b2}/tests/community/test_community_v3_openapi.py +0 -0
- {agentcat-2.0.0b1 → agentcat-2.0.0b2}/tests/community/test_community_v3_runtime_state_tools.py +0 -0
- {agentcat-2.0.0b1 → agentcat-2.0.0b2}/tests/e2e/__init__.py +0 -0
- {agentcat-2.0.0b1 → agentcat-2.0.0b2}/tests/e2e/_helpers.py +0 -0
- {agentcat-2.0.0b1 → agentcat-2.0.0b2}/tests/e2e/community_v3/__init__.py +0 -0
- {agentcat-2.0.0b1 → agentcat-2.0.0b2}/tests/e2e/community_v3/conftest.py +0 -0
- {agentcat-2.0.0b1 → agentcat-2.0.0b2}/tests/e2e/community_v3/test_event_capture_http.py +0 -0
- {agentcat-2.0.0b1 → agentcat-2.0.0b2}/tests/e2e/community_v3/test_identify_http.py +0 -0
- {agentcat-2.0.0b1 → agentcat-2.0.0b2}/tests/e2e/community_v3/test_request_extra_http.py +0 -0
- {agentcat-2.0.0b1 → agentcat-2.0.0b2}/tests/e2e/community_v3/test_stateless_http.py +0 -0
- {agentcat-2.0.0b1 → agentcat-2.0.0b2}/tests/e2e/community_v4/__init__.py +0 -0
- {agentcat-2.0.0b1 → agentcat-2.0.0b2}/tests/e2e/community_v4/conftest.py +0 -0
- {agentcat-2.0.0b1 → agentcat-2.0.0b2}/tests/e2e/community_v4/test_stateless_http.py +0 -0
- {agentcat-2.0.0b1 → agentcat-2.0.0b2}/tests/e2e/conftest.py +0 -0
- {agentcat-2.0.0b1 → agentcat-2.0.0b2}/tests/e2e/official/__init__.py +0 -0
- {agentcat-2.0.0b1 → agentcat-2.0.0b2}/tests/e2e/official/conftest.py +0 -0
- {agentcat-2.0.0b1 → agentcat-2.0.0b2}/tests/e2e/official/test_event_capture_http.py +0 -0
- {agentcat-2.0.0b1 → agentcat-2.0.0b2}/tests/e2e/official/test_identify_http.py +0 -0
- {agentcat-2.0.0b1 → agentcat-2.0.0b2}/tests/e2e/official/test_redaction_http.py +0 -0
- {agentcat-2.0.0b1 → agentcat-2.0.0b2}/tests/e2e/official/test_request_extra_http.py +0 -0
- {agentcat-2.0.0b1 → agentcat-2.0.0b2}/tests/e2e/official/test_session_http.py +0 -0
- {agentcat-2.0.0b1 → agentcat-2.0.0b2}/tests/e2e/official/test_stateless_http.py +0 -0
- {agentcat-2.0.0b1 → agentcat-2.0.0b2}/tests/e2e/official_modern/__init__.py +0 -0
- {agentcat-2.0.0b1 → agentcat-2.0.0b2}/tests/e2e/official_modern/conftest.py +0 -0
- {agentcat-2.0.0b1 → agentcat-2.0.0b2}/tests/e2e/official_modern/test_mcpserver_http.py +0 -0
- {agentcat-2.0.0b1 → agentcat-2.0.0b2}/tests/e2e/official_modern/test_session_http.py +0 -0
- {agentcat-2.0.0b1 → agentcat-2.0.0b2}/tests/e2e/official_modern/test_stateless_http.py +0 -0
- {agentcat-2.0.0b1 → agentcat-2.0.0b2}/tests/test_api_base_url.py +0 -0
- {agentcat-2.0.0b1 → agentcat-2.0.0b2}/tests/test_callpath.py +0 -0
- {agentcat-2.0.0b1 → agentcat-2.0.0b2}/tests/test_client_identity.py +0 -0
- {agentcat-2.0.0b1 → agentcat-2.0.0b2}/tests/test_community_v4_handles.py +0 -0
- {agentcat-2.0.0b1 → agentcat-2.0.0b2}/tests/test_constants_copy.py +0 -0
- {agentcat-2.0.0b1 → agentcat-2.0.0b2}/tests/test_customer_owned_parameters.py +0 -0
- {agentcat-2.0.0b1 → agentcat-2.0.0b2}/tests/test_detection.py +0 -0
- {agentcat-2.0.0b1 → agentcat-2.0.0b2}/tests/test_diagnostics_attributes.py +0 -0
- {agentcat-2.0.0b1 → agentcat-2.0.0b2}/tests/test_diagnostics_auth.py +0 -0
- {agentcat-2.0.0b1 → agentcat-2.0.0b2}/tests/test_diagnostics_export.py +0 -0
- {agentcat-2.0.0b1 → agentcat-2.0.0b2}/tests/test_diagnostics_integration.py +0 -0
- {agentcat-2.0.0b1 → agentcat-2.0.0b2}/tests/test_diagnostics_no_payload.py +0 -0
- {agentcat-2.0.0b1 → agentcat-2.0.0b2}/tests/test_diagnostics_optout.py +0 -0
- {agentcat-2.0.0b1 → agentcat-2.0.0b2}/tests/test_diagnostics_record.py +0 -0
- {agentcat-2.0.0b1 → agentcat-2.0.0b2}/tests/test_diagnostics_sink.py +0 -0
- {agentcat-2.0.0b1 → agentcat-2.0.0b2}/tests/test_diagnostics_test_env.py +0 -0
- {agentcat-2.0.0b1 → agentcat-2.0.0b2}/tests/test_dynamic_tracking.py +0 -0
- {agentcat-2.0.0b1 → agentcat-2.0.0b2}/tests/test_event_capture_completeness.py +0 -0
- {agentcat-2.0.0b1 → agentcat-2.0.0b2}/tests/test_event_queue.py +0 -0
- {agentcat-2.0.0b1 → agentcat-2.0.0b2}/tests/test_event_tags_properties.py +0 -0
- {agentcat-2.0.0b1 → agentcat-2.0.0b2}/tests/test_exceptions.py +0 -0
- {agentcat-2.0.0b1 → agentcat-2.0.0b2}/tests/test_exporter_sdk_version.py +0 -0
- {agentcat-2.0.0b1 → agentcat-2.0.0b2}/tests/test_handles.py +0 -0
- {agentcat-2.0.0b1 → agentcat-2.0.0b2}/tests/test_identify_shape.py +0 -0
- {agentcat-2.0.0b1 → agentcat-2.0.0b2}/tests/test_injection.py +0 -0
- {agentcat-2.0.0b1 → agentcat-2.0.0b2}/tests/test_logging.py +0 -0
- {agentcat-2.0.0b1 → agentcat-2.0.0b2}/tests/test_lowlevel_v2_handles.py +0 -0
- {agentcat-2.0.0b1 → agentcat-2.0.0b2}/tests/test_multiple_servers.py +0 -0
- {agentcat-2.0.0b1 → agentcat-2.0.0b2}/tests/test_options_v2.py +0 -0
- {agentcat-2.0.0b1 → agentcat-2.0.0b2}/tests/test_publish_custom_event.py +0 -0
- {agentcat-2.0.0b1 → agentcat-2.0.0b2}/tests/test_rebuild_on_demand.py +0 -0
- {agentcat-2.0.0b1 → agentcat-2.0.0b2}/tests/test_redaction.py +0 -0
- {agentcat-2.0.0b1 → agentcat-2.0.0b2}/tests/test_removed_events.py +0 -0
- {agentcat-2.0.0b1 → agentcat-2.0.0b2}/tests/test_report_missing.py +0 -0
- {agentcat-2.0.0b1 → agentcat-2.0.0b2}/tests/test_request_extra.py +0 -0
- {agentcat-2.0.0b1 → agentcat-2.0.0b2}/tests/test_sanitization.py +0 -0
- {agentcat-2.0.0b1 → agentcat-2.0.0b2}/tests/test_session_id_validation.py +0 -0
- {agentcat-2.0.0b1 → agentcat-2.0.0b2}/tests/test_tag_validation.py +0 -0
- {agentcat-2.0.0b1 → agentcat-2.0.0b2}/tests/test_tool_context.py +0 -0
- {agentcat-2.0.0b1 → agentcat-2.0.0b2}/tests/test_truncation.py +0 -0
- {agentcat-2.0.0b1 → agentcat-2.0.0b2}/tests/test_truncation_json_safe.py +0 -0
- {agentcat-2.0.0b1 → agentcat-2.0.0b2}/tests/test_utils/client.py +0 -0
- {agentcat-2.0.0b1 → agentcat-2.0.0b2}/tests/test_utils/community_client.py +0 -0
- {agentcat-2.0.0b1 → agentcat-2.0.0b2}/tests/test_utils/community_openapi_server.py +0 -0
- {agentcat-2.0.0b1 → agentcat-2.0.0b2}/tests/test_utils/community_todo_server.py +0 -0
- {agentcat-2.0.0b1 → agentcat-2.0.0b2}/tests/test_utils/delivery.py +0 -0
- {agentcat-2.0.0b1 → agentcat-2.0.0b2}/tests/test_utils/modern_server.py +0 -0
- {agentcat-2.0.0b1 → agentcat-2.0.0b2}/tests/test_utils/todo_server.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: agentcat
|
|
3
|
-
Version: 2.0.
|
|
3
|
+
Version: 2.0.0b2
|
|
4
4
|
Summary: Analytics tool for MCP (Model Context Protocol) servers and AI agents - tracks tool usage patterns and provides insights
|
|
5
5
|
Project-URL: Homepage, https://github.com/agentcathq/agentcat-python-sdk
|
|
6
6
|
Project-URL: Bug Tracker, https://github.com/agentcathq/agentcat-python-sdk/issues
|
|
@@ -77,7 +77,7 @@ pip install --pre "agentcat[community]"
|
|
|
77
77
|
```
|
|
78
78
|
|
|
79
79
|
`--pre` is required while 2.x is a prerelease: without it pip skips
|
|
80
|
-
`2.0.
|
|
80
|
+
`2.0.0b2` and resolves the 1.x line instead, which has none of the features
|
|
81
81
|
documented below. Drop the flag once a stable 2.0.0 ships.
|
|
82
82
|
|
|
83
83
|
One `track()` call covers every supported server shape:
|
|
@@ -89,6 +89,21 @@ One `track()` call covers every supported server shape:
|
|
|
89
89
|
| Community FastMCP (`fastmcp`) 3.x and 4.x | ✅ (`agentcat[community]`) |
|
|
90
90
|
| Community FastMCP (`fastmcp`) 2.x | ❌ pin `agentcat<2` |
|
|
91
91
|
|
|
92
|
+
The floors are `mcp>=1.2.0,<3` and `fastmcp>=3.0.0,<5`, and every minor in
|
|
93
|
+
both ranges is exercised on each change by the compatibility matrix.
|
|
94
|
+
|
|
95
|
+
AgentCat runs on the whole range, but the oldest MCP releases lack the SDK
|
|
96
|
+
seams some features are built on, so those features go quiet rather than
|
|
97
|
+
break:
|
|
98
|
+
|
|
99
|
+
| On | What is missing upstream | Effect |
|
|
100
|
+
| --- | --- | --- |
|
|
101
|
+
| `mcp<1.10` | `Server._make_error_result`; declared structured tool output | A bare low-level handler's exception type and stack frames cannot be recovered — the surfaced message is still published. No structured mint-back. |
|
|
102
|
+
| `mcp<1.9.2` | `RequestContext.request` | No header or `requestInfo` capture. |
|
|
103
|
+
| `mcp<1.8` | Streamable HTTP | stdio only. |
|
|
104
|
+
| `mcp<1.3` | Concurrent message handling | The server never has two calls in flight. |
|
|
105
|
+
| `fastmcp<3.4` | `ToolResult.is_error` | A proxied upstream error arrives as a raised `ToolError`, so it is published *with* full exception detail rather than as a bare message. |
|
|
106
|
+
|
|
92
107
|
To learn more about us, check us out [here](https://agentcat.com)
|
|
93
108
|
|
|
94
109
|
## Why use AgentCat? 🤔
|
|
@@ -290,7 +305,7 @@ Learn more about our free and open source [telemetry integrations](https://docs.
|
|
|
290
305
|
|
|
291
306
|
### Known limitations
|
|
292
307
|
|
|
293
|
-
Two behaviors are worth knowing before you read your first dashboard. Both are deliberate for `2.0.
|
|
308
|
+
Two behaviors are worth knowing before you read your first dashboard. Both are deliberate for `2.0.0b2`.
|
|
294
309
|
|
|
295
310
|
- **Multi-round tool calls that mint their own handle land on separate sessions.** When a tool call runs several round trips and the *first* round is what mints the handle, each round is attributed to its own session rather than one shared session. Supplying a `session_id` yourself, or deriving one with `resolve_session_id`, correlates the rounds correctly — those two modes are protocol-enforced. Only the mint-on-first-round case is affected.
|
|
296
311
|
- **Errors forwarded from a proxied community tool carry no stack detail.** When a community FastMCP server proxies a tool to an upstream server and that upstream returns an error result, there is no local Python exception to read, so the event records the error message without a stack trace. Errors raised by your own tool code are unaffected and carry full detail.
|
|
@@ -45,7 +45,7 @@ pip install --pre "agentcat[community]"
|
|
|
45
45
|
```
|
|
46
46
|
|
|
47
47
|
`--pre` is required while 2.x is a prerelease: without it pip skips
|
|
48
|
-
`2.0.
|
|
48
|
+
`2.0.0b2` and resolves the 1.x line instead, which has none of the features
|
|
49
49
|
documented below. Drop the flag once a stable 2.0.0 ships.
|
|
50
50
|
|
|
51
51
|
One `track()` call covers every supported server shape:
|
|
@@ -57,6 +57,21 @@ One `track()` call covers every supported server shape:
|
|
|
57
57
|
| Community FastMCP (`fastmcp`) 3.x and 4.x | ✅ (`agentcat[community]`) |
|
|
58
58
|
| Community FastMCP (`fastmcp`) 2.x | ❌ pin `agentcat<2` |
|
|
59
59
|
|
|
60
|
+
The floors are `mcp>=1.2.0,<3` and `fastmcp>=3.0.0,<5`, and every minor in
|
|
61
|
+
both ranges is exercised on each change by the compatibility matrix.
|
|
62
|
+
|
|
63
|
+
AgentCat runs on the whole range, but the oldest MCP releases lack the SDK
|
|
64
|
+
seams some features are built on, so those features go quiet rather than
|
|
65
|
+
break:
|
|
66
|
+
|
|
67
|
+
| On | What is missing upstream | Effect |
|
|
68
|
+
| --- | --- | --- |
|
|
69
|
+
| `mcp<1.10` | `Server._make_error_result`; declared structured tool output | A bare low-level handler's exception type and stack frames cannot be recovered — the surfaced message is still published. No structured mint-back. |
|
|
70
|
+
| `mcp<1.9.2` | `RequestContext.request` | No header or `requestInfo` capture. |
|
|
71
|
+
| `mcp<1.8` | Streamable HTTP | stdio only. |
|
|
72
|
+
| `mcp<1.3` | Concurrent message handling | The server never has two calls in flight. |
|
|
73
|
+
| `fastmcp<3.4` | `ToolResult.is_error` | A proxied upstream error arrives as a raised `ToolError`, so it is published *with* full exception detail rather than as a bare message. |
|
|
74
|
+
|
|
60
75
|
To learn more about us, check us out [here](https://agentcat.com)
|
|
61
76
|
|
|
62
77
|
## Why use AgentCat? 🤔
|
|
@@ -258,7 +273,7 @@ Learn more about our free and open source [telemetry integrations](https://docs.
|
|
|
258
273
|
|
|
259
274
|
### Known limitations
|
|
260
275
|
|
|
261
|
-
Two behaviors are worth knowing before you read your first dashboard. Both are deliberate for `2.0.
|
|
276
|
+
Two behaviors are worth knowing before you read your first dashboard. Both are deliberate for `2.0.0b2`.
|
|
262
277
|
|
|
263
278
|
- **Multi-round tool calls that mint their own handle land on separate sessions.** When a tool call runs several round trips and the *first* round is what mints the handle, each round is attributed to its own session rather than one shared session. Supplying a `session_id` yourself, or deriving one with `resolve_session_id`, correlates the rounds correctly — those two modes are protocol-enforced. Only the mint-on-first-round case is affected.
|
|
264
279
|
- **Errors forwarded from a proxied community tool carry no stack detail.** When a community FastMCP server proxies a tool to an upstream server and that upstream returns an error result, there is no local Python exception to read, so the event records the error message without a stack trace. Errors raised by your own tool code are unaffected and carry full detail.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "agentcat"
|
|
3
|
-
version = "2.0.
|
|
3
|
+
version = "2.0.0b2"
|
|
4
4
|
description = "Analytics tool for MCP (Model Context Protocol) servers and AI agents - tracks tool usage patterns and provides insights"
|
|
5
5
|
authors = [
|
|
6
6
|
{ name = "AgentCat, Inc.", email = "support@agentcat.com" },
|
|
@@ -169,7 +169,6 @@ def install_lowlevel_v1(server: Any, data: AgentCatData, facade: Any = None) ->
|
|
|
169
169
|
ServerResult,
|
|
170
170
|
TextContent,
|
|
171
171
|
Tool,
|
|
172
|
-
ToolAnnotations,
|
|
173
172
|
)
|
|
174
173
|
|
|
175
174
|
from agentcat.modules.callpath import (
|
|
@@ -217,13 +216,24 @@ def install_lowlevel_v1(server: Any, data: AgentCatData, facade: Any = None) ->
|
|
|
217
216
|
return state.get(f"orig_{key}")
|
|
218
217
|
|
|
219
218
|
def make_get_more_tools() -> Tool:
|
|
219
|
+
# Spec defaults assume the worst; declare the honest hint so
|
|
220
|
+
# annotation-aware clients skip the confirmation prompt. Passed as a
|
|
221
|
+
# plain mapping, not the `ToolAnnotations` model — that model only
|
|
222
|
+
# exists from mcp 1.7, and importing it unconditionally used to make
|
|
223
|
+
# `install_lowlevel_v1` raise on 1.2-1.6, where `track()`'s blanket
|
|
224
|
+
# except turned AgentCat into a silent no-op. `Tool` is extra="allow"
|
|
225
|
+
# on every 1.x, so the mapping is absorbed below 1.7 and coerced into
|
|
226
|
+
# the model at and above it.
|
|
227
|
+
#
|
|
228
|
+
# Typed `Any` for the same reason `adapters/community.py` does it: the
|
|
229
|
+
# field is declared `ToolAnnotations | None`, so a type-check pass
|
|
230
|
+
# rejects the mapping that pydantic accepts at runtime.
|
|
231
|
+
annotations: Any = {"readOnlyHint": True}
|
|
220
232
|
return Tool(
|
|
221
233
|
name=GET_MORE_TOOLS_NAME,
|
|
222
234
|
description=GET_MORE_TOOLS_DESCRIPTION,
|
|
223
235
|
inputSchema=copy.deepcopy(GET_MORE_TOOLS_SCHEMA),
|
|
224
|
-
|
|
225
|
-
# annotation-aware clients skip the confirmation prompt.
|
|
226
|
-
annotations=ToolAnnotations(readOnlyHint=True),
|
|
236
|
+
annotations=annotations,
|
|
227
237
|
)
|
|
228
238
|
|
|
229
239
|
def advertised_tools(original: Any, options: Any) -> list[Any]:
|
|
@@ -127,7 +127,7 @@ def _text_block(text: str) -> Any:
|
|
|
127
127
|
|
|
128
128
|
|
|
129
129
|
def _make_get_more_tools() -> Any:
|
|
130
|
-
from mcp.types import Tool
|
|
130
|
+
from mcp.types import Tool
|
|
131
131
|
|
|
132
132
|
# Built from a keyword mapping rather than literal kwargs. `input_schema`
|
|
133
133
|
# and `read_only_hint` are the 2.x field names, and a type-check pass run
|
|
@@ -141,8 +141,11 @@ def _make_get_more_tools() -> Any:
|
|
|
141
141
|
"description": GET_MORE_TOOLS_DESCRIPTION,
|
|
142
142
|
"input_schema": copy.deepcopy(GET_MORE_TOOLS_SCHEMA),
|
|
143
143
|
# Spec defaults assume the worst; declare the honest hint so
|
|
144
|
-
# annotation-aware clients skip the confirmation prompt.
|
|
145
|
-
|
|
144
|
+
# annotation-aware clients skip the confirmation prompt. Handed over as
|
|
145
|
+
# the mapping itself: pydantic coerces it into whichever annotations
|
|
146
|
+
# model the running SDK declares, and nothing here has to import a type
|
|
147
|
+
# whose availability moved between generations.
|
|
148
|
+
"annotations": annotations,
|
|
146
149
|
}
|
|
147
150
|
return Tool(**fields)
|
|
148
151
|
|
|
@@ -658,12 +658,13 @@ async def test_a_tool_returning_is_error_records_the_surfaced_message(capture):
|
|
|
658
658
|
to tap, so the payload is the SDK-wide no-tap shape built from the wire
|
|
659
659
|
result — not a pydantic repr of FastMCP's ToolResult."""
|
|
660
660
|
from fastmcp.server.middleware import Middleware
|
|
661
|
-
from fastmcp.tools import ToolResult
|
|
662
661
|
from mcp.types import TextContent
|
|
663
662
|
|
|
663
|
+
from ..test_utils import error_tool_result
|
|
664
|
+
|
|
664
665
|
class Failing(Middleware):
|
|
665
666
|
async def on_call_tool(self, context, call_next):
|
|
666
|
-
return
|
|
667
|
+
return error_tool_result(
|
|
667
668
|
content=[TextContent(type="text", text="the tool said no")],
|
|
668
669
|
is_error=True,
|
|
669
670
|
)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import os
|
|
2
|
-
from importlib.metadata import version
|
|
2
|
+
from importlib.metadata import PackageNotFoundError, version
|
|
3
3
|
|
|
4
4
|
# Belt-and-suspenders: force diagnostics off before any test imports/runs, so no
|
|
5
5
|
# test ordering or future change to the auto-disable detection can ever ship OTLP
|
|
@@ -8,11 +8,26 @@ from importlib.metadata import version
|
|
|
8
8
|
os.environ["DISABLE_DIAGNOSTICS"] = "true"
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
# ──
|
|
12
|
-
#
|
|
13
|
-
#
|
|
14
|
-
#
|
|
15
|
-
|
|
11
|
+
# ── Collection gating ────────────────────────────────────────────────────────
|
|
12
|
+
# Three independent reasons a module cannot even be IMPORTED in a given
|
|
13
|
+
# environment. They are accumulated below rather than chosen between: the
|
|
14
|
+
# compatibility matrix runs legs that trip more than one at once (mcp 2.x with
|
|
15
|
+
# fastmcp deliberately uninstalled trips two).
|
|
16
|
+
#
|
|
17
|
+
# This has to happen at collection, not as a `skipif`. Every case here is a
|
|
18
|
+
# module-scope import of a symbol that does not exist, which raises while
|
|
19
|
+
# pytest is importing the module — before any mark on any test inside it runs.
|
|
20
|
+
#
|
|
21
|
+
# Prerelease segments are dropped rather than parsed: `2.0.0b1` yields (2, 0),
|
|
22
|
+
# which orders correctly against every bound used here.
|
|
23
|
+
MCP_VERSION = tuple(int(p) for p in version("mcp").split(".")[:3] if p.isdigit())
|
|
24
|
+
MCP_MAJOR = MCP_VERSION[0]
|
|
25
|
+
|
|
26
|
+
try:
|
|
27
|
+
version("fastmcp")
|
|
28
|
+
HAS_FASTMCP = True
|
|
29
|
+
except PackageNotFoundError: # the `test-without-fastmcp` matrix legs
|
|
30
|
+
HAS_FASTMCP = False
|
|
16
31
|
|
|
17
32
|
_LEGACY_ONLY = (
|
|
18
33
|
"e2e/official",
|
|
@@ -44,6 +59,24 @@ _MODERN_ONLY = (
|
|
|
44
59
|
"test_community_v4_handles.py",
|
|
45
60
|
)
|
|
46
61
|
|
|
62
|
+
# Needs community FastMCP importable at all, independent of era. The
|
|
63
|
+
# `test-without-fastmcp` matrix legs uninstall it and then verify it is gone,
|
|
64
|
+
# and these trees reach for `fastmcp` while pytest imports them.
|
|
65
|
+
_NEEDS_FASTMCP = (
|
|
66
|
+
"e2e/community_v3",
|
|
67
|
+
"e2e/community_v4",
|
|
68
|
+
"community",
|
|
69
|
+
)
|
|
70
|
+
|
|
71
|
+
# Needs a Streamable-HTTP transport AND an HTTP request object to inspect.
|
|
72
|
+
# `mcp.client.streamable_http`, `FastMCP.streamable_http_app()` and the
|
|
73
|
+
# `stateless_http` setting all arrive in mcp 1.8.0; `RequestContext.request` —
|
|
74
|
+
# everything `extra.requestInfo` reads — arrives in 1.9.2. Below that there is
|
|
75
|
+
# no transport to exercise and no request to read, so unlike the rest of the
|
|
76
|
+
# old-version work there is nothing to reach into: the capability is absent
|
|
77
|
+
# upstream, not merely spelled differently.
|
|
78
|
+
_NEEDS_REQUEST_CONTEXT = ("e2e/official",)
|
|
79
|
+
|
|
47
80
|
|
|
48
81
|
def _ignore_globs(paths: tuple[str, ...]) -> list[str]:
|
|
49
82
|
"""Ignore each path itself plus everything beneath it.
|
|
@@ -57,3 +90,7 @@ def _ignore_globs(paths: tuple[str, ...]) -> list[str]:
|
|
|
57
90
|
|
|
58
91
|
|
|
59
92
|
collect_ignore_glob = _ignore_globs(_MODERN_ONLY if MCP_MAJOR < 2 else _LEGACY_ONLY)
|
|
93
|
+
if not HAS_FASTMCP:
|
|
94
|
+
collect_ignore_glob += _ignore_globs(_NEEDS_FASTMCP)
|
|
95
|
+
if MCP_VERSION < (1, 9, 2):
|
|
96
|
+
collect_ignore_glob += _ignore_globs(_NEEDS_REQUEST_CONTEXT)
|
|
@@ -6,6 +6,11 @@ mint-back, and the protocol error a malformed request must keep. v2 publishes
|
|
|
6
6
|
exactly one event type: `mcp:tools/call`. `initialize` only feeds the
|
|
7
7
|
client-identity ladder and `tools/list` is intercepted for schema injection, so
|
|
8
8
|
neither produces an event.
|
|
9
|
+
|
|
10
|
+
Every `fastmcp` / `httpx2` import is inside a test body, as in the rest of this
|
|
11
|
+
tree. `tests/conftest.py` keeps the community trees out of a run with no
|
|
12
|
+
fastmcp installed, but a module-scope import here would fail at COLLECTION,
|
|
13
|
+
which no conftest gate downstream of it can rescue.
|
|
9
14
|
"""
|
|
10
15
|
|
|
11
16
|
from __future__ import annotations
|
|
@@ -13,10 +18,7 @@ from __future__ import annotations
|
|
|
13
18
|
import json
|
|
14
19
|
import time
|
|
15
20
|
|
|
16
|
-
import httpx2
|
|
17
21
|
import pytest
|
|
18
|
-
from fastmcp import Client
|
|
19
|
-
from fastmcp.client.transports import StreamableHttpTransport
|
|
20
22
|
|
|
21
23
|
from agentcat.modules.constants import (
|
|
22
24
|
AGENTCAT_TAG_SESSION_SOURCE,
|
|
@@ -40,6 +42,9 @@ def _text(result) -> str:
|
|
|
40
42
|
async def test_handshake_and_list_publish_nothing(v4_http_server, capture_queue):
|
|
41
43
|
"""A real handshake plus list_tools produces no events at all — and the
|
|
42
44
|
injected schema survives the SDK's outbound validation."""
|
|
45
|
+
from fastmcp import Client
|
|
46
|
+
from fastmcp.client.transports import StreamableHttpTransport
|
|
47
|
+
|
|
43
48
|
url, _ = v4_http_server
|
|
44
49
|
async with Client(StreamableHttpTransport(url)) as client:
|
|
45
50
|
listed = await client.list_tools()
|
|
@@ -54,6 +59,9 @@ async def test_handshake_and_list_publish_nothing(v4_http_server, capture_queue)
|
|
|
54
59
|
async def test_task_handle_is_minted_then_echoed(v4_http_server, capture_queue):
|
|
55
60
|
"""The mint-back travels over the wire — text and structured — and the
|
|
56
61
|
echoed handle keys the next event to the same task."""
|
|
62
|
+
from fastmcp import Client
|
|
63
|
+
from fastmcp.client.transports import StreamableHttpTransport
|
|
64
|
+
|
|
57
65
|
url, _ = v4_http_server
|
|
58
66
|
async with Client(StreamableHttpTransport(url)) as client:
|
|
59
67
|
first = await client.call_tool(
|
|
@@ -86,6 +94,9 @@ async def test_task_handle_is_minted_then_echoed(v4_http_server, capture_queue):
|
|
|
86
94
|
async def test_client_identity_reaches_the_event(v4_http_server, capture_queue):
|
|
87
95
|
"""The handshake clientInfo is the last rung of the identity ladder, and it
|
|
88
96
|
reaches the tools/call event over a real connection."""
|
|
97
|
+
from fastmcp import Client
|
|
98
|
+
from fastmcp.client.transports import StreamableHttpTransport
|
|
99
|
+
|
|
89
100
|
url, _ = v4_http_server
|
|
90
101
|
async with Client(StreamableHttpTransport(url)) as client:
|
|
91
102
|
await client.call_tool("add_todo", {"text": "who", "context": "x"})
|
|
@@ -106,6 +117,8 @@ async def test_a_malformed_tools_call_keeps_its_own_protocol_error(
|
|
|
106
117
|
customer server's own `-32602` on the wire, and no real client can be made
|
|
107
118
|
to send this, so only a hand-built request reaches it.
|
|
108
119
|
"""
|
|
120
|
+
import httpx2
|
|
121
|
+
|
|
109
122
|
url, _ = v4_http_server
|
|
110
123
|
headers = {
|
|
111
124
|
"Content-Type": "application/json",
|
|
@@ -31,9 +31,13 @@ from agentcat.modules.constants import (
|
|
|
31
31
|
SESSION_ID_PARAM,
|
|
32
32
|
)
|
|
33
33
|
|
|
34
|
-
from .test_utils import sid
|
|
34
|
+
from .test_utils import NEEDS_CONCURRENT_DISPATCH, sid
|
|
35
35
|
from .test_utils.flavors import flavors
|
|
36
36
|
|
|
37
|
+
# Every test here asserts `barrier.peak == TOTAL`, which is unsatisfiable on an
|
|
38
|
+
# SDK that handles messages serially. See `NEEDS_CONCURRENT_DISPATCH`.
|
|
39
|
+
pytestmark = NEEDS_CONCURRENT_DISPATCH
|
|
40
|
+
|
|
37
41
|
TOTAL = 25
|
|
38
42
|
|
|
39
43
|
|
|
@@ -37,7 +37,12 @@ from agentcat.modules.adapters._inner_tap import (
|
|
|
37
37
|
tapped,
|
|
38
38
|
)
|
|
39
39
|
|
|
40
|
-
from .test_utils import
|
|
40
|
+
from .test_utils import (
|
|
41
|
+
LEGACY_ONLY,
|
|
42
|
+
MODERN_ONLY,
|
|
43
|
+
NEEDS_CONCURRENT_DISPATCH,
|
|
44
|
+
NEEDS_LOWLEVEL_ERROR_SEAM,
|
|
45
|
+
)
|
|
41
46
|
|
|
42
47
|
try:
|
|
43
48
|
import fastmcp # noqa: F401
|
|
@@ -501,6 +506,7 @@ class TestOfficialV1:
|
|
|
501
506
|
assert tool_frames[0]["in_app"] is True
|
|
502
507
|
assert "Test value error from tool" in tool_frames[0]["context_line"]
|
|
503
508
|
|
|
509
|
+
@NEEDS_LOWLEVEL_ERROR_SEAM
|
|
504
510
|
@pytest.mark.asyncio
|
|
505
511
|
async def test_bare_lowlevel_v1_publishes_the_handlers_own_exception(
|
|
506
512
|
self, events
|
|
@@ -550,6 +556,7 @@ class TestOfficialV1:
|
|
|
550
556
|
assert _call_events(events, "tool_that_raises")
|
|
551
557
|
assert len(tracked.content) > len(untracked.content)
|
|
552
558
|
|
|
559
|
+
@NEEDS_CONCURRENT_DISPATCH
|
|
553
560
|
@pytest.mark.asyncio
|
|
554
561
|
async def test_parallel_failures_each_get_their_own_slot(self, events):
|
|
555
562
|
from .test_utils.client import create_test_client
|
|
@@ -630,8 +637,15 @@ class TestOfficialV1:
|
|
|
630
637
|
|
|
631
638
|
Nothing the agent sees came from a Python exception, so the surfaced
|
|
632
639
|
message is the whole payload — the sub-call's stack must not be it.
|
|
640
|
+
|
|
641
|
+
The error result is produced by a layer BELOW AgentCat rather than by
|
|
642
|
+
returning a `CallToolResult` from the tool body, which mcp only honors
|
|
643
|
+
from 1.19 (PR #1459) and which JSON-serializes into an `isError=False`
|
|
644
|
+
text block below it. Wrapping `request_handlers` before `track()` puts
|
|
645
|
+
AgentCat above the layer that answers, which is the arrangement this
|
|
646
|
+
test is about, and it behaves identically on every mcp 1.x.
|
|
633
647
|
"""
|
|
634
|
-
from mcp.types import
|
|
648
|
+
from mcp.types import CallToolRequest, ServerResult, TextContent
|
|
635
649
|
|
|
636
650
|
from .test_utils.client import create_test_client
|
|
637
651
|
from .test_utils.todo_server import create_todo_server
|
|
@@ -644,15 +658,33 @@ class TestOfficialV1:
|
|
|
644
658
|
raise Boom(f"INNER {marker}")
|
|
645
659
|
|
|
646
660
|
@server.tool()
|
|
647
|
-
async def outer(marker: str) ->
|
|
648
|
-
"""Handles inner's failure and reports its own
|
|
661
|
+
async def outer(marker: str) -> str:
|
|
662
|
+
"""Handles inner's failure and reports its own message."""
|
|
649
663
|
with contextlib.suppress(Exception):
|
|
650
664
|
await server._tool_manager.call_tool("inner", {"marker": marker})
|
|
651
|
-
return
|
|
652
|
-
|
|
653
|
-
|
|
665
|
+
return f"OUTER declined {marker}"
|
|
666
|
+
|
|
667
|
+
low = server._mcp_server
|
|
668
|
+
answered = low.request_handlers[CallToolRequest]
|
|
669
|
+
|
|
670
|
+
async def declines(req):
|
|
671
|
+
result = await answered(req)
|
|
672
|
+
return ServerResult(
|
|
673
|
+
result.root.model_copy(
|
|
674
|
+
update={
|
|
675
|
+
"isError": True,
|
|
676
|
+
"content": [
|
|
677
|
+
TextContent(
|
|
678
|
+
type="text",
|
|
679
|
+
text=f"OUTER declined {req.params.arguments['marker']}",
|
|
680
|
+
)
|
|
681
|
+
],
|
|
682
|
+
}
|
|
683
|
+
)
|
|
654
684
|
)
|
|
655
685
|
|
|
686
|
+
low.request_handlers[CallToolRequest] = declines
|
|
687
|
+
|
|
656
688
|
track(server, "test_project", AgentCatOptions())
|
|
657
689
|
|
|
658
690
|
async with create_test_client(server) as client:
|
|
@@ -666,11 +698,17 @@ class TestOfficialV1:
|
|
|
666
698
|
"platform": "python",
|
|
667
699
|
}
|
|
668
700
|
|
|
701
|
+
@NEEDS_LOWLEVEL_ERROR_SEAM
|
|
669
702
|
@pytest.mark.asyncio
|
|
670
703
|
async def test_a_schema_validation_failure_keeps_the_surfaced_message(
|
|
671
704
|
self, events
|
|
672
705
|
):
|
|
673
|
-
"""The lowlevel SDK composes that message itself; the probe skips it.
|
|
706
|
+
"""The lowlevel SDK composes that message itself; the probe skips it.
|
|
707
|
+
|
|
708
|
+
Gated on the same seam: the input validation this asserts arrived in
|
|
709
|
+
the very PR that added `_make_error_result`, so below it there is no
|
|
710
|
+
"Input validation error:" for AgentCat to keep.
|
|
711
|
+
"""
|
|
674
712
|
from .test_utils.client import create_test_client
|
|
675
713
|
|
|
676
714
|
server = _bare_v1_server("validating-v1")
|
|
@@ -997,10 +1035,11 @@ class _SwallowingMiddleware:
|
|
|
997
1035
|
try:
|
|
998
1036
|
return await call_next(context)
|
|
999
1037
|
except Exception as exc:
|
|
1000
|
-
from fastmcp.tools import ToolResult
|
|
1001
1038
|
from mcp.types import TextContent
|
|
1002
1039
|
|
|
1003
|
-
|
|
1040
|
+
from .test_utils import error_tool_result
|
|
1041
|
+
|
|
1042
|
+
return error_tool_result(
|
|
1004
1043
|
content=[TextContent(type="text", text=f"swallowed: {exc}")],
|
|
1005
1044
|
is_error=True,
|
|
1006
1045
|
)
|
|
@@ -1102,17 +1141,25 @@ class TestCommunity:
|
|
|
1102
1141
|
|
|
1103
1142
|
@pytest.mark.asyncio
|
|
1104
1143
|
async def test_a_proxied_upstream_error_keeps_the_surfaced_message(self, events):
|
|
1105
|
-
"""The documented
|
|
1106
|
-
|
|
1107
|
-
`providers/proxy.py` passes an upstream error result
|
|
1108
|
-
deliberately — "rather than collapsing it into a raised
|
|
1109
|
-
from a `call_tool_mcp` that never raises. The failure
|
|
1110
|
-
backend; there is no Python exception anywhere in this
|
|
1111
|
-
recover, and no tap placement could change that.
|
|
1112
|
-
|
|
1144
|
+
"""The documented gap, driven through a real proxy.
|
|
1145
|
+
|
|
1146
|
+
From fastmcp 3.4 `providers/proxy.py` passes an upstream error result
|
|
1147
|
+
through deliberately — "rather than collapsing it into a raised
|
|
1148
|
+
ToolError" — from a `call_tool_mcp` that never raises. The failure
|
|
1149
|
+
happened in the backend; there is no Python exception anywhere in this
|
|
1150
|
+
process to recover, and no tap placement could change that.
|
|
1151
|
+
|
|
1152
|
+
Below 3.4 the proxy did exactly the collapsing that comment rules out
|
|
1153
|
+
(`if result.isError: raise ToolError(first.text)`), so there IS a local
|
|
1154
|
+
exception and the tap keeps it — the gap is a CONSEQUENCE of PR #4217
|
|
1155
|
+
making the pass-through expressible, not a property of proxying. Both
|
|
1156
|
+
branches are asserted rather than one being skipped, so this still
|
|
1157
|
+
fails loudly if a future FastMCP changes its mind again.
|
|
1113
1158
|
"""
|
|
1114
1159
|
from fastmcp import Client
|
|
1115
1160
|
|
|
1161
|
+
from .test_utils import FASTMCP_TOOLRESULT_HAS_IS_ERROR
|
|
1162
|
+
|
|
1116
1163
|
backend = _community_server("proxy-backend")
|
|
1117
1164
|
front = _create_proxy(backend)
|
|
1118
1165
|
track(front, "test_project", AgentCatOptions())
|
|
@@ -1128,7 +1175,12 @@ class TestCommunity:
|
|
|
1128
1175
|
upstream = result.content[0].text
|
|
1129
1176
|
assert "kaboom one" in upstream
|
|
1130
1177
|
error = _one(events, "boom").error
|
|
1131
|
-
assert error
|
|
1178
|
+
assert error["message"] == upstream
|
|
1179
|
+
if FASTMCP_TOOLRESULT_HAS_IS_ERROR:
|
|
1180
|
+
assert error == {"message": upstream, "type": None, "platform": "python"}
|
|
1181
|
+
else:
|
|
1182
|
+
assert error["type"] == "ToolError"
|
|
1183
|
+
assert error["frames"]
|
|
1132
1184
|
|
|
1133
1185
|
@pytest.mark.asyncio
|
|
1134
1186
|
async def test_the_wire_error_is_what_an_untracked_server_returns(self, events):
|
|
@@ -1242,9 +1294,10 @@ class TestCommunity:
|
|
|
1242
1294
|
frames, to the three-key payload a server with no tap at all produces.
|
|
1243
1295
|
"""
|
|
1244
1296
|
from fastmcp import Client, FastMCP
|
|
1245
|
-
from fastmcp.tools import ToolResult
|
|
1246
1297
|
from mcp.types import TextContent
|
|
1247
1298
|
|
|
1299
|
+
from .test_utils import error_tool_result
|
|
1300
|
+
|
|
1248
1301
|
sub_call_is_inside = asyncio.Event()
|
|
1249
1302
|
let_the_sub_call_finish = asyncio.Event()
|
|
1250
1303
|
spawned: list = []
|
|
@@ -1261,7 +1314,7 @@ class TestCommunity:
|
|
|
1261
1314
|
except Exception as exc:
|
|
1262
1315
|
let_the_sub_call_finish.set()
|
|
1263
1316
|
await spawned[0]
|
|
1264
|
-
return
|
|
1317
|
+
return error_tool_result(
|
|
1265
1318
|
content=[TextContent(type="text", text=f"swallowed: {exc}")],
|
|
1266
1319
|
is_error=True,
|
|
1267
1320
|
)
|
|
@@ -29,7 +29,7 @@ from agentcat.modules.constants import (
|
|
|
29
29
|
)
|
|
30
30
|
from agentcat.modules.handles import derive_session_id
|
|
31
31
|
|
|
32
|
-
from .test_utils import sid
|
|
32
|
+
from .test_utils import NEEDS_STRUCTURED_OUTPUT, read_only_hint, sid
|
|
33
33
|
from .test_utils.client import create_test_client
|
|
34
34
|
from .test_utils.delivery import delivered_arguments_for, record_delivered_arguments
|
|
35
35
|
from .test_utils.todo_server import create_todo_server
|
|
@@ -115,6 +115,7 @@ async def test_prompted_mode_end_to_end(capture):
|
|
|
115
115
|
assert call_events[0].user_intent.startswith("Adding a todo item")
|
|
116
116
|
|
|
117
117
|
|
|
118
|
+
@NEEDS_STRUCTURED_OUTPUT
|
|
118
119
|
async def test_structured_mint_back_mirrors_into_structured_content(capture):
|
|
119
120
|
"""A tool with an outputSchema gets `_mcp_instructions` mirrored in, and its
|
|
120
121
|
schema declares the field so schema-validating clients still accept it."""
|
|
@@ -181,7 +182,7 @@ async def test_get_more_tools_keeps_its_own_context_and_publishes(capture):
|
|
|
181
182
|
# described by the tool's own copy — and handles ride alongside.
|
|
182
183
|
assert gmt.inputSchema["required"] == ["context"]
|
|
183
184
|
assert "session_id" in gmt.inputSchema["properties"]
|
|
184
|
-
assert gmt
|
|
185
|
+
assert read_only_hint(gmt) is True
|
|
185
186
|
|
|
186
187
|
result = await client.call_tool(
|
|
187
188
|
"get_more_tools", {"context": "I need a tool to send emails"}
|
|
@@ -237,7 +238,13 @@ async def test_hook_mode(capture):
|
|
|
237
238
|
r2 = await client.call_tool("add_todo", {"text": "hook two"})
|
|
238
239
|
assert "[MCP INSTRUCTIONS]" not in _text(r1)
|
|
239
240
|
assert "[MCP INSTRUCTIONS]" not in _text(r2)
|
|
240
|
-
|
|
241
|
+
# `getattr`, not attribute access: `structuredContent` is a real field
|
|
242
|
+
# from mcp 1.10 and an unset extra before it, and pydantic raises
|
|
243
|
+
# AttributeError for an extra that was never assigned. The claim here
|
|
244
|
+
# is absence either way.
|
|
245
|
+
assert MCP_INSTRUCTIONS_KEY not in (
|
|
246
|
+
getattr(r1, "structuredContent", None) or {}
|
|
247
|
+
)
|
|
241
248
|
|
|
242
249
|
call_events = _call_events(capture)
|
|
243
250
|
expected = derive_session_id("cust-1", "proj_test")
|
|
@@ -575,9 +582,23 @@ async def test_re_arm_is_not_stacked_by_a_second_track(capture):
|
|
|
575
582
|
|
|
576
583
|
async def test_intermediate_mrtr_round_is_tagged_but_never_decorated(capture):
|
|
577
584
|
"""A round that asks the client for more input is not the completing round,
|
|
578
|
-
so it carries no mint-back — text or structured.
|
|
585
|
+
so it carries no mint-back — text or structured.
|
|
586
|
+
|
|
587
|
+
The round is registered straight into `request_handlers` rather than
|
|
588
|
+
through `@server.call_tool()`: returning a `CallToolResult` from the
|
|
589
|
+
decorated function is only honored from mcp 1.19 (PR #1459), and below it
|
|
590
|
+
the SDK wraps the model itself as content and fails its own validation.
|
|
591
|
+
`request_handlers` takes a `ServerResult` on every 1.x, and `resultType`
|
|
592
|
+
rides along as an extra field because `CallToolResult` is extra="allow".
|
|
593
|
+
"""
|
|
579
594
|
from mcp.server.lowlevel import Server
|
|
580
|
-
from mcp.types import
|
|
595
|
+
from mcp.types import (
|
|
596
|
+
CallToolRequest,
|
|
597
|
+
CallToolRequestParams,
|
|
598
|
+
CallToolResult,
|
|
599
|
+
ServerResult,
|
|
600
|
+
Tool,
|
|
601
|
+
)
|
|
581
602
|
|
|
582
603
|
server = Server("mrtr-server")
|
|
583
604
|
|
|
@@ -591,13 +612,16 @@ async def test_intermediate_mrtr_round_is_tagged_but_never_decorated(capture):
|
|
|
591
612
|
)
|
|
592
613
|
]
|
|
593
614
|
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
615
|
+
async def call_tool(req):
|
|
616
|
+
return ServerResult(
|
|
617
|
+
CallToolResult(
|
|
618
|
+
content=[TextContent(type="text", text="need more")],
|
|
619
|
+
resultType="input_required",
|
|
620
|
+
)
|
|
599
621
|
)
|
|
600
622
|
|
|
623
|
+
server.request_handlers[CallToolRequest] = call_tool
|
|
624
|
+
|
|
601
625
|
track(server, "proj_test")
|
|
602
626
|
handler = server.request_handlers[CallToolRequest]
|
|
603
627
|
result = await handler(
|
|
@@ -608,7 +632,10 @@ async def test_intermediate_mrtr_round_is_tagged_but_never_decorated(capture):
|
|
|
608
632
|
)
|
|
609
633
|
|
|
610
634
|
assert [block.text for block in result.root.content] == ["need more"]
|
|
611
|
-
|
|
635
|
+
# See the note in `test_hook_mode`: absence is the claim, and below mcp
|
|
636
|
+
# 1.10 an unmirrored `structuredContent` is an unset extra rather than a
|
|
637
|
+
# field holding None.
|
|
638
|
+
assert getattr(result.root, "structuredContent", None) is None
|
|
612
639
|
event = _call_events(capture)[0]
|
|
613
640
|
assert event.tags["agentcat_mrtr"] == "input_required"
|
|
614
641
|
assert event.session_id.startswith("ses_")
|
|
@@ -25,16 +25,26 @@ import pytest
|
|
|
25
25
|
from agentcat import AgentCatOptions, track
|
|
26
26
|
from agentcat.modules.constants import MCP_INSTRUCTIONS_KEY, SESSION_ID_PARAM
|
|
27
27
|
|
|
28
|
-
from .test_utils import sid
|
|
28
|
+
from .test_utils import FASTMCP_TOOLRESULT_HAS_IS_ERROR, sid
|
|
29
29
|
from .test_utils.flavors import flavors
|
|
30
30
|
|
|
31
31
|
# (error key, structured key) as each flavor's own result model spells them.
|
|
32
|
+
# A `None` error key means this era's result model has no error field at all,
|
|
33
|
+
# so the payload correctly carries neither spelling — which is still exactly
|
|
34
|
+
# what this module pins: the event keeps the era's OWN field names.
|
|
32
35
|
EXPECTED_SPELLING = {
|
|
33
36
|
"official-fastmcp-v1": ("isError", "structuredContent"),
|
|
34
37
|
"lowlevel-v1": ("isError", "structuredContent"),
|
|
35
38
|
"mcpserver-v2": ("is_error", "structured_content"),
|
|
36
39
|
"lowlevel-v2": ("is_error", "structured_content"),
|
|
37
|
-
|
|
40
|
+
# Community FastMCP only grew `ToolResult.is_error` in 3.4 (PR #4217); on
|
|
41
|
+
# the 3.0-3.3 line the model has three fields and the dump has no error
|
|
42
|
+
# key. The EVENT's own `is_error` is unaffected — the adapter sets it, it
|
|
43
|
+
# is not read back off this payload.
|
|
44
|
+
"community-v3": (
|
|
45
|
+
"is_error" if FASTMCP_TOOLRESULT_HAS_IS_ERROR else None,
|
|
46
|
+
"structured_content",
|
|
47
|
+
),
|
|
38
48
|
"community-v4": ("is_error", "structured_content"),
|
|
39
49
|
}
|
|
40
50
|
|
|
@@ -67,8 +77,11 @@ async def test_the_event_response_keeps_its_eras_own_field_names(flavor, capture
|
|
|
67
77
|
response = capture[0].response
|
|
68
78
|
assert isinstance(response, dict)
|
|
69
79
|
# This era's spelling is present, and the other era's is nowhere in it.
|
|
70
|
-
|
|
80
|
+
if error_key is not None:
|
|
81
|
+
assert error_key in response
|
|
71
82
|
assert structured_key in response
|
|
83
|
+
# With `error_key` None this asserts NEITHER error spelling appears, which
|
|
84
|
+
# is strictly stronger than the case where one is expected.
|
|
72
85
|
assert not (BOTH_SPELLINGS - {error_key, structured_key}) & set(response)
|
|
73
86
|
# ...and it is the customer's own result, undecorated: the mint-back is
|
|
74
87
|
# wire-only and must never reach the analytics payload.
|