agentcat 2.0.0b2__tar.gz → 2.0.0b5__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.0b2 → agentcat-2.0.0b5}/PKG-INFO +23 -10
- {agentcat-2.0.0b2 → agentcat-2.0.0b5}/README.md +20 -7
- {agentcat-2.0.0b2 → agentcat-2.0.0b5}/pyproject.toml +3 -3
- {agentcat-2.0.0b2 → agentcat-2.0.0b5}/src/agentcat/__init__.py +8 -3
- {agentcat-2.0.0b2 → agentcat-2.0.0b5}/src/agentcat/modules/adapters/community.py +31 -13
- {agentcat-2.0.0b2 → agentcat-2.0.0b5}/src/agentcat/modules/adapters/lowlevel_v1.py +40 -19
- {agentcat-2.0.0b2 → agentcat-2.0.0b5}/src/agentcat/modules/adapters/lowlevel_v2.py +56 -14
- {agentcat-2.0.0b2 → agentcat-2.0.0b5}/src/agentcat/modules/callpath.py +11 -6
- {agentcat-2.0.0b2 → agentcat-2.0.0b5}/src/agentcat/modules/diagnostics.py +24 -3
- {agentcat-2.0.0b2 → agentcat-2.0.0b5}/src/agentcat/modules/event_queue.py +148 -82
- {agentcat-2.0.0b2 → agentcat-2.0.0b5}/src/agentcat/modules/exceptions.py +124 -65
- {agentcat-2.0.0b2 → agentcat-2.0.0b5}/src/agentcat/modules/exporters/otlp.py +24 -1
- {agentcat-2.0.0b2 → agentcat-2.0.0b5}/src/agentcat/modules/handles.py +2 -4
- agentcat-2.0.0b5/src/agentcat/modules/hooks.py +233 -0
- {agentcat-2.0.0b2 → agentcat-2.0.0b5}/src/agentcat/modules/identify.py +8 -2
- {agentcat-2.0.0b2 → agentcat-2.0.0b5}/src/agentcat/modules/injection.py +42 -7
- {agentcat-2.0.0b2 → agentcat-2.0.0b5}/src/agentcat/modules/internal.py +3 -7
- {agentcat-2.0.0b2 → agentcat-2.0.0b5}/src/agentcat/modules/logging.py +29 -8
- {agentcat-2.0.0b2 → agentcat-2.0.0b5}/src/agentcat/modules/redaction.py +7 -10
- {agentcat-2.0.0b2 → agentcat-2.0.0b5}/src/agentcat/types.py +16 -2
- {agentcat-2.0.0b2 → agentcat-2.0.0b5}/src/agentcat/utils.py +17 -0
- agentcat-2.0.0b5/tests/e2e/community_v3/test_agent_handle_http.py +203 -0
- {agentcat-2.0.0b2 → agentcat-2.0.0b5}/tests/e2e/community_v3/test_event_capture_http.py +53 -4
- agentcat-2.0.0b5/tests/e2e/community_v3/test_identify_http.py +189 -0
- {agentcat-2.0.0b2 → agentcat-2.0.0b5}/tests/e2e/community_v3/test_stateless_http.py +9 -0
- agentcat-2.0.0b5/tests/e2e/community_v4/test_agent_handle_http.py +202 -0
- agentcat-2.0.0b5/tests/e2e/community_v4/test_identify_http.py +199 -0
- {agentcat-2.0.0b2 → agentcat-2.0.0b5}/tests/e2e/community_v4/test_session_http.py +50 -4
- {agentcat-2.0.0b2 → agentcat-2.0.0b5}/tests/e2e/community_v4/test_stateless_http.py +12 -2
- {agentcat-2.0.0b2 → agentcat-2.0.0b5}/tests/e2e/conftest.py +1 -1
- agentcat-2.0.0b5/tests/e2e/official/test_agent_handle_http.py +237 -0
- {agentcat-2.0.0b2 → agentcat-2.0.0b5}/tests/e2e/official/test_identify_http.py +24 -4
- {agentcat-2.0.0b2 → agentcat-2.0.0b5}/tests/e2e/official/test_session_http.py +38 -0
- {agentcat-2.0.0b2 → agentcat-2.0.0b5}/tests/e2e/official/test_stateless_http.py +11 -0
- agentcat-2.0.0b5/tests/e2e/official_modern/test_agent_handle_http.py +198 -0
- agentcat-2.0.0b5/tests/e2e/official_modern/test_identify_http.py +231 -0
- {agentcat-2.0.0b2 → agentcat-2.0.0b5}/tests/e2e/official_modern/test_session_http.py +96 -0
- {agentcat-2.0.0b2 → agentcat-2.0.0b5}/tests/e2e/official_modern/test_stateless_http.py +18 -5
- agentcat-2.0.0b5/tests/test_async_hooks.py +327 -0
- {agentcat-2.0.0b2 → agentcat-2.0.0b5}/tests/test_callpath.py +31 -5
- {agentcat-2.0.0b2 → agentcat-2.0.0b5}/tests/test_diagnostics_attributes.py +16 -0
- {agentcat-2.0.0b2 → agentcat-2.0.0b5}/tests/test_diagnostics_export.py +61 -0
- {agentcat-2.0.0b2 → agentcat-2.0.0b5}/tests/test_diagnostics_sink.py +2 -1
- {agentcat-2.0.0b2 → agentcat-2.0.0b5}/tests/test_event_capture_completeness.py +11 -11
- {agentcat-2.0.0b2 → agentcat-2.0.0b5}/tests/test_event_queue.py +142 -113
- {agentcat-2.0.0b2 → agentcat-2.0.0b5}/tests/test_event_tags_properties.py +3 -3
- {agentcat-2.0.0b2 → agentcat-2.0.0b5}/tests/test_exceptions.py +141 -1
- {agentcat-2.0.0b2 → agentcat-2.0.0b5}/tests/test_exporter_sdk_version.py +62 -0
- agentcat-2.0.0b5/tests/test_hook_offload.py +207 -0
- {agentcat-2.0.0b2 → agentcat-2.0.0b5}/tests/test_identify_shape.py +57 -0
- {agentcat-2.0.0b2 → agentcat-2.0.0b5}/tests/test_injection.py +58 -8
- {agentcat-2.0.0b2 → agentcat-2.0.0b5}/tests/test_logging.py +162 -2
- {agentcat-2.0.0b2 → agentcat-2.0.0b5}/tests/test_lowlevel_v1_handles.py +48 -0
- {agentcat-2.0.0b2 → agentcat-2.0.0b5}/tests/test_lowlevel_v2_handles.py +48 -0
- {agentcat-2.0.0b2 → agentcat-2.0.0b5}/tests/test_multiple_servers.py +4 -4
- agentcat-2.0.0b5/tests/test_process_safety.py +265 -0
- {agentcat-2.0.0b2 → agentcat-2.0.0b5}/tests/test_rebuild_on_demand.py +79 -0
- {agentcat-2.0.0b2 → agentcat-2.0.0b5}/tests/test_request_extra.py +3 -3
- {agentcat-2.0.0b2 → agentcat-2.0.0b5}/tests/test_tool_context.py +1 -1
- {agentcat-2.0.0b2 → agentcat-2.0.0b5}/tests/test_truncation.py +1 -1
- agentcat-2.0.0b2/tests/e2e/community_v3/test_identify_http.py +0 -110
- {agentcat-2.0.0b2 → agentcat-2.0.0b5}/.gitignore +0 -0
- {agentcat-2.0.0b2 → agentcat-2.0.0b5}/CONTRIBUTING.md +0 -0
- {agentcat-2.0.0b2 → agentcat-2.0.0b5}/LICENSE +0 -0
- {agentcat-2.0.0b2 → agentcat-2.0.0b5}/docs/cats/bibi.png +0 -0
- {agentcat-2.0.0b2 → agentcat-2.0.0b5}/docs/cats/zelda.jpg +0 -0
- {agentcat-2.0.0b2 → agentcat-2.0.0b5}/docs/static/architecture.png +0 -0
- {agentcat-2.0.0b2 → agentcat-2.0.0b5}/docs/static/og-image.png +0 -0
- {agentcat-2.0.0b2 → agentcat-2.0.0b5}/src/agentcat/modules/__init__.py +0 -0
- {agentcat-2.0.0b2 → agentcat-2.0.0b5}/src/agentcat/modules/adapters/__init__.py +0 -0
- {agentcat-2.0.0b2 → agentcat-2.0.0b5}/src/agentcat/modules/adapters/_common.py +0 -0
- {agentcat-2.0.0b2 → agentcat-2.0.0b5}/src/agentcat/modules/adapters/_inner_tap.py +0 -0
- {agentcat-2.0.0b2 → agentcat-2.0.0b5}/src/agentcat/modules/client_identity.py +0 -0
- {agentcat-2.0.0b2 → agentcat-2.0.0b5}/src/agentcat/modules/constants.py +0 -0
- {agentcat-2.0.0b2 → agentcat-2.0.0b5}/src/agentcat/modules/detection.py +0 -0
- {agentcat-2.0.0b2 → agentcat-2.0.0b5}/src/agentcat/modules/exporters/__init__.py +0 -0
- {agentcat-2.0.0b2 → agentcat-2.0.0b5}/src/agentcat/modules/exporters/datadog.py +0 -0
- {agentcat-2.0.0b2 → agentcat-2.0.0b5}/src/agentcat/modules/exporters/sentry.py +0 -0
- {agentcat-2.0.0b2 → agentcat-2.0.0b5}/src/agentcat/modules/exporters/trace_context.py +0 -0
- {agentcat-2.0.0b2 → agentcat-2.0.0b5}/src/agentcat/modules/request_extra.py +0 -0
- {agentcat-2.0.0b2 → agentcat-2.0.0b5}/src/agentcat/modules/sanitization.py +0 -0
- {agentcat-2.0.0b2 → agentcat-2.0.0b5}/src/agentcat/modules/telemetry.py +0 -0
- {agentcat-2.0.0b2 → agentcat-2.0.0b5}/src/agentcat/modules/tools.py +0 -0
- {agentcat-2.0.0b2 → agentcat-2.0.0b5}/src/agentcat/modules/truncation.py +0 -0
- {agentcat-2.0.0b2 → agentcat-2.0.0b5}/src/agentcat/modules/validation.py +0 -0
- {agentcat-2.0.0b2 → agentcat-2.0.0b5}/src/agentcat/thirdparty/__init__.py +0 -0
- {agentcat-2.0.0b2 → agentcat-2.0.0b5}/src/agentcat/thirdparty/ksuid/__init__.py +0 -0
- {agentcat-2.0.0b2 → agentcat-2.0.0b5}/src/agentcat/thirdparty/ksuid/baseconv.py +0 -0
- {agentcat-2.0.0b2 → agentcat-2.0.0b5}/src/agentcat/thirdparty/ksuid/ksuid.py +0 -0
- {agentcat-2.0.0b2 → agentcat-2.0.0b5}/tests/__init__.py +0 -0
- {agentcat-2.0.0b2 → agentcat-2.0.0b5}/tests/community/__init__.py +0 -0
- {agentcat-2.0.0b2 → agentcat-2.0.0b5}/tests/community/test_community_v3_event_serialization.py +0 -0
- {agentcat-2.0.0b2 → agentcat-2.0.0b5}/tests/community/test_community_v3_handles.py +0 -0
- {agentcat-2.0.0b2 → agentcat-2.0.0b5}/tests/community/test_community_v3_inject_context.py +0 -0
- {agentcat-2.0.0b2 → agentcat-2.0.0b5}/tests/community/test_community_v3_openapi.py +0 -0
- {agentcat-2.0.0b2 → agentcat-2.0.0b5}/tests/community/test_community_v3_runtime_state_tools.py +0 -0
- {agentcat-2.0.0b2 → agentcat-2.0.0b5}/tests/conftest.py +0 -0
- {agentcat-2.0.0b2 → agentcat-2.0.0b5}/tests/e2e/__init__.py +0 -0
- {agentcat-2.0.0b2 → agentcat-2.0.0b5}/tests/e2e/_helpers.py +0 -0
- {agentcat-2.0.0b2 → agentcat-2.0.0b5}/tests/e2e/community_v3/__init__.py +0 -0
- {agentcat-2.0.0b2 → agentcat-2.0.0b5}/tests/e2e/community_v3/conftest.py +0 -0
- {agentcat-2.0.0b2 → agentcat-2.0.0b5}/tests/e2e/community_v3/test_request_extra_http.py +0 -0
- {agentcat-2.0.0b2 → agentcat-2.0.0b5}/tests/e2e/community_v4/__init__.py +0 -0
- {agentcat-2.0.0b2 → agentcat-2.0.0b5}/tests/e2e/community_v4/conftest.py +0 -0
- {agentcat-2.0.0b2 → agentcat-2.0.0b5}/tests/e2e/official/__init__.py +0 -0
- {agentcat-2.0.0b2 → agentcat-2.0.0b5}/tests/e2e/official/conftest.py +0 -0
- {agentcat-2.0.0b2 → agentcat-2.0.0b5}/tests/e2e/official/test_event_capture_http.py +0 -0
- {agentcat-2.0.0b2 → agentcat-2.0.0b5}/tests/e2e/official/test_redaction_http.py +0 -0
- {agentcat-2.0.0b2 → agentcat-2.0.0b5}/tests/e2e/official/test_request_extra_http.py +0 -0
- {agentcat-2.0.0b2 → agentcat-2.0.0b5}/tests/e2e/official_modern/__init__.py +0 -0
- {agentcat-2.0.0b2 → agentcat-2.0.0b5}/tests/e2e/official_modern/conftest.py +0 -0
- {agentcat-2.0.0b2 → agentcat-2.0.0b5}/tests/e2e/official_modern/test_mcpserver_http.py +0 -0
- {agentcat-2.0.0b2 → agentcat-2.0.0b5}/tests/test_api_base_url.py +0 -0
- {agentcat-2.0.0b2 → agentcat-2.0.0b5}/tests/test_client_identity.py +0 -0
- {agentcat-2.0.0b2 → agentcat-2.0.0b5}/tests/test_community_v4_handles.py +0 -0
- {agentcat-2.0.0b2 → agentcat-2.0.0b5}/tests/test_concurrency_handles.py +0 -0
- {agentcat-2.0.0b2 → agentcat-2.0.0b5}/tests/test_constants_copy.py +0 -0
- {agentcat-2.0.0b2 → agentcat-2.0.0b5}/tests/test_customer_owned_parameters.py +0 -0
- {agentcat-2.0.0b2 → agentcat-2.0.0b5}/tests/test_detection.py +0 -0
- {agentcat-2.0.0b2 → agentcat-2.0.0b5}/tests/test_diagnostics_auth.py +0 -0
- {agentcat-2.0.0b2 → agentcat-2.0.0b5}/tests/test_diagnostics_integration.py +0 -0
- {agentcat-2.0.0b2 → agentcat-2.0.0b5}/tests/test_diagnostics_no_payload.py +0 -0
- {agentcat-2.0.0b2 → agentcat-2.0.0b5}/tests/test_diagnostics_optout.py +0 -0
- {agentcat-2.0.0b2 → agentcat-2.0.0b5}/tests/test_diagnostics_record.py +0 -0
- {agentcat-2.0.0b2 → agentcat-2.0.0b5}/tests/test_diagnostics_test_env.py +0 -0
- {agentcat-2.0.0b2 → agentcat-2.0.0b5}/tests/test_dynamic_tracking.py +0 -0
- {agentcat-2.0.0b2 → agentcat-2.0.0b5}/tests/test_handles.py +0 -0
- {agentcat-2.0.0b2 → agentcat-2.0.0b5}/tests/test_inner_tap.py +0 -0
- {agentcat-2.0.0b2 → agentcat-2.0.0b5}/tests/test_options_v2.py +0 -0
- {agentcat-2.0.0b2 → agentcat-2.0.0b5}/tests/test_publish_custom_event.py +0 -0
- {agentcat-2.0.0b2 → agentcat-2.0.0b5}/tests/test_redaction.py +0 -0
- {agentcat-2.0.0b2 → agentcat-2.0.0b5}/tests/test_removed_events.py +0 -0
- {agentcat-2.0.0b2 → agentcat-2.0.0b5}/tests/test_report_missing.py +0 -0
- {agentcat-2.0.0b2 → agentcat-2.0.0b5}/tests/test_response_shape.py +0 -0
- {agentcat-2.0.0b2 → agentcat-2.0.0b5}/tests/test_sanitization.py +0 -0
- {agentcat-2.0.0b2 → agentcat-2.0.0b5}/tests/test_session_id_validation.py +0 -0
- {agentcat-2.0.0b2 → agentcat-2.0.0b5}/tests/test_tag_validation.py +0 -0
- {agentcat-2.0.0b2 → agentcat-2.0.0b5}/tests/test_truncation_json_safe.py +0 -0
- {agentcat-2.0.0b2 → agentcat-2.0.0b5}/tests/test_utils/__init__.py +0 -0
- {agentcat-2.0.0b2 → agentcat-2.0.0b5}/tests/test_utils/client.py +0 -0
- {agentcat-2.0.0b2 → agentcat-2.0.0b5}/tests/test_utils/community_client.py +0 -0
- {agentcat-2.0.0b2 → agentcat-2.0.0b5}/tests/test_utils/community_openapi_server.py +0 -0
- {agentcat-2.0.0b2 → agentcat-2.0.0b5}/tests/test_utils/community_todo_server.py +0 -0
- {agentcat-2.0.0b2 → agentcat-2.0.0b5}/tests/test_utils/delivery.py +0 -0
- {agentcat-2.0.0b2 → agentcat-2.0.0b5}/tests/test_utils/flavors.py +0 -0
- {agentcat-2.0.0b2 → agentcat-2.0.0b5}/tests/test_utils/modern_server.py +0 -0
- {agentcat-2.0.0b2 → agentcat-2.0.0b5}/tests/test_utils/todo_server.py +0 -0
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: agentcat
|
|
3
|
-
Version: 2.0.
|
|
4
|
-
Summary: Analytics tool for MCP (Model Context Protocol) servers and
|
|
3
|
+
Version: 2.0.0b5
|
|
4
|
+
Summary: Analytics tool for MCP (Model Context Protocol) servers, Claude Connectors, and ChatGPT Plugins - 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
|
|
7
7
|
Project-URL: Repository, https://github.com/agentcathq/agentcat-python-sdk
|
|
8
8
|
Author-email: "AgentCat, Inc." <support@agentcat.com>
|
|
9
9
|
License: MIT
|
|
10
10
|
License-File: LICENSE
|
|
11
|
-
Classifier: Development Status ::
|
|
11
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
12
12
|
Classifier: Intended Audience :: Developers
|
|
13
13
|
Classifier: License :: OSI Approved :: MIT License
|
|
14
14
|
Classifier: Programming Language :: Python :: 3
|
|
@@ -70,16 +70,12 @@ This SDK also provides a free and simple way to forward telemetry like logs, tra
|
|
|
70
70
|
|
|
71
71
|
```bash
|
|
72
72
|
# Basic installation (includes official MCP SDK)
|
|
73
|
-
pip install
|
|
73
|
+
pip install agentcat
|
|
74
74
|
|
|
75
75
|
# With Jlowin's/Prefect's FastMCP support
|
|
76
|
-
pip install
|
|
76
|
+
pip install "agentcat[community]"
|
|
77
77
|
```
|
|
78
78
|
|
|
79
|
-
`--pre` is required while 2.x is a prerelease: without it pip skips
|
|
80
|
-
`2.0.0b2` and resolves the 1.x line instead, which has none of the features
|
|
81
|
-
documented below. Drop the flag once a stable 2.0.0 ships.
|
|
82
|
-
|
|
83
79
|
One `track()` call covers every supported server shape:
|
|
84
80
|
|
|
85
81
|
| Runtime | Supported |
|
|
@@ -203,6 +199,8 @@ def identify_user(request, extra):
|
|
|
203
199
|
agentcat.track(server, "proj_0000000", AgentCatOptions(identify=identify_user))
|
|
204
200
|
```
|
|
205
201
|
|
|
202
|
+
The hook may be sync or async — `async def identify_user(request, extra)` works the same way. A sync hook runs on a worker thread, so a blocking lookup stalls only its own call, never the rest of your server; note that this means a *sync* hook cannot use asyncio APIs (make it `async def` if it needs the loop). Every hook runs under a 5-second cap — a slower one is logged and its call proceeds anonymously. Returning anything that is not a `UserIdentity`, or raising, publishes the event anonymously rather than failing the call.
|
|
203
|
+
|
|
206
204
|
### Bringing your own session IDs
|
|
207
205
|
|
|
208
206
|
If you already have a correlation ID — a trace ID, a job ID, a header your gateway sets — hand it to AgentCat with `resolve_session_id` and no `session_id` parameter is injected into your tools at all:
|
|
@@ -305,11 +303,26 @@ Learn more about our free and open source [telemetry integrations](https://docs.
|
|
|
305
303
|
|
|
306
304
|
### Known limitations
|
|
307
305
|
|
|
308
|
-
Two behaviors are worth knowing before you read your first dashboard. Both are deliberate
|
|
306
|
+
Two behaviors are worth knowing before you read your first dashboard. Both are deliberate in the 2.x line.
|
|
309
307
|
|
|
310
308
|
- **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.
|
|
311
309
|
- **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.
|
|
312
310
|
|
|
311
|
+
### Shutdown behavior
|
|
312
|
+
|
|
313
|
+
AgentCat never touches your process lifecycle: no signal handlers, no forced
|
|
314
|
+
exits, and no exit-time event drain. The SDK's single publish worker is a
|
|
315
|
+
daemon thread, so your shutdown — `Ctrl-C`, `SIGTERM`, `sys.exit()` — runs
|
|
316
|
+
exactly as it would untracked, and is never delayed by AgentCat. The trade:
|
|
317
|
+
telemetry still queued at the moment the process exits is dropped rather than
|
|
318
|
+
flushed. The SDK keeps exactly two bounded exit hooks, neither of which sends
|
|
319
|
+
events: one stops the publish worker before interpreter finalization (instant
|
|
320
|
+
when idle, ~1-second cap otherwise — on Linux with CPython ≤3.13 a daemon
|
|
321
|
+
thread still running during finalization can abort the process, CPython
|
|
322
|
+
gh-87135, and stopping first closes that path), and the internal-diagnostics
|
|
323
|
+
beacon below — skipped when there is nothing buffered, capped at ~2 seconds
|
|
324
|
+
when there is.
|
|
325
|
+
|
|
313
326
|
### Internal diagnostics
|
|
314
327
|
|
|
315
328
|
To help us catch and fix broken installs, the SDK sends AgentCat a small, anonymized
|
|
@@ -38,16 +38,12 @@ This SDK also provides a free and simple way to forward telemetry like logs, tra
|
|
|
38
38
|
|
|
39
39
|
```bash
|
|
40
40
|
# Basic installation (includes official MCP SDK)
|
|
41
|
-
pip install
|
|
41
|
+
pip install agentcat
|
|
42
42
|
|
|
43
43
|
# With Jlowin's/Prefect's FastMCP support
|
|
44
|
-
pip install
|
|
44
|
+
pip install "agentcat[community]"
|
|
45
45
|
```
|
|
46
46
|
|
|
47
|
-
`--pre` is required while 2.x is a prerelease: without it pip skips
|
|
48
|
-
`2.0.0b2` and resolves the 1.x line instead, which has none of the features
|
|
49
|
-
documented below. Drop the flag once a stable 2.0.0 ships.
|
|
50
|
-
|
|
51
47
|
One `track()` call covers every supported server shape:
|
|
52
48
|
|
|
53
49
|
| Runtime | Supported |
|
|
@@ -171,6 +167,8 @@ def identify_user(request, extra):
|
|
|
171
167
|
agentcat.track(server, "proj_0000000", AgentCatOptions(identify=identify_user))
|
|
172
168
|
```
|
|
173
169
|
|
|
170
|
+
The hook may be sync or async — `async def identify_user(request, extra)` works the same way. A sync hook runs on a worker thread, so a blocking lookup stalls only its own call, never the rest of your server; note that this means a *sync* hook cannot use asyncio APIs (make it `async def` if it needs the loop). Every hook runs under a 5-second cap — a slower one is logged and its call proceeds anonymously. Returning anything that is not a `UserIdentity`, or raising, publishes the event anonymously rather than failing the call.
|
|
171
|
+
|
|
174
172
|
### Bringing your own session IDs
|
|
175
173
|
|
|
176
174
|
If you already have a correlation ID — a trace ID, a job ID, a header your gateway sets — hand it to AgentCat with `resolve_session_id` and no `session_id` parameter is injected into your tools at all:
|
|
@@ -273,11 +271,26 @@ Learn more about our free and open source [telemetry integrations](https://docs.
|
|
|
273
271
|
|
|
274
272
|
### Known limitations
|
|
275
273
|
|
|
276
|
-
Two behaviors are worth knowing before you read your first dashboard. Both are deliberate
|
|
274
|
+
Two behaviors are worth knowing before you read your first dashboard. Both are deliberate in the 2.x line.
|
|
277
275
|
|
|
278
276
|
- **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.
|
|
279
277
|
- **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.
|
|
280
278
|
|
|
279
|
+
### Shutdown behavior
|
|
280
|
+
|
|
281
|
+
AgentCat never touches your process lifecycle: no signal handlers, no forced
|
|
282
|
+
exits, and no exit-time event drain. The SDK's single publish worker is a
|
|
283
|
+
daemon thread, so your shutdown — `Ctrl-C`, `SIGTERM`, `sys.exit()` — runs
|
|
284
|
+
exactly as it would untracked, and is never delayed by AgentCat. The trade:
|
|
285
|
+
telemetry still queued at the moment the process exits is dropped rather than
|
|
286
|
+
flushed. The SDK keeps exactly two bounded exit hooks, neither of which sends
|
|
287
|
+
events: one stops the publish worker before interpreter finalization (instant
|
|
288
|
+
when idle, ~1-second cap otherwise — on Linux with CPython ≤3.13 a daemon
|
|
289
|
+
thread still running during finalization can abort the process, CPython
|
|
290
|
+
gh-87135, and stopping first closes that path), and the internal-diagnostics
|
|
291
|
+
beacon below — skipped when there is nothing buffered, capped at ~2 seconds
|
|
292
|
+
when there is.
|
|
293
|
+
|
|
281
294
|
### Internal diagnostics
|
|
282
295
|
|
|
283
296
|
To help us catch and fix broken installs, the SDK sends AgentCat a small, anonymized
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "agentcat"
|
|
3
|
-
version = "2.0.
|
|
4
|
-
description = "Analytics tool for MCP (Model Context Protocol) servers and
|
|
3
|
+
version = "2.0.0b5"
|
|
4
|
+
description = "Analytics tool for MCP (Model Context Protocol) servers, Claude Connectors, and ChatGPT Plugins - tracks tool usage patterns and provides insights"
|
|
5
5
|
authors = [
|
|
6
6
|
{ name = "AgentCat, Inc.", email = "support@agentcat.com" },
|
|
7
7
|
]
|
|
@@ -9,7 +9,7 @@ readme = "README.md"
|
|
|
9
9
|
license = { text = "MIT" }
|
|
10
10
|
requires-python = ">=3.10"
|
|
11
11
|
classifiers = [
|
|
12
|
-
"Development Status ::
|
|
12
|
+
"Development Status :: 5 - Production/Stable",
|
|
13
13
|
"Intended Audience :: Developers",
|
|
14
14
|
"License :: OSI Approved :: MIT License",
|
|
15
15
|
"Programming Language :: Python :: 3",
|
|
@@ -3,10 +3,14 @@
|
|
|
3
3
|
import os
|
|
4
4
|
from collections.abc import Mapping
|
|
5
5
|
from datetime import datetime, timezone
|
|
6
|
-
from importlib.metadata import version
|
|
7
6
|
from typing import Any
|
|
8
7
|
|
|
9
|
-
|
|
8
|
+
from .utils import get_agentcat_version
|
|
9
|
+
|
|
10
|
+
# Guarded: on installs without distribution metadata (vendored source trees,
|
|
11
|
+
# PYTHONPATH, PyInstaller bundles) the lookup fails — that must degrade the
|
|
12
|
+
# version string, never crash the customer's import.
|
|
13
|
+
__version__ = get_agentcat_version() or "0.0.0"
|
|
10
14
|
|
|
11
15
|
from .modules.constants import AGENTCAT_CUSTOM_EVENT_TYPE
|
|
12
16
|
from .modules.detection import Detection, ServerFlavor, detect_server
|
|
@@ -85,7 +89,8 @@ def track(
|
|
|
85
89
|
if options is None:
|
|
86
90
|
options = AgentCatOptions()
|
|
87
91
|
|
|
88
|
-
|
|
92
|
+
if options.debug_mode is not None:
|
|
93
|
+
set_debug_mode(options.debug_mode)
|
|
89
94
|
|
|
90
95
|
# Initialize internal diagnostics before anything can fail, so even an
|
|
91
96
|
# invalid setup still emits a failure beacon. Never throws into the host.
|
|
@@ -256,22 +256,35 @@ class AgentCatMiddleware:
|
|
|
256
256
|
except TypeError:
|
|
257
257
|
return None
|
|
258
258
|
|
|
259
|
-
def _specs(self, tools: list[Any]) -> list[ToolSpec]:
|
|
259
|
+
def _specs(self, tools: list[Any]) -> list[ToolSpec | None]:
|
|
260
260
|
"""Copies of the listed schemas, ready for the in-place injection pass.
|
|
261
261
|
|
|
262
262
|
Only the schema dicts are copied. Deep-copying the ``Tool`` itself
|
|
263
263
|
raises on every tool holding live runtime state — an OpenAPI tool's
|
|
264
264
|
``httpx.AsyncClient`` carries a ``threading.RLock`` — which silently
|
|
265
|
-
dropped injection for whole servers in v1.
|
|
265
|
+
dropped injection for whole servers in v1. The same lesson applies
|
|
266
|
+
per tool: a schema dict whose copy fails yields ``None`` in the
|
|
267
|
+
aligned slot (that tool serves verbatim, un-injected) instead of
|
|
268
|
+
taking the whole listing down.
|
|
266
269
|
"""
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
270
|
+
specs: list[ToolSpec | None] = []
|
|
271
|
+
for tool in tools:
|
|
272
|
+
try:
|
|
273
|
+
specs.append(
|
|
274
|
+
ToolSpec(
|
|
275
|
+
tool.name,
|
|
276
|
+
copy.deepcopy(getattr(tool, "parameters", None) or {}),
|
|
277
|
+
copy.deepcopy(_field(tool, "output_schema", "outputSchema")),
|
|
278
|
+
)
|
|
279
|
+
)
|
|
280
|
+
except Exception as e:
|
|
281
|
+
write_to_log(
|
|
282
|
+
"Warning: could not copy the schema of tool "
|
|
283
|
+
f"'{getattr(tool, 'name', '<unnamed>')}' for injection; "
|
|
284
|
+
f"serving it verbatim without handle parameters - {e}"
|
|
285
|
+
)
|
|
286
|
+
specs.append(None)
|
|
287
|
+
return specs
|
|
275
288
|
|
|
276
289
|
# ── hooks ───────────────────────────────────────────────────────────────
|
|
277
290
|
|
|
@@ -313,7 +326,9 @@ class AgentCatMiddleware:
|
|
|
313
326
|
try:
|
|
314
327
|
specs = self._specs(tools)
|
|
315
328
|
injected = build_injected_schemas(
|
|
316
|
-
specs
|
|
329
|
+
[spec for spec in specs if spec is not None],
|
|
330
|
+
tracking.options,
|
|
331
|
+
tracking.reported_conflicts,
|
|
317
332
|
)
|
|
318
333
|
tracking.injected_params_registry = injected.injected_params
|
|
319
334
|
tracking.output_injection_registry = injected.output_injected
|
|
@@ -322,7 +337,9 @@ class AgentCatMiddleware:
|
|
|
322
337
|
# one did not see.
|
|
323
338
|
tracking.declared_session_params |= injected.declared_session_params
|
|
324
339
|
return [
|
|
325
|
-
tool
|
|
340
|
+
tool
|
|
341
|
+
if spec is None # uncopyable schema: served verbatim
|
|
342
|
+
else tool.model_copy(update=self._schema_update(spec))
|
|
326
343
|
for tool, spec in zip(tools, specs, strict=True)
|
|
327
344
|
]
|
|
328
345
|
except Exception as e:
|
|
@@ -456,9 +473,10 @@ class AgentCatMiddleware:
|
|
|
456
473
|
case install_community registers eagerly for.
|
|
457
474
|
"""
|
|
458
475
|
listed = list(await self._server.list_tools(run_middleware=False))
|
|
459
|
-
|
|
476
|
+
specs = self._specs(
|
|
460
477
|
await self._concede_get_more_tools(listed, authoritative=True)
|
|
461
478
|
)
|
|
479
|
+
return [spec for spec in specs if spec is not None]
|
|
462
480
|
|
|
463
481
|
stripped = await get_stripped_arguments(
|
|
464
482
|
tracking, options, name, raw_arguments, rebuild
|
|
@@ -165,7 +165,6 @@ def install_lowlevel_v1(server: Any, data: AgentCatData, facade: Any = None) ->
|
|
|
165
165
|
from mcp.types import (
|
|
166
166
|
CallToolRequest,
|
|
167
167
|
ListToolsRequest,
|
|
168
|
-
ListToolsResult,
|
|
169
168
|
ServerResult,
|
|
170
169
|
TextContent,
|
|
171
170
|
Tool,
|
|
@@ -236,17 +235,33 @@ def install_lowlevel_v1(server: Any, data: AgentCatData, facade: Any = None) ->
|
|
|
236
235
|
annotations=annotations,
|
|
237
236
|
)
|
|
238
237
|
|
|
239
|
-
def advertised_tools(
|
|
238
|
+
def advertised_tools(
|
|
239
|
+
original: Any, options: Any
|
|
240
|
+
) -> tuple[list[Any], set[int]]:
|
|
240
241
|
"""Deep copies of the listed tools, plus get_more_tools when enabled.
|
|
241
242
|
|
|
242
243
|
Copies because the injection pipeline rewrites schemas in place and
|
|
243
|
-
FastMCP hands out the very dict its tool manager holds.
|
|
244
|
+
FastMCP hands out the very dict its tool manager holds. A tool whose
|
|
245
|
+
copy fails is carried through VERBATIM (the customer's object, never
|
|
246
|
+
given to the pipeline) with its id() in the returned skip set — one
|
|
247
|
+
uncopyable tool must not take down the whole listing.
|
|
244
248
|
"""
|
|
245
249
|
nonlocal agentcat_advertises_get_more_tools
|
|
246
250
|
tools: list[Any] = []
|
|
251
|
+
skipped: set[int] = set()
|
|
247
252
|
listed = getattr(getattr(original, "root", None), "tools", None)
|
|
248
253
|
if isinstance(listed, list):
|
|
249
|
-
|
|
254
|
+
for tool in listed:
|
|
255
|
+
try:
|
|
256
|
+
tools.append(tool.model_copy(deep=True))
|
|
257
|
+
except Exception as e:
|
|
258
|
+
write_to_log(
|
|
259
|
+
"Warning: could not copy tool "
|
|
260
|
+
f"'{getattr(tool, 'name', '<unnamed>')}' for injection; "
|
|
261
|
+
f"serving it verbatim without handle parameters - {e}"
|
|
262
|
+
)
|
|
263
|
+
tools.append(tool)
|
|
264
|
+
skipped.add(id(tool))
|
|
250
265
|
customer_owns_get_more_tools = any(
|
|
251
266
|
getattr(tool, "name", None) == GET_MORE_TOOLS_NAME for tool in tools
|
|
252
267
|
)
|
|
@@ -257,11 +272,16 @@ def install_lowlevel_v1(server: Any, data: AgentCatData, facade: Any = None) ->
|
|
|
257
272
|
# context pass skips it by name, so early placement cannot double-inject.
|
|
258
273
|
if agentcat_advertises_get_more_tools:
|
|
259
274
|
tools.append(make_get_more_tools())
|
|
260
|
-
return tools
|
|
275
|
+
return tools, skipped
|
|
261
276
|
|
|
262
|
-
def specs_for(tools: list[Any]) -> list[ToolSpec]:
|
|
277
|
+
def specs_for(tools: list[Any], skipped: set[int]) -> list[ToolSpec | None]:
|
|
278
|
+
"""Specs aligned index-for-index with `tools`; None for skipped ones."""
|
|
263
279
|
return [
|
|
264
|
-
|
|
280
|
+
None
|
|
281
|
+
if id(tool) in skipped
|
|
282
|
+
else ToolSpec(
|
|
283
|
+
tool.name, tool.inputSchema, getattr(tool, "outputSchema", None)
|
|
284
|
+
)
|
|
265
285
|
for tool in tools
|
|
266
286
|
]
|
|
267
287
|
|
|
@@ -271,16 +291,19 @@ def install_lowlevel_v1(server: Any, data: AgentCatData, facade: Any = None) ->
|
|
|
271
291
|
if list_handler is None:
|
|
272
292
|
return []
|
|
273
293
|
listed = await list_handler(ListToolsRequest(method="tools/list"))
|
|
274
|
-
|
|
294
|
+
tools, skipped = advertised_tools(listed, current_data().options)
|
|
295
|
+
return [spec for spec in specs_for(tools, skipped) if spec is not None]
|
|
275
296
|
|
|
276
297
|
async def wrapped_list(request: Any) -> Any:
|
|
277
298
|
listed = await original(_LIST)(request)
|
|
278
299
|
tracking = current_data()
|
|
279
300
|
try:
|
|
280
|
-
tools = advertised_tools(listed, tracking.options)
|
|
281
|
-
specs = specs_for(tools)
|
|
301
|
+
tools, skipped = advertised_tools(listed, tracking.options)
|
|
302
|
+
specs = specs_for(tools, skipped)
|
|
282
303
|
injected = build_injected_schemas(
|
|
283
|
-
specs
|
|
304
|
+
[spec for spec in specs if spec is not None],
|
|
305
|
+
tracking.options,
|
|
306
|
+
tracking.reported_conflicts,
|
|
284
307
|
)
|
|
285
308
|
tracking.injected_params_registry = injected.injected_params
|
|
286
309
|
tracking.output_injection_registry = injected.output_injected
|
|
@@ -289,17 +312,15 @@ def install_lowlevel_v1(server: Any, data: AgentCatData, facade: Any = None) ->
|
|
|
289
312
|
# one did not see.
|
|
290
313
|
tracking.declared_session_params |= injected.declared_session_params
|
|
291
314
|
for tool, spec in zip(tools, specs, strict=True):
|
|
315
|
+
if spec is None:
|
|
316
|
+
continue # uncopyable tool: served verbatim, never mutated
|
|
292
317
|
tool.inputSchema = spec.input_schema
|
|
293
318
|
if spec.output_schema is not None:
|
|
294
319
|
tool.outputSchema = spec.output_schema
|
|
295
|
-
#
|
|
296
|
-
# any
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
tools=tools,
|
|
300
|
-
nextCursor=getattr(listed.root, "nextCursor", None),
|
|
301
|
-
)
|
|
302
|
-
)
|
|
320
|
+
# A copy of the customer's result rather than a rebuilt one: _meta
|
|
321
|
+
# and any extra fields their handler set survive (Result is
|
|
322
|
+
# extra='allow' on 1.x), exactly like the v2 adapter.
|
|
323
|
+
return ServerResult(listed.root.model_copy(update={"tools": tools}))
|
|
303
324
|
except Exception as e:
|
|
304
325
|
write_to_log(
|
|
305
326
|
"Warning: tools/list injection failed, serving the customer's "
|
|
@@ -225,18 +225,37 @@ def install_lowlevel_v2(server: Any, data: AgentCatData, facade: Any = None) ->
|
|
|
225
225
|
"""
|
|
226
226
|
return state.get(f"orig_{method}")
|
|
227
227
|
|
|
228
|
-
def advertised_tools(
|
|
228
|
+
def advertised_tools(
|
|
229
|
+
result: Any, options: Any
|
|
230
|
+
) -> tuple[list[Any], set[int]] | None:
|
|
229
231
|
"""Deep copies of the listed tools, plus get_more_tools when enabled.
|
|
230
232
|
|
|
231
233
|
None when the handler returned something with no tool list to inject
|
|
232
234
|
into (a raw dict, an error shape), which the caller serves untouched.
|
|
233
|
-
Copies because the injection pipeline rewrites schemas in place.
|
|
235
|
+
Copies because the injection pipeline rewrites schemas in place. A
|
|
236
|
+
tool whose copy fails is carried through VERBATIM — the customer's
|
|
237
|
+
original object, never handed to the pipeline so it is never mutated
|
|
238
|
+
— and its id() lands in the returned skip set so the callers exclude
|
|
239
|
+
it from injection; one uncopyable tool must not take down the whole
|
|
240
|
+
listing (or, on the rebuild path, brand the call's arguments).
|
|
234
241
|
"""
|
|
235
242
|
nonlocal agentcat_advertises_get_more_tools
|
|
236
243
|
listed = getattr(result, "tools", None)
|
|
237
244
|
if not isinstance(listed, list):
|
|
238
245
|
return None
|
|
239
|
-
tools = [
|
|
246
|
+
tools: list[Any] = []
|
|
247
|
+
skipped: set[int] = set()
|
|
248
|
+
for tool in listed:
|
|
249
|
+
try:
|
|
250
|
+
tools.append(tool.model_copy(deep=True))
|
|
251
|
+
except Exception as e:
|
|
252
|
+
write_to_log(
|
|
253
|
+
"Warning: could not copy tool "
|
|
254
|
+
f"'{getattr(tool, 'name', '<unnamed>')}' for injection; "
|
|
255
|
+
f"serving it verbatim without handle parameters - {e}"
|
|
256
|
+
)
|
|
257
|
+
tools.append(tool)
|
|
258
|
+
skipped.add(id(tool))
|
|
240
259
|
customer_owns_get_more_tools = any(
|
|
241
260
|
getattr(tool, "name", None) == GET_MORE_TOOLS_NAME for tool in tools
|
|
242
261
|
)
|
|
@@ -247,11 +266,16 @@ def install_lowlevel_v2(server: Any, data: AgentCatData, facade: Any = None) ->
|
|
|
247
266
|
# context pass skips it by name, so early placement cannot double-inject.
|
|
248
267
|
if agentcat_advertises_get_more_tools:
|
|
249
268
|
tools.append(_make_get_more_tools())
|
|
250
|
-
return tools
|
|
269
|
+
return tools, skipped
|
|
251
270
|
|
|
252
|
-
def specs_for(tools: list[Any]) -> list[ToolSpec]:
|
|
271
|
+
def specs_for(tools: list[Any], skipped: set[int]) -> list[ToolSpec | None]:
|
|
272
|
+
"""Specs aligned index-for-index with `tools`; None for skipped ones."""
|
|
253
273
|
return [
|
|
254
|
-
|
|
274
|
+
None
|
|
275
|
+
if id(tool) in skipped
|
|
276
|
+
else ToolSpec(
|
|
277
|
+
tool.name, tool.input_schema, getattr(tool, "output_schema", None)
|
|
278
|
+
)
|
|
255
279
|
for tool in tools
|
|
256
280
|
]
|
|
257
281
|
|
|
@@ -261,11 +285,21 @@ def install_lowlevel_v2(server: Any, data: AgentCatData, facade: Any = None) ->
|
|
|
261
285
|
The registered params type is all-optional (``PaginatedRequestParams``),
|
|
262
286
|
which is what the runner would hand a handler for a request that
|
|
263
287
|
carried none — so a customer handler reading ``params.cursor`` sees the
|
|
264
|
-
same thing it always does.
|
|
288
|
+
same thing it always does. A bare-callable registration carries no
|
|
289
|
+
params_type; the real model is the fallback then, NOT None — a
|
|
290
|
+
customer list handler that dereferences its params must not crash the
|
|
291
|
+
rebuild (and with it, the call's argument strip).
|
|
265
292
|
"""
|
|
266
293
|
params_type = getattr(_entry(server, LIST_METHOD), "params_type", None)
|
|
294
|
+
if params_type is None:
|
|
295
|
+
try:
|
|
296
|
+
from mcp.types import PaginatedRequestParams
|
|
297
|
+
|
|
298
|
+
return PaginatedRequestParams()
|
|
299
|
+
except Exception:
|
|
300
|
+
return None
|
|
267
301
|
try:
|
|
268
|
-
return params_type()
|
|
302
|
+
return params_type()
|
|
269
303
|
except Exception:
|
|
270
304
|
return None
|
|
271
305
|
|
|
@@ -273,12 +307,15 @@ def install_lowlevel_v2(server: Any, data: AgentCatData, facade: Any = None) ->
|
|
|
273
307
|
result = await original(LIST_METHOD)(ctx, params)
|
|
274
308
|
tracking = current_data()
|
|
275
309
|
try:
|
|
276
|
-
|
|
277
|
-
if
|
|
310
|
+
advertised = advertised_tools(result, tracking.options)
|
|
311
|
+
if advertised is None:
|
|
278
312
|
return result
|
|
279
|
-
|
|
313
|
+
tools, skipped = advertised
|
|
314
|
+
specs = specs_for(tools, skipped)
|
|
280
315
|
injected = build_injected_schemas(
|
|
281
|
-
specs
|
|
316
|
+
[spec for spec in specs if spec is not None],
|
|
317
|
+
tracking.options,
|
|
318
|
+
tracking.reported_conflicts,
|
|
282
319
|
)
|
|
283
320
|
tracking.injected_params_registry = injected.injected_params
|
|
284
321
|
tracking.output_injection_registry = injected.output_injected
|
|
@@ -287,6 +324,8 @@ def install_lowlevel_v2(server: Any, data: AgentCatData, facade: Any = None) ->
|
|
|
287
324
|
# one did not see.
|
|
288
325
|
tracking.declared_session_params |= injected.declared_session_params
|
|
289
326
|
for tool, spec in zip(tools, specs, strict=True):
|
|
327
|
+
if spec is None:
|
|
328
|
+
continue # uncopyable tool: served verbatim, never mutated
|
|
290
329
|
tool.input_schema = spec.input_schema
|
|
291
330
|
if spec.output_schema is not None:
|
|
292
331
|
tool.output_schema = spec.output_schema
|
|
@@ -317,8 +356,11 @@ def install_lowlevel_v2(server: Any, data: AgentCatData, facade: Any = None) ->
|
|
|
317
356
|
if list_handler is None:
|
|
318
357
|
return []
|
|
319
358
|
listed = await list_handler(ctx, empty_list_params())
|
|
320
|
-
|
|
321
|
-
|
|
359
|
+
advertised = advertised_tools(listed, current_data().options)
|
|
360
|
+
if advertised is None:
|
|
361
|
+
return []
|
|
362
|
+
tools, skipped = advertised
|
|
363
|
+
return [spec for spec in specs_for(tools, skipped) if spec is not None]
|
|
322
364
|
|
|
323
365
|
# Runs first: on an instance that never served a listing this rebuilds
|
|
324
366
|
# the registries, which is also what settles whether the customer ships
|
|
@@ -119,10 +119,12 @@ async def resolve_call(
|
|
|
119
119
|
data.project_id,
|
|
120
120
|
request,
|
|
121
121
|
extra,
|
|
122
|
-
injected_parameter_names(
|
|
122
|
+
injected_parameter_names(
|
|
123
|
+
tool_name, data.injected_params_registry, raw_arguments, data.options
|
|
124
|
+
),
|
|
123
125
|
tool_name not in data.declared_session_params,
|
|
124
126
|
)
|
|
125
|
-
actor = resolve_identity(data, request, extra)
|
|
127
|
+
actor = await resolve_identity(data, request, extra)
|
|
126
128
|
client = resolve_client_identity(meta_sources, legacy_client)
|
|
127
129
|
protocol_version = resolve_protocol_version(meta_sources, protocol_fallback)
|
|
128
130
|
# Read from the RAW arguments (pre-strip): the event records what the agent
|
|
@@ -152,9 +154,12 @@ async def get_stripped_arguments(
|
|
|
152
154
|
`tools/list` rebuilds the registries on demand from the adapter's list
|
|
153
155
|
source (§6.3); the injection pipeline is deterministic, so a rebuilt
|
|
154
156
|
registry matches what any listing instance advertised. Only a failed
|
|
155
|
-
rebuild falls back to the
|
|
156
|
-
|
|
157
|
-
|
|
157
|
+
rebuild falls back to the shape+config-aware strip (see
|
|
158
|
+
`injected_parameter_names`): a name is removed only when the enabled
|
|
159
|
+
options would have injected it AND, for `session_id`, the value matches
|
|
160
|
+
our minted shape — a customer-declared parameter rides through to their
|
|
161
|
+
handler. The fallback also clears the output-injection registry, so the
|
|
162
|
+
structured mirror stops gating on knowledge we no longer have (§3.4b).
|
|
158
163
|
"""
|
|
159
164
|
registry = data.injected_params_registry
|
|
160
165
|
if registry is None and rebuild is not None:
|
|
@@ -182,7 +187,7 @@ async def get_stripped_arguments(
|
|
|
182
187
|
"Rebuilt injection registries on demand "
|
|
183
188
|
"(tools/call before tools/list on this instance)"
|
|
184
189
|
)
|
|
185
|
-
return strip_injected_arguments(tool_name, raw_arguments, registry)
|
|
190
|
+
return strip_injected_arguments(tool_name, raw_arguments, registry, options)
|
|
186
191
|
|
|
187
192
|
|
|
188
193
|
def detect_mrtr(
|
|
@@ -167,6 +167,10 @@ def _build_static_attributes(project_id: str | None) -> list[dict[str, Any]]:
|
|
|
167
167
|
out += _attr("agentcat.mcp_sdk.version", version("mcp"))
|
|
168
168
|
except Exception:
|
|
169
169
|
pass
|
|
170
|
+
try:
|
|
171
|
+
out += _attr("agentcat.fastmcp_sdk.version", version("fastmcp"))
|
|
172
|
+
except Exception:
|
|
173
|
+
pass
|
|
170
174
|
|
|
171
175
|
# Runtime
|
|
172
176
|
out += _attr("process.runtime.name", platform.python_implementation().lower())
|
|
@@ -230,7 +234,7 @@ def capture(entry: str) -> None:
|
|
|
230
234
|
pass
|
|
231
235
|
|
|
232
236
|
|
|
233
|
-
def flush_diagnostics() -> None:
|
|
237
|
+
def flush_diagnostics(timeout: float = 5.0) -> None:
|
|
234
238
|
"""Swap out the buffer and POST it fire-and-forget. Never raises."""
|
|
235
239
|
try:
|
|
236
240
|
if not _enabled:
|
|
@@ -263,7 +267,9 @@ def flush_diagnostics() -> None:
|
|
|
263
267
|
if token:
|
|
264
268
|
headers["Authorization"] = f"Bearer {token}"
|
|
265
269
|
|
|
266
|
-
requests.post(
|
|
270
|
+
requests.post(
|
|
271
|
+
_resolve_endpoint(), json=payload, headers=headers, timeout=timeout
|
|
272
|
+
)
|
|
267
273
|
except Exception:
|
|
268
274
|
# fire-and-forget: never propagate diagnostics network errors
|
|
269
275
|
pass
|
|
@@ -325,5 +331,20 @@ def _build_record_for_test(entry: str) -> dict[str, Any]:
|
|
|
325
331
|
return _build_record(entry)
|
|
326
332
|
|
|
327
333
|
|
|
334
|
+
def _flush_at_exit() -> None:
|
|
335
|
+
"""Exit-time flush, hard-bounded so the customer's shutdown is never held
|
|
336
|
+
up: skip without even taking the lock when there is nothing buffered, and
|
|
337
|
+
cap the POST at 2s (requests applies the timeout per phase — connect,
|
|
338
|
+
then between bytes — so this approximates, not guarantees, 2s wall clock).
|
|
339
|
+
This is the only atexit hook the SDK registers.
|
|
340
|
+
"""
|
|
341
|
+
try:
|
|
342
|
+
if not _enabled or not _buffer:
|
|
343
|
+
return
|
|
344
|
+
flush_diagnostics(timeout=2.0)
|
|
345
|
+
except Exception:
|
|
346
|
+
pass
|
|
347
|
+
|
|
348
|
+
|
|
328
349
|
# Flush whatever is buffered on interpreter exit (covers non-destroy() paths).
|
|
329
|
-
atexit.register(
|
|
350
|
+
atexit.register(_flush_at_exit)
|