agentcat 2.1.0__tar.gz → 2.2.0__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.
Files changed (156) hide show
  1. {agentcat-2.1.0 → agentcat-2.2.0}/CONTRIBUTING.md +53 -3
  2. {agentcat-2.1.0 → agentcat-2.2.0}/PKG-INFO +3 -3
  3. {agentcat-2.1.0 → agentcat-2.2.0}/README.md +1 -1
  4. {agentcat-2.1.0 → agentcat-2.2.0}/pyproject.toml +2 -2
  5. {agentcat-2.1.0 → agentcat-2.2.0}/src/agentcat/modules/adapters/community.py +107 -2
  6. {agentcat-2.1.0 → agentcat-2.2.0}/src/agentcat/modules/adapters/lowlevel_v1.py +157 -15
  7. {agentcat-2.1.0 → agentcat-2.2.0}/src/agentcat/modules/adapters/lowlevel_v2.py +185 -14
  8. {agentcat-2.1.0 → agentcat-2.2.0}/src/agentcat/modules/callpath.py +6 -0
  9. {agentcat-2.1.0 → agentcat-2.2.0}/src/agentcat/modules/event_queue.py +87 -8
  10. {agentcat-2.1.0 → agentcat-2.2.0}/src/agentcat/modules/redaction.py +63 -0
  11. agentcat-2.2.0/src/agentcat/modules/server_info.py +379 -0
  12. agentcat-2.2.0/src/agentcat/modules/token_estimate.py +112 -0
  13. {agentcat-2.1.0 → agentcat-2.2.0}/src/agentcat/modules/validation.py +1 -1
  14. {agentcat-2.1.0 → agentcat-2.2.0}/tests/conftest.py +37 -0
  15. agentcat-2.2.0/tests/test_release.py +428 -0
  16. agentcat-2.2.0/tests/test_server_info.py +1838 -0
  17. {agentcat-2.1.0 → agentcat-2.2.0}/tests/test_tag_validation.py +6 -0
  18. agentcat-2.2.0/tests/test_token_estimate.py +129 -0
  19. agentcat-2.2.0/tests/test_token_estimates_integration.py +234 -0
  20. {agentcat-2.1.0 → agentcat-2.2.0}/.gitignore +0 -0
  21. {agentcat-2.1.0 → agentcat-2.2.0}/LICENSE +0 -0
  22. {agentcat-2.1.0 → agentcat-2.2.0}/docs/cats/bibi.png +0 -0
  23. {agentcat-2.1.0 → agentcat-2.2.0}/docs/cats/void.jpg +0 -0
  24. {agentcat-2.1.0 → agentcat-2.2.0}/docs/cats/zelda.jpg +0 -0
  25. {agentcat-2.1.0 → agentcat-2.2.0}/docs/static/architecture.png +0 -0
  26. {agentcat-2.1.0 → agentcat-2.2.0}/docs/static/og-image.png +0 -0
  27. {agentcat-2.1.0 → agentcat-2.2.0}/src/agentcat/__init__.py +0 -0
  28. {agentcat-2.1.0 → agentcat-2.2.0}/src/agentcat/modules/__init__.py +0 -0
  29. {agentcat-2.1.0 → agentcat-2.2.0}/src/agentcat/modules/adapters/__init__.py +0 -0
  30. {agentcat-2.1.0 → agentcat-2.2.0}/src/agentcat/modules/adapters/_common.py +0 -0
  31. {agentcat-2.1.0 → agentcat-2.2.0}/src/agentcat/modules/adapters/_inner_tap.py +0 -0
  32. {agentcat-2.1.0 → agentcat-2.2.0}/src/agentcat/modules/client_identity.py +0 -0
  33. {agentcat-2.1.0 → agentcat-2.2.0}/src/agentcat/modules/constants.py +0 -0
  34. {agentcat-2.1.0 → agentcat-2.2.0}/src/agentcat/modules/detection.py +0 -0
  35. {agentcat-2.1.0 → agentcat-2.2.0}/src/agentcat/modules/diagnostics.py +0 -0
  36. {agentcat-2.1.0 → agentcat-2.2.0}/src/agentcat/modules/exceptions.py +0 -0
  37. {agentcat-2.1.0 → agentcat-2.2.0}/src/agentcat/modules/exporters/__init__.py +0 -0
  38. {agentcat-2.1.0 → agentcat-2.2.0}/src/agentcat/modules/exporters/datadog.py +0 -0
  39. {agentcat-2.1.0 → agentcat-2.2.0}/src/agentcat/modules/exporters/otlp.py +0 -0
  40. {agentcat-2.1.0 → agentcat-2.2.0}/src/agentcat/modules/exporters/sentry.py +0 -0
  41. {agentcat-2.1.0 → agentcat-2.2.0}/src/agentcat/modules/exporters/trace_context.py +0 -0
  42. {agentcat-2.1.0 → agentcat-2.2.0}/src/agentcat/modules/handles.py +0 -0
  43. {agentcat-2.1.0 → agentcat-2.2.0}/src/agentcat/modules/hooks.py +0 -0
  44. {agentcat-2.1.0 → agentcat-2.2.0}/src/agentcat/modules/identify.py +0 -0
  45. {agentcat-2.1.0 → agentcat-2.2.0}/src/agentcat/modules/injection.py +0 -0
  46. {agentcat-2.1.0 → agentcat-2.2.0}/src/agentcat/modules/internal.py +0 -0
  47. {agentcat-2.1.0 → agentcat-2.2.0}/src/agentcat/modules/logging.py +0 -0
  48. {agentcat-2.1.0 → agentcat-2.2.0}/src/agentcat/modules/request_extra.py +0 -0
  49. {agentcat-2.1.0 → agentcat-2.2.0}/src/agentcat/modules/sanitization.py +0 -0
  50. {agentcat-2.1.0 → agentcat-2.2.0}/src/agentcat/modules/telemetry.py +0 -0
  51. {agentcat-2.1.0 → agentcat-2.2.0}/src/agentcat/modules/tools.py +0 -0
  52. {agentcat-2.1.0 → agentcat-2.2.0}/src/agentcat/modules/truncation.py +0 -0
  53. {agentcat-2.1.0 → agentcat-2.2.0}/src/agentcat/thirdparty/__init__.py +0 -0
  54. {agentcat-2.1.0 → agentcat-2.2.0}/src/agentcat/thirdparty/ksuid/__init__.py +0 -0
  55. {agentcat-2.1.0 → agentcat-2.2.0}/src/agentcat/thirdparty/ksuid/baseconv.py +0 -0
  56. {agentcat-2.1.0 → agentcat-2.2.0}/src/agentcat/thirdparty/ksuid/ksuid.py +0 -0
  57. {agentcat-2.1.0 → agentcat-2.2.0}/src/agentcat/types.py +0 -0
  58. {agentcat-2.1.0 → agentcat-2.2.0}/src/agentcat/utils.py +0 -0
  59. {agentcat-2.1.0 → agentcat-2.2.0}/tests/__init__.py +0 -0
  60. {agentcat-2.1.0 → agentcat-2.2.0}/tests/community/__init__.py +0 -0
  61. {agentcat-2.1.0 → agentcat-2.2.0}/tests/community/test_community_v3_event_serialization.py +0 -0
  62. {agentcat-2.1.0 → agentcat-2.2.0}/tests/community/test_community_v3_handles.py +0 -0
  63. {agentcat-2.1.0 → agentcat-2.2.0}/tests/community/test_community_v3_inject_context.py +0 -0
  64. {agentcat-2.1.0 → agentcat-2.2.0}/tests/community/test_community_v3_nested_calls.py +0 -0
  65. {agentcat-2.1.0 → agentcat-2.2.0}/tests/community/test_community_v3_openapi.py +0 -0
  66. {agentcat-2.1.0 → agentcat-2.2.0}/tests/community/test_community_v3_runtime_state_tools.py +0 -0
  67. {agentcat-2.1.0 → agentcat-2.2.0}/tests/e2e/__init__.py +0 -0
  68. {agentcat-2.1.0 → agentcat-2.2.0}/tests/e2e/_helpers.py +0 -0
  69. {agentcat-2.1.0 → agentcat-2.2.0}/tests/e2e/community_v3/__init__.py +0 -0
  70. {agentcat-2.1.0 → agentcat-2.2.0}/tests/e2e/community_v3/conftest.py +0 -0
  71. {agentcat-2.1.0 → agentcat-2.2.0}/tests/e2e/community_v3/test_agent_handle_http.py +0 -0
  72. {agentcat-2.1.0 → agentcat-2.2.0}/tests/e2e/community_v3/test_event_capture_http.py +0 -0
  73. {agentcat-2.1.0 → agentcat-2.2.0}/tests/e2e/community_v3/test_identify_http.py +0 -0
  74. {agentcat-2.1.0 → agentcat-2.2.0}/tests/e2e/community_v3/test_request_extra_http.py +0 -0
  75. {agentcat-2.1.0 → agentcat-2.2.0}/tests/e2e/community_v3/test_stateless_http.py +0 -0
  76. {agentcat-2.1.0 → agentcat-2.2.0}/tests/e2e/community_v4/__init__.py +0 -0
  77. {agentcat-2.1.0 → agentcat-2.2.0}/tests/e2e/community_v4/conftest.py +0 -0
  78. {agentcat-2.1.0 → agentcat-2.2.0}/tests/e2e/community_v4/test_agent_handle_http.py +0 -0
  79. {agentcat-2.1.0 → agentcat-2.2.0}/tests/e2e/community_v4/test_identify_http.py +0 -0
  80. {agentcat-2.1.0 → agentcat-2.2.0}/tests/e2e/community_v4/test_session_http.py +0 -0
  81. {agentcat-2.1.0 → agentcat-2.2.0}/tests/e2e/community_v4/test_stateless_http.py +0 -0
  82. {agentcat-2.1.0 → agentcat-2.2.0}/tests/e2e/conftest.py +0 -0
  83. {agentcat-2.1.0 → agentcat-2.2.0}/tests/e2e/official/__init__.py +0 -0
  84. {agentcat-2.1.0 → agentcat-2.2.0}/tests/e2e/official/conftest.py +0 -0
  85. {agentcat-2.1.0 → agentcat-2.2.0}/tests/e2e/official/test_agent_handle_http.py +0 -0
  86. {agentcat-2.1.0 → agentcat-2.2.0}/tests/e2e/official/test_event_capture_http.py +0 -0
  87. {agentcat-2.1.0 → agentcat-2.2.0}/tests/e2e/official/test_identify_http.py +0 -0
  88. {agentcat-2.1.0 → agentcat-2.2.0}/tests/e2e/official/test_redaction_http.py +0 -0
  89. {agentcat-2.1.0 → agentcat-2.2.0}/tests/e2e/official/test_request_extra_http.py +0 -0
  90. {agentcat-2.1.0 → agentcat-2.2.0}/tests/e2e/official/test_session_http.py +0 -0
  91. {agentcat-2.1.0 → agentcat-2.2.0}/tests/e2e/official/test_stateless_http.py +0 -0
  92. {agentcat-2.1.0 → agentcat-2.2.0}/tests/e2e/official_modern/__init__.py +0 -0
  93. {agentcat-2.1.0 → agentcat-2.2.0}/tests/e2e/official_modern/conftest.py +0 -0
  94. {agentcat-2.1.0 → agentcat-2.2.0}/tests/e2e/official_modern/test_agent_handle_http.py +0 -0
  95. {agentcat-2.1.0 → agentcat-2.2.0}/tests/e2e/official_modern/test_identify_http.py +0 -0
  96. {agentcat-2.1.0 → agentcat-2.2.0}/tests/e2e/official_modern/test_mcpserver_http.py +0 -0
  97. {agentcat-2.1.0 → agentcat-2.2.0}/tests/e2e/official_modern/test_session_http.py +0 -0
  98. {agentcat-2.1.0 → agentcat-2.2.0}/tests/e2e/official_modern/test_stateless_http.py +0 -0
  99. {agentcat-2.1.0 → agentcat-2.2.0}/tests/test_api_base_url.py +0 -0
  100. {agentcat-2.1.0 → agentcat-2.2.0}/tests/test_async_hooks.py +0 -0
  101. {agentcat-2.1.0 → agentcat-2.2.0}/tests/test_callpath.py +0 -0
  102. {agentcat-2.1.0 → agentcat-2.2.0}/tests/test_client_identity.py +0 -0
  103. {agentcat-2.1.0 → agentcat-2.2.0}/tests/test_community_v4_handles.py +0 -0
  104. {agentcat-2.1.0 → agentcat-2.2.0}/tests/test_community_v4_nested_calls.py +0 -0
  105. {agentcat-2.1.0 → agentcat-2.2.0}/tests/test_concurrency_handles.py +0 -0
  106. {agentcat-2.1.0 → agentcat-2.2.0}/tests/test_constants_copy.py +0 -0
  107. {agentcat-2.1.0 → agentcat-2.2.0}/tests/test_customer_owned_parameters.py +0 -0
  108. {agentcat-2.1.0 → agentcat-2.2.0}/tests/test_detection.py +0 -0
  109. {agentcat-2.1.0 → agentcat-2.2.0}/tests/test_diagnostics_attributes.py +0 -0
  110. {agentcat-2.1.0 → agentcat-2.2.0}/tests/test_diagnostics_auth.py +0 -0
  111. {agentcat-2.1.0 → agentcat-2.2.0}/tests/test_diagnostics_export.py +0 -0
  112. {agentcat-2.1.0 → agentcat-2.2.0}/tests/test_diagnostics_integration.py +0 -0
  113. {agentcat-2.1.0 → agentcat-2.2.0}/tests/test_diagnostics_no_payload.py +0 -0
  114. {agentcat-2.1.0 → agentcat-2.2.0}/tests/test_diagnostics_optout.py +0 -0
  115. {agentcat-2.1.0 → agentcat-2.2.0}/tests/test_diagnostics_record.py +0 -0
  116. {agentcat-2.1.0 → agentcat-2.2.0}/tests/test_diagnostics_sink.py +0 -0
  117. {agentcat-2.1.0 → agentcat-2.2.0}/tests/test_diagnostics_test_env.py +0 -0
  118. {agentcat-2.1.0 → agentcat-2.2.0}/tests/test_dynamic_tracking.py +0 -0
  119. {agentcat-2.1.0 → agentcat-2.2.0}/tests/test_event_capture_completeness.py +0 -0
  120. {agentcat-2.1.0 → agentcat-2.2.0}/tests/test_event_queue.py +0 -0
  121. {agentcat-2.1.0 → agentcat-2.2.0}/tests/test_event_tags_properties.py +0 -0
  122. {agentcat-2.1.0 → agentcat-2.2.0}/tests/test_exceptions.py +0 -0
  123. {agentcat-2.1.0 → agentcat-2.2.0}/tests/test_exporter_sdk_version.py +0 -0
  124. {agentcat-2.1.0 → agentcat-2.2.0}/tests/test_handles.py +0 -0
  125. {agentcat-2.1.0 → agentcat-2.2.0}/tests/test_hook_offload.py +0 -0
  126. {agentcat-2.1.0 → agentcat-2.2.0}/tests/test_identify_shape.py +0 -0
  127. {agentcat-2.1.0 → agentcat-2.2.0}/tests/test_injection.py +0 -0
  128. {agentcat-2.1.0 → agentcat-2.2.0}/tests/test_inner_tap.py +0 -0
  129. {agentcat-2.1.0 → agentcat-2.2.0}/tests/test_logging.py +0 -0
  130. {agentcat-2.1.0 → agentcat-2.2.0}/tests/test_lowlevel_v1_handles.py +0 -0
  131. {agentcat-2.1.0 → agentcat-2.2.0}/tests/test_lowlevel_v2_handles.py +0 -0
  132. {agentcat-2.1.0 → agentcat-2.2.0}/tests/test_multiple_servers.py +0 -0
  133. {agentcat-2.1.0 → agentcat-2.2.0}/tests/test_options_v2.py +0 -0
  134. {agentcat-2.1.0 → agentcat-2.2.0}/tests/test_process_safety.py +0 -0
  135. {agentcat-2.1.0 → agentcat-2.2.0}/tests/test_publish_custom_event.py +0 -0
  136. {agentcat-2.1.0 → agentcat-2.2.0}/tests/test_rebuild_on_demand.py +0 -0
  137. {agentcat-2.1.0 → agentcat-2.2.0}/tests/test_redaction.py +0 -0
  138. {agentcat-2.1.0 → agentcat-2.2.0}/tests/test_removed_events.py +0 -0
  139. {agentcat-2.1.0 → agentcat-2.2.0}/tests/test_report_missing.py +0 -0
  140. {agentcat-2.1.0 → agentcat-2.2.0}/tests/test_request_extra.py +0 -0
  141. {agentcat-2.1.0 → agentcat-2.2.0}/tests/test_response_shape.py +0 -0
  142. {agentcat-2.1.0 → agentcat-2.2.0}/tests/test_sanitization.py +0 -0
  143. {agentcat-2.1.0 → agentcat-2.2.0}/tests/test_session_id_validation.py +0 -0
  144. {agentcat-2.1.0 → agentcat-2.2.0}/tests/test_tool_context.py +0 -0
  145. {agentcat-2.1.0 → agentcat-2.2.0}/tests/test_truncation.py +0 -0
  146. {agentcat-2.1.0 → agentcat-2.2.0}/tests/test_truncation_json_safe.py +0 -0
  147. {agentcat-2.1.0 → agentcat-2.2.0}/tests/test_utils/__init__.py +0 -0
  148. {agentcat-2.1.0 → agentcat-2.2.0}/tests/test_utils/client.py +0 -0
  149. {agentcat-2.1.0 → agentcat-2.2.0}/tests/test_utils/community_catalog_server.py +0 -0
  150. {agentcat-2.1.0 → agentcat-2.2.0}/tests/test_utils/community_client.py +0 -0
  151. {agentcat-2.1.0 → agentcat-2.2.0}/tests/test_utils/community_openapi_server.py +0 -0
  152. {agentcat-2.1.0 → agentcat-2.2.0}/tests/test_utils/community_todo_server.py +0 -0
  153. {agentcat-2.1.0 → agentcat-2.2.0}/tests/test_utils/delivery.py +0 -0
  154. {agentcat-2.1.0 → agentcat-2.2.0}/tests/test_utils/flavors.py +0 -0
  155. {agentcat-2.1.0 → agentcat-2.2.0}/tests/test_utils/modern_server.py +0 -0
  156. {agentcat-2.1.0 → agentcat-2.2.0}/tests/test_utils/todo_server.py +0 -0
@@ -262,9 +262,59 @@ agentcat-python-sdk/
262
262
  - **Documentation**: Visit [docs.agentcat.com](https://docs.agentcat.com) for detailed guides
263
263
  - **Issues**: Browse [open issues](https://github.com/agentcathq/agentcat-python-sdk/issues) for areas needing help
264
264
 
265
- ## Versioning
266
-
267
- The AgentCat team handles versioning and releases. Your contributions will be included in the next appropriate release based on semantic versioning principles.
265
+ ## Record your change
266
+
267
+ Every change that a user can see adds an entry to the `[Unreleased]` section of `CHANGELOG.md`
268
+ in its pull request. The release notes come from this section.
269
+
270
+ ## Release a version
271
+
272
+ The AgentCat team releases the SDK. The release workflow (`.github/workflows/release.yml`) does
273
+ the release in two steps, with a pull request between them. The Java, Rust and Ruby SDKs release
274
+ the same way.
275
+
276
+ 1. In GitHub, open **Actions > Release > Run workflow** on `main`. Keep `patch`, or type `minor`,
277
+ `major` or an exact version such as `2.2.0`. The words count from the newest `vX.Y.Z` tag.
278
+ 2. The workflow opens the pull request "Release vX.Y.Z". It sets the version in `pyproject.toml`
279
+ and turns `[Unreleased]` into the dated section of the version. It also starts
280
+ `mcp-compatibility.yml` on the pull request, for the required check `report-compatibility`. An
281
+ `[Unreleased]` section with no entry, or a version that PyPI already has, stops the workflow.
282
+ 3. Read the pull request, and merge it when CI passes.
283
+ 4. The merge starts the workflow again. It waits for the `mcp-compatibility.yml` run of the merge
284
+ commit, builds the sdist and the wheel, and uploads them to PyPI. Then it creates the tag
285
+ `vX.Y.Z` and its GitHub release, with the CHANGELOG section as the notes.
286
+
287
+ If a step fails, fix the cause and re-run the failed jobs of that run. The publish job skips the
288
+ files that PyPI already has, and the tag comes last.
289
+
290
+ Do not upload to PyPI from your machine. PyPI never accepts a file name twice, not even after you
291
+ delete the file, so a local upload can use up a version for good. Only the release workflow
292
+ publishes.
293
+
294
+ The workflow releases `X.Y.Z` versions only. A pre-release, such as `2.2.0b1`, stays a manual task:
295
+ set the version in `pyproject.toml`, build with `uv build --no-sources`, and upload the files with
296
+ `uv publish` and a PyPI API token. Do not tag it `vX.Y.Z`, and do not add a dated section for it to
297
+ `CHANGELOG.md`.
298
+
299
+ To run a step of the workflow by hand, use `python .github/scripts/release.py prepare <patch |
300
+ minor | major | X.Y.Z> <YYYY-MM-DD>`, `status` or `notes <X.Y.Z>`. The script needs only the
301
+ standard library, and the wheel and the sdist do not include it. `tests/test_release.py` tests
302
+ these steps in the normal suite, so CI runs it on each pull request and each push to `main`.
303
+
304
+ The publish job uses PyPI trusted publishing: PyPI trades the OIDC token of the job for a
305
+ short-lived API token, so GitHub stores no PyPI secret. The upload also adds a PEP 740
306
+ attestation of each file, which PyPI shows on the file page. The job also attests the build
307
+ provenance of the files with Sigstore. To make sure that a file came from this workflow, run
308
+ `gh attestation verify agentcat-X.Y.Z-py3-none-any.whl -R agentcathq/agentcat-python-sdk`.
309
+
310
+ ### One-time setup
311
+
312
+ - In the repository settings, turn on **Actions > General > Allow GitHub Actions to create and
313
+ approve pull requests**, so that the workflow can open the release pull request.
314
+ - Create a `release` environment, limited to the `main` branch.
315
+ - On pypi.org, an owner of `agentcat` adds a trusted publisher under **Your projects > agentcat >
316
+ Manage > Publishing > GitHub**: the owner `agentcathq`, the repository `agentcat-python-sdk`, the
317
+ workflow `release.yml` and the environment `release`.
268
318
 
269
319
  ## Recognition
270
320
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: agentcat
3
- Version: 2.1.0
3
+ Version: 2.2.0
4
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
@@ -16,7 +16,7 @@ Classifier: Programming Language :: Python :: 3.10
16
16
  Classifier: Programming Language :: Python :: 3.11
17
17
  Classifier: Programming Language :: Python :: 3.12
18
18
  Requires-Python: >=3.10
19
- Requires-Dist: agentcat-api==1.0.0
19
+ Requires-Dist: agentcat-api==1.0.5
20
20
  Requires-Dist: mcp<3,>=1.2.0
21
21
  Requires-Dist: pydantic<3,>=2.0.0
22
22
  Requires-Dist: requests>=2.31.0
@@ -44,7 +44,7 @@ Description-Content-Type: text/markdown
44
44
  <span> · </span>
45
45
  <a href="#free-for-open-source">Open Source</a>
46
46
  <span> · </span>
47
- <a href="https://meet.agentcat.com/meet">Schedule a Demo</a>
47
+ <a href="https://book.agentcat.com/meet">Schedule a Demo</a>
48
48
  </h3>
49
49
  <p align="center">
50
50
  <a href="https://badge.fury.io/py/agentcat"><img src="https://badge.fury.io/py/agentcat.svg" alt="PyPI version"></a>
@@ -12,7 +12,7 @@
12
12
  <span> · </span>
13
13
  <a href="#free-for-open-source">Open Source</a>
14
14
  <span> · </span>
15
- <a href="https://meet.agentcat.com/meet">Schedule a Demo</a>
15
+ <a href="https://book.agentcat.com/meet">Schedule a Demo</a>
16
16
  </h3>
17
17
  <p align="center">
18
18
  <a href="https://badge.fury.io/py/agentcat"><img src="https://badge.fury.io/py/agentcat.svg" alt="PyPI version"></a>
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "agentcat"
3
- version = "2.1.0"
3
+ version = "2.2.0"
4
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" },
@@ -19,7 +19,7 @@ classifiers = [
19
19
  ]
20
20
  dependencies = [
21
21
  "mcp>=1.2.0,<3",
22
- "agentcat-api==1.0.0",
22
+ "agentcat-api==1.0.5",
23
23
  "pydantic>=2.0.0,<3",
24
24
  "requests>=2.31.0",
25
25
  ]
@@ -73,6 +73,14 @@ from agentcat.modules.handles import HandleResolution
73
73
  from agentcat.modules.injection import ToolSpec, build_injected_schemas
74
74
  from agentcat.modules.logging import write_to_log
75
75
  from agentcat.modules.request_extra import extra_from_request_context
76
+ from agentcat.modules.server_info import (
77
+ FEEDBACK_NOTE,
78
+ LIST_REQUEST,
79
+ TOOL_CALL,
80
+ ServerInfoSource,
81
+ identity_text,
82
+ )
83
+ from agentcat.modules.server_info import check as check_server_info
76
84
  from agentcat.modules.tools import GET_MORE_TOOLS_DESCRIPTION
77
85
  from agentcat.types import AgentCatData, ErrorData
78
86
 
@@ -135,6 +143,28 @@ def _request_context(context: Any) -> Any:
135
143
  return None
136
144
 
137
145
 
146
+ def _serves_a_tool_call(request_context: Any) -> bool:
147
+ """Whether the MCP request behind a ``tools/list`` pass is another method.
148
+
149
+ The mcp 1.x lowlevel server fills its tool cache through the ``tools/list``
150
+ handler in the middle of a ``tools/call``, and under FastMCP 3 that listing
151
+ runs the middleware chain like a client's. The session knows which request
152
+ it is answering. mcp 2.x keeps no such table; there the HTTP request says
153
+ it, on the one path where mcp lists inside a call. A context that says
154
+ neither is taken to be answering what the middleware was handed.
155
+ """
156
+ from agentcat.modules.adapters.lowlevel_v2 import lists_for_another_request
157
+
158
+ if lists_for_another_request(request_context):
159
+ return True
160
+ try:
161
+ in_flight = request_context.session._in_flight
162
+ request = in_flight[request_context.request_id].request
163
+ return bool(getattr(request, "root", request).method == "tools/call")
164
+ except Exception:
165
+ return False
166
+
167
+
138
168
  def _connection_key(source: Any) -> Any:
139
169
  """The per-connection object a handshake capture is filed under, or None.
140
170
 
@@ -291,9 +321,15 @@ class AgentCatMiddleware:
291
321
  if method == "initialize":
292
322
  return await self.on_initialize(context, call_next)
293
323
  if method == "tools/list":
294
- return await self.on_list_tools(context, call_next)
324
+ try:
325
+ return await self.on_list_tools(context, call_next)
326
+ finally:
327
+ self._check_server_info(context, is_list=True)
295
328
  if method == "tools/call":
296
- return await self.on_call_tool(context, call_next)
329
+ try:
330
+ return await self.on_call_tool(context, call_next)
331
+ finally:
332
+ self._check_server_info(context, is_list=False)
297
333
  return await call_next(context)
298
334
 
299
335
  # ── helpers ─────────────────────────────────────────────────────────────
@@ -348,6 +384,75 @@ class AgentCatMiddleware:
348
384
  except TypeError:
349
385
  return None
350
386
 
387
+ def _check_server_info(self, context: Any, is_list: bool) -> None:
388
+ """Run the heartbeat check for a request this middleware has served.
389
+
390
+ Called from a ``finally``, so nothing may leave it: an error here would
391
+ replace the result of the request.
392
+
393
+ Three passes do not count as a request of a client. One is the server
394
+ driving itself from inside a tool call, which the enclosing call
395
+ answers for. One is a listing or a call made with no MCP request
396
+ behind it, such as ``server.list_tools()`` at startup: the list
397
+ handlers need the context of a live request. The last is the listing
398
+ mcp 1.x makes on its own while it serves a tool call.
399
+ """
400
+ try:
401
+ if _enclosing_frame(self._server) is not None:
402
+ return
403
+ request_context = _request_context(context)
404
+ if request_context is None:
405
+ return
406
+ if is_list:
407
+ if _serves_a_tool_call(request_context):
408
+ return
409
+ kind = LIST_REQUEST
410
+ elif (
411
+ getattr(context.message, "name", None) == GET_MORE_TOOLS_NAME
412
+ and self._registered_get_more_tools is not None
413
+ ):
414
+ kind = FEEDBACK_NOTE
415
+ else:
416
+ kind = TOOL_CALL
417
+ check_server_info(
418
+ self._current_data(),
419
+ kind,
420
+ lambda: self._server_info_source(request_context),
421
+ )
422
+ except Exception:
423
+ return
424
+
425
+ def _server_info_source(self, request_context: Any) -> ServerInfoSource:
426
+ """What the heartbeat reads from this server, as of right now.
427
+
428
+ The lists come from the handlers FastMCP registered on its lowlevel
429
+ server, which is what answers a client: they run this middleware, the
430
+ customer's middleware and FastMCP's own paging. The handler table has
431
+ the mcp 1.x shape under FastMCP 3 and the mcp 2.x shape under FastMCP 4.
432
+
433
+ This runs inside the build task, which starts with a copy of the
434
+ context of the request. The call frames are emptied in it, so the tool
435
+ listing is injected like a client's and not served verbatim like a
436
+ listing from inside a tool call.
437
+ """
438
+ _call_frames.set(())
439
+ lowlevel = self._server._mcp_server
440
+ if hasattr(lowlevel, "request_handlers"):
441
+ from agentcat.modules.adapters.lowlevel_v1 import list_fetchers as v1
442
+
443
+ lists = v1(lowlevel)
444
+ else:
445
+ from agentcat.modules.adapters.lowlevel_v2 import list_fetchers as v2
446
+
447
+ # FastMCP 4 hands its middleware a wrapper; the handlers take the
448
+ # SDK's own request context, which the wrapper carries.
449
+ lists = v2(lowlevel, getattr(request_context, "_srctx", request_context))
450
+ return ServerInfoSource(
451
+ title=identity_text(lowlevel, "title"),
452
+ instructions=identity_text(lowlevel, "instructions"),
453
+ lists=lists,
454
+ )
455
+
351
456
  def _specs(self, tools: list[Any]) -> list[ToolSpec | None]:
352
457
  """Copies of the listed schemas, ready for the in-place injection pass.
353
458
 
@@ -41,6 +41,16 @@ from agentcat.modules.adapters._inner_tap import (
41
41
  )
42
42
  from agentcat.modules.logging import write_to_log
43
43
  from agentcat.modules.request_extra import extra_from_request_context
44
+ from agentcat.modules.server_info import (
45
+ FEEDBACK_NOTE,
46
+ LIST_REQUEST,
47
+ TOOL_CALL,
48
+ Page,
49
+ PageFetcher,
50
+ ServerInfoSource,
51
+ identity_text,
52
+ )
53
+ from agentcat.modules.server_info import check as check_server_info
44
54
  from agentcat.types import AgentCatData
45
55
 
46
56
  # The two handlers this adapter wraps, keyed by the name of the ``Server``
@@ -52,6 +62,72 @@ _LIST = "list_tools"
52
62
  _CALL = "call_tool"
53
63
 
54
64
 
65
+ # The lists of the server info heartbeat: the key of each one in the body, the
66
+ # name of its request model and its field on the result.
67
+ _INFO_LISTS = (
68
+ ("tools", "ListToolsRequest", "tools/list", "tools"),
69
+ ("resources", "ListResourcesRequest", "resources/list", "resources"),
70
+ (
71
+ "resourceTemplates",
72
+ "ListResourceTemplatesRequest",
73
+ "resources/templates/list",
74
+ "resourceTemplates",
75
+ ),
76
+ ("prompts", "ListPromptsRequest", "prompts/list", "prompts"),
77
+ )
78
+
79
+
80
+ def _list_request(request_type: Any, method: str, cursor: Any) -> Any:
81
+ """The request a client sends for one page of a list.
82
+
83
+ The cursor rides in ``params`` where this mcp 1.x has the model for it.
84
+ The oldest releases keep it as a field of the request itself.
85
+ """
86
+ if cursor is None:
87
+ return request_type(method=method)
88
+ try:
89
+ from mcp.types import PaginatedRequestParams
90
+ except ImportError:
91
+ return request_type(method=method, cursor=cursor)
92
+ return request_type(method=method, params=PaginatedRequestParams(cursor=cursor))
93
+
94
+
95
+ def page_fetcher(
96
+ handler: Any, request_type: Any, method: str, field: str, finish: Any = None
97
+ ) -> PageFetcher:
98
+ """Reads one list page by page through its registered handler.
99
+
100
+ ``finish`` turns the handler's result into the one a client receives.
101
+ """
102
+
103
+ async def fetch(cursor: Any) -> Page:
104
+ result = await handler(_list_request(request_type, method, cursor))
105
+ if finish is not None:
106
+ result = finish(result)
107
+ listed = getattr(result, "root", result)
108
+ return list(getattr(listed, field)), getattr(listed, "nextCursor", None)
109
+
110
+ return fetch
111
+
112
+
113
+ def list_fetchers(server: Any) -> dict[str, PageFetcher]:
114
+ """A fetcher for each list this server has a handler for.
115
+
116
+ A handler runs as it does for a client: it is called on the server's event
117
+ loop, in a context where ``server.request_context`` still answers with the
118
+ request that started the heartbeat.
119
+ """
120
+ import mcp.types as types
121
+
122
+ fetchers: dict[str, PageFetcher] = {}
123
+ for key, type_name, method, field in _INFO_LISTS:
124
+ request_type = getattr(types, type_name, None)
125
+ handler = server.request_handlers.get(request_type)
126
+ if request_type is not None and handler is not None:
127
+ fetchers[key] = page_fetcher(handler, request_type, method, field)
128
+ return fetchers
129
+
130
+
55
131
  def _safe_request_context(server: Any) -> Any:
56
132
  """The in-flight request context, or None outside a request.
57
133
 
@@ -236,7 +312,7 @@ def install_lowlevel_v1(server: Any, data: AgentCatData, facade: Any = None) ->
236
312
  )
237
313
 
238
314
  def advertised_tools(
239
- original: Any, options: Any
315
+ original: Any, options: Any, record: bool = True
240
316
  ) -> tuple[list[Any], set[int]]:
241
317
  """Deep copies of the listed tools, plus get_more_tools when enabled.
242
318
 
@@ -245,6 +321,9 @@ def install_lowlevel_v1(server: Any, data: AgentCatData, facade: Any = None) ->
245
321
  copy fails is carried through VERBATIM (the customer's object, never
246
322
  given to the pipeline) with its id() in the returned skip set — one
247
323
  uncopyable tool must not take down the whole listing.
324
+
325
+ ``record=False`` leaves the ownership flag alone: the server info
326
+ heartbeat reads a listing without changing how a call is served.
248
327
  """
249
328
  nonlocal agentcat_advertises_get_more_tools
250
329
  tools: list[Any] = []
@@ -265,12 +344,12 @@ def install_lowlevel_v1(server: Any, data: AgentCatData, facade: Any = None) ->
265
344
  customer_owns_get_more_tools = any(
266
345
  getattr(tool, "name", None) == GET_MORE_TOOLS_NAME for tool in tools
267
346
  )
268
- agentcat_advertises_get_more_tools = (
269
- options.enable_report_missing and not customer_owns_get_more_tools
270
- )
347
+ advertises = options.enable_report_missing and not customer_owns_get_more_tools
348
+ if record:
349
+ agentcat_advertises_get_more_tools = advertises
271
350
  # Appended before injection so it receives handle parameters too; the
272
351
  # context pass skips it by name, so early placement cannot double-inject.
273
- if agentcat_advertises_get_more_tools:
352
+ if advertises:
274
353
  tools.append(make_get_more_tools())
275
354
  return tools, skipped
276
355
 
@@ -294,23 +373,29 @@ def install_lowlevel_v1(server: Any, data: AgentCatData, facade: Any = None) ->
294
373
  tools, skipped = advertised_tools(listed, current_data().options)
295
374
  return [spec for spec in specs_for(tools, skipped) if spec is not None]
296
375
 
297
- async def wrapped_list(request: Any) -> Any:
298
- listed = await original(_LIST)(request)
376
+ def injected_listing(listed: Any, record: bool = True) -> Any:
377
+ """The listing a client receives for the customer's ``listed``.
378
+
379
+ ``record=False`` builds it without writing the registries a later call
380
+ strips by, which is what the server info heartbeat needs: it reads
381
+ every page, and a page must not replace what a client's listing wrote.
382
+ """
299
383
  tracking = current_data()
300
384
  try:
301
- tools, skipped = advertised_tools(listed, tracking.options)
385
+ tools, skipped = advertised_tools(listed, tracking.options, record)
302
386
  specs = specs_for(tools, skipped)
303
387
  injected = build_injected_schemas(
304
388
  [spec for spec in specs if spec is not None],
305
389
  tracking.options,
306
390
  tracking.reported_conflicts,
307
391
  )
308
- tracking.injected_params_registry = injected.injected_params
309
- tracking.output_injection_registry = injected.output_injected
310
- # Union, never replace: membership only grows, and a concurrent
311
- # listing on another instance may already have recorded a tool this
312
- # one did not see.
313
- tracking.declared_session_params |= injected.declared_session_params
392
+ if record:
393
+ tracking.injected_params_registry = injected.injected_params
394
+ tracking.output_injection_registry = injected.output_injected
395
+ # Union, never replace: membership only grows, and a concurrent
396
+ # listing on another instance may already have recorded a tool
397
+ # this one did not see.
398
+ tracking.declared_session_params |= injected.declared_session_params
314
399
  for tool, spec in zip(tools, specs, strict=True):
315
400
  if spec is None:
316
401
  continue # uncopyable tool: served verbatim, never mutated
@@ -328,12 +413,69 @@ def install_lowlevel_v1(server: Any, data: AgentCatData, facade: Any = None) ->
328
413
  )
329
414
  return listed
330
415
 
416
+ def server_info_source() -> ServerInfoSource:
417
+ """What the heartbeat reads from this server, as of right now."""
418
+ lists = list_fetchers(server)
419
+ list_handler = original(_LIST)
420
+ if list_handler is None:
421
+ lists.pop("tools", None)
422
+ else:
423
+ # The table holds this adapter's wrapper. The heartbeat goes to the
424
+ # customer's handler and injects without recording.
425
+ lists["tools"] = page_fetcher(
426
+ list_handler,
427
+ ListToolsRequest,
428
+ "tools/list",
429
+ "tools",
430
+ finish=lambda listed: injected_listing(listed, record=False),
431
+ )
432
+ return ServerInfoSource(
433
+ title=identity_text(server, "title"),
434
+ instructions=identity_text(server, "instructions"),
435
+ lists=lists,
436
+ )
437
+
438
+ def check_after(request: Any, is_list: bool) -> None:
439
+ """Run the heartbeat check for a request this adapter has served.
440
+
441
+ Called from a ``finally``, so nothing may leave it: an error here would
442
+ replace the result of the request.
443
+ """
444
+ try:
445
+ if is_list:
446
+ kind = LIST_REQUEST
447
+ elif (
448
+ getattr(request.params, "name", None) == GET_MORE_TOOLS_NAME
449
+ and agentcat_advertises_get_more_tools
450
+ ):
451
+ kind = FEEDBACK_NOTE
452
+ else:
453
+ kind = TOOL_CALL
454
+ check_server_info(current_data(), kind, server_info_source)
455
+ except Exception:
456
+ return
457
+
458
+ async def wrapped_list(request: Any) -> Any:
459
+ try:
460
+ return injected_listing(await original(_LIST)(request))
461
+ finally:
462
+ # The SDK refreshes its own tool cache through this handler with no
463
+ # request at all. That is not a client asking for the list.
464
+ if request is not None:
465
+ check_after(request, is_list=True)
466
+
467
+ async def wrapped_call(request: Any) -> Any:
468
+ try:
469
+ return await tracked_call(request)
470
+ finally:
471
+ check_after(request, is_list=False)
472
+
331
473
  async def run_original(request: Any, arguments: dict[str, Any]) -> Any:
332
474
  """Dispatch to the customer's handler on a clone carrying only their args."""
333
475
  params = request.params.model_copy(update={"arguments": arguments})
334
476
  return await original(_CALL)(request.model_copy(update={"params": params}))
335
477
 
336
- async def wrapped_call(request: Any) -> Any:
478
+ async def tracked_call(request: Any) -> Any:
337
479
  tracking = current_data()
338
480
  options = tracking.options
339
481
  name = getattr(request.params, "name", None) or "Unknown Tool"